-
Notifications
You must be signed in to change notification settings - Fork 31.6k
ESM openfold_utils type hints #20544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
|
Wow, this is really comprehensive! All of your edits seem good, and thanks for catching those duplicate functions! The code is failing some of our code style checks, but I believe I can fix that for you, hang on! |
|
I think the other issues are just old issues with our repo - they'll be fixed if you pull from upstream on your fork's |
use isinstance builtin instead of 'type(x) is y'; add assertions to aid in type inferencing; use bools instead of ints in _get_minimal_slice_set for improved type clarity; refactor to avoid re-assigning to the same variable with a different type
refactor to avoid re-assigning to the same variable with a different type
refactor to avoid re-assigning to the same variable with a different type
refactor to avoid re-assigning to the same variable with a different type; fix Callable, Tuple type hints; match conditional structure to other methods; fix return type on Rotation.cat and Rotation.unsqueeze
overload for tree_map; use insinstance builtin instead of 'type(x) is y'; export dict_multimap, flatten_final_dims, permute_final_dims in openfold_utils
add FIXME for attempted string mutation; add missing None check in get_pdb_headers; fix potentially unbound variable 'chain_tag' in to_pdb; modify get_pdb_headers return type
hints on collection constants; remove magic trailing comma to reduce number of lines; change list -> tuple for rigid_group_atom_positions for improved hinting
f036d7f to
8eea668
Compare
|
@ringohoffman Looks good to me now! Are you okay with me merging it? |
I'm good if you are! |
* add type annotations for esm chunk_utils use isinstance builtin instead of 'type(x) is y'; add assertions to aid in type inferencing; use bools instead of ints in _get_minimal_slice_set for improved type clarity; refactor to avoid re-assigning to the same variable with a different type * add type annotations for esm data_transforms refactor to avoid re-assigning to the same variable with a different type * add type annotations for esm feats utils refactor to avoid re-assigning to the same variable with a different type * add type annotations for esm loss utils * add/fix type annotations for esm rigit_utils refactor to avoid re-assigning to the same variable with a different type; fix Callable, Tuple type hints; match conditional structure to other methods; fix return type on Rotation.cat and Rotation.unsqueeze * add type annotations for esm tensor_utils overload for tree_map; use insinstance builtin instead of 'type(x) is y'; export dict_multimap, flatten_final_dims, permute_final_dims in openfold_utils * add type annotations for esm protein utils add FIXME for attempted string mutation; add missing None check in get_pdb_headers; fix potentially unbound variable 'chain_tag' in to_pdb; modify get_pdb_headers return type * add type annotations for esm residue constants hints on collection constants; remove magic trailing comma to reduce number of lines; change list -> tuple for rigid_group_atom_positions for improved hinting * code style fixup Co-authored-by: Matt <[email protected]>
What does this PR do?
This PR generally adds type hints for the files located at
src/transformers/models/esm/openfold_utils/.dict_multimap,flatten_final_dims,permute_final_dimsin__init__.pysince these functions are currently duplicated in src/transformers/models/esm/modeling_esmfold.py; exporting these fromopenfold_utilsshould allow us to remove these duplicatestype(x) is yto use the builtinisinstance(x, y)assertstatements to to narrow typesFIXMEstatement at an apparent bug inprotein.pyin which string mutation is attemptedRelated: #16059
Before submitting
Who can review?
@Rocketknight1