Skip to content

Commit 2c2e67b

Browse files
authored
Update inputs.py (#202)
1 parent 09db704 commit 2c2e67b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

alphafold3_pytorch/inputs.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,7 +3454,7 @@ def register_input_transform(input_type: Type, fn: Callable[[Any], AtomInput]):
34543454

34553455

34563456
@typecheck
3457-
def maybe_transform_to_atom_input(i: Any) -> AtomInput:
3457+
def maybe_transform_to_atom_input(i: Any, raise_exception: bool = False) -> AtomInput | None:
34583458
"""Convert an input to an AtomInput."""
34593459
maybe_to_atom_fn = INPUT_TO_ATOM_TRANSFORM.get(type(i), None)
34603460

@@ -3463,10 +3463,17 @@ def maybe_transform_to_atom_input(i: Any) -> AtomInput:
34633463
f"invalid input type {type(i)} being passed into Trainer that is not converted to AtomInput correctly"
34643464
)
34653465

3466-
return maybe_to_atom_fn(i)
3466+
try:
3467+
return maybe_to_atom_fn(i)
3468+
except Exception as e:
3469+
logger.error(f"Failed to convert input {i} to AtomInput due to: {e}")
3470+
if raise_exception:
3471+
raise e
3472+
return None
34673473

34683474

34693475
@typecheck
34703476
def maybe_transform_to_atom_inputs(inputs: List[Any]) -> List[AtomInput]:
34713477
"""Convert a list of inputs to AtomInputs."""
3472-
return [maybe_transform_to_atom_input(i) for i in inputs]
3478+
maybe_atom_inputs = [maybe_transform_to_atom_input(i) for i in inputs]
3479+
return [i for i in maybe_atom_inputs if exists(i)]

0 commit comments

Comments
 (0)