ESM openfold_utils type hints#20544
Merged
Rocketknight1 merged 9 commits intohuggingface:mainfrom Dec 5, 2022
Merged
Conversation
|
The documentation is not available anymore as the PR was closed or merged. |
Member
|
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! |
Member
|
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
Member
|
@ringohoffman Looks good to me now! Are you okay with me merging it? |
Author
I'm good if you are! |
Rocketknight1
approved these changes
Dec 5, 2022
mpierrau
pushed a commit
to mpierrau/transformers
that referenced
this pull request
Dec 15, 2022
* 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 <rocketknight1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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