-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Sort init import #10801
Merged
Merged
Sort init import #10801
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16f9479
Initial script
sgugger ce520fa
Add script to properly sort imports in init.
sgugger ae154f6
Add to the CI
sgugger 3e78efb
Update utils/custom_init_isort.py
sgugger ff01e89
Separate scripts that change content from quality
sgugger 66ba6b0
Move class_mapping_update to style_checks
sgugger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ | |
"xnli_processors", | ||
"xnli_tasks_num_labels", | ||
], | ||
"feature_extraction_sequence_utils": ["BatchFeature", "SequenceFeatureExtractor"], | ||
"file_utils": [ | ||
"CONFIG_NAME", | ||
"MODEL_CARD_NAME", | ||
|
@@ -124,23 +125,8 @@ | |
"load_tf2_model_in_pytorch_model", | ||
"load_tf2_weights_in_pytorch_model", | ||
], | ||
"models": [], | ||
# Models | ||
"models.wav2vec2": [ | ||
"WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
"Wav2Vec2Config", | ||
"Wav2Vec2CTCTokenizer", | ||
"Wav2Vec2Tokenizer", | ||
"Wav2Vec2FeatureExtractor", | ||
"Wav2Vec2Processor", | ||
], | ||
"models.m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config"], | ||
"models.speech_to_text": [ | ||
"SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
"Speech2TextConfig", | ||
"Speech2TextFeatureExtractor", | ||
], | ||
"models.convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvBertConfig", "ConvBertTokenizer"], | ||
"models": [], | ||
"models.albert": ["ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "AlbertConfig"], | ||
"models.auto": [ | ||
"ALL_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
|
@@ -169,6 +155,7 @@ | |
"BlenderbotSmallTokenizer", | ||
], | ||
"models.camembert": ["CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "CamembertConfig"], | ||
"models.convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvBertConfig", "ConvBertTokenizer"], | ||
"models.ctrl": ["CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP", "CTRLConfig", "CTRLTokenizer"], | ||
"models.deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaConfig", "DebertaTokenizer"], | ||
"models.deberta_v2": ["DEBERTA_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaV2Config"], | ||
|
@@ -193,6 +180,7 @@ | |
"models.led": ["LED_PRETRAINED_CONFIG_ARCHIVE_MAP", "LEDConfig", "LEDTokenizer"], | ||
"models.longformer": ["LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "LongformerConfig", "LongformerTokenizer"], | ||
"models.lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LxmertConfig", "LxmertTokenizer"], | ||
"models.m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config"], | ||
"models.marian": ["MarianConfig"], | ||
"models.mbart": ["MBartConfig"], | ||
"models.mmbt": ["MMBTConfig"], | ||
|
@@ -207,6 +195,11 @@ | |
"models.reformer": ["REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "ReformerConfig"], | ||
"models.retribert": ["RETRIBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RetriBertConfig", "RetriBertTokenizer"], | ||
"models.roberta": ["ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "RobertaConfig", "RobertaTokenizer"], | ||
"models.speech_to_text": [ | ||
"SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
"Speech2TextConfig", | ||
"Speech2TextFeatureExtractor", | ||
], | ||
"models.squeezebert": ["SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "SqueezeBertConfig", "SqueezeBertTokenizer"], | ||
"models.t5": ["T5_PRETRAINED_CONFIG_ARCHIVE_MAP", "T5Config"], | ||
"models.tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig", "TapasTokenizer"], | ||
|
@@ -216,6 +209,14 @@ | |
"TransfoXLCorpus", | ||
"TransfoXLTokenizer", | ||
], | ||
"models.wav2vec2": [ | ||
"WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP", | ||
"Wav2Vec2Config", | ||
"Wav2Vec2CTCTokenizer", | ||
"Wav2Vec2FeatureExtractor", | ||
"Wav2Vec2Processor", | ||
"Wav2Vec2Tokenizer", | ||
], | ||
"models.xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMTokenizer"], | ||
"models.xlm_prophetnet": ["XLM_PROPHETNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMProphetNetConfig"], | ||
"models.xlm_roberta": ["XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMRobertaConfig"], | ||
|
@@ -251,7 +252,6 @@ | |
"SpecialTokensMixin", | ||
"TokenSpan", | ||
], | ||
"feature_extraction_sequence_utils": ["SequenceFeatureExtractor", "BatchFeature"], | ||
"trainer_callback": [ | ||
"DefaultFlowCallback", | ||
"EarlyStoppingCallback", | ||
|
@@ -383,54 +383,14 @@ | |
"TopPLogitsWarper", | ||
] | ||
_import_structure["generation_stopping_criteria"] = [ | ||
"StoppingCriteria", | ||
"StoppingCriteriaList", | ||
"MaxLengthCriteria", | ||
"MaxTimeCriteria", | ||
"StoppingCriteria", | ||
"StoppingCriteriaList", | ||
] | ||
_import_structure["generation_utils"] = ["top_k_top_p_filtering"] | ||
_import_structure["modeling_utils"] = ["Conv1D", "PreTrainedModel", "apply_chunking_to_forward", "prune_layer"] | ||
# PyTorch models structure | ||
|
||
_import_structure["models.speech_to_text"].extend( | ||
[ | ||
"SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"Speech2TextForConditionalGeneration", | ||
"Speech2TextModel", | ||
] | ||
) | ||
|
||
_import_structure["models.wav2vec2"].extend( | ||
[ | ||
"WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"Wav2Vec2ForCTC", | ||
"Wav2Vec2ForMaskedLM", | ||
"Wav2Vec2Model", | ||
"Wav2Vec2PreTrainedModel", | ||
] | ||
) | ||
_import_structure["models.m2m_100"].extend( | ||
[ | ||
"M2M_100_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"M2M100ForConditionalGeneration", | ||
"M2M100Model", | ||
] | ||
) | ||
|
||
_import_structure["models.convbert"].extend( | ||
[ | ||
"CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"ConvBertForMaskedLM", | ||
"ConvBertForMultipleChoice", | ||
"ConvBertForQuestionAnswering", | ||
"ConvBertForSequenceClassification", | ||
"ConvBertForTokenClassification", | ||
"ConvBertLayer", | ||
"ConvBertModel", | ||
"ConvBertPreTrainedModel", | ||
"load_tf_weights_in_convbert", | ||
] | ||
) | ||
_import_structure["models.albert"].extend( | ||
[ | ||
"ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -512,17 +472,17 @@ | |
_import_structure["models.blenderbot"].extend( | ||
[ | ||
"BLENDERBOT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"BlenderbotForCausalLM", | ||
"BlenderbotForConditionalGeneration", | ||
"BlenderbotModel", | ||
"BlenderbotForCausalLM", | ||
] | ||
) | ||
_import_structure["models.blenderbot_small"].extend( | ||
[ | ||
"BLENDERBOT_SMALL_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"BlenderbotSmallForCausalLM", | ||
"BlenderbotSmallForConditionalGeneration", | ||
"BlenderbotSmallModel", | ||
"BlenderbotSmallForCausalLM", | ||
] | ||
) | ||
_import_structure["models.camembert"].extend( | ||
|
@@ -537,6 +497,20 @@ | |
"CamembertModel", | ||
] | ||
) | ||
_import_structure["models.convbert"].extend( | ||
[ | ||
"CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"ConvBertForMaskedLM", | ||
"ConvBertForMultipleChoice", | ||
"ConvBertForQuestionAnswering", | ||
"ConvBertForSequenceClassification", | ||
"ConvBertForTokenClassification", | ||
"ConvBertLayer", | ||
"ConvBertModel", | ||
"ConvBertPreTrainedModel", | ||
"load_tf_weights_in_convbert", | ||
] | ||
) | ||
_import_structure["models.ctrl"].extend( | ||
[ | ||
"CTRL_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -549,23 +523,23 @@ | |
_import_structure["models.deberta"].extend( | ||
[ | ||
"DEBERTA_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"DebertaForMaskedLM", | ||
"DebertaForQuestionAnswering", | ||
"DebertaForSequenceClassification", | ||
"DebertaForTokenClassification", | ||
"DebertaModel", | ||
"DebertaForMaskedLM", | ||
"DebertaPreTrainedModel", | ||
"DebertaForTokenClassification", | ||
"DebertaForQuestionAnswering", | ||
] | ||
) | ||
_import_structure["models.deberta_v2"].extend( | ||
[ | ||
"DEBERTA_V2_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"DebertaV2ForMaskedLM", | ||
"DebertaV2ForQuestionAnswering", | ||
"DebertaV2ForSequenceClassification", | ||
"DebertaV2ForTokenClassification", | ||
"DebertaV2Model", | ||
"DebertaV2ForMaskedLM", | ||
"DebertaV2PreTrainedModel", | ||
"DebertaV2ForTokenClassification", | ||
"DebertaV2ForQuestionAnswering", | ||
] | ||
) | ||
_import_structure["models.distilbert"].extend( | ||
|
@@ -699,7 +673,14 @@ | |
"LxmertXLayer", | ||
] | ||
) | ||
_import_structure["models.marian"].extend(["MarianModel", "MarianMTModel", "MarianForCausalLM"]) | ||
_import_structure["models.m2m_100"].extend( | ||
[ | ||
"M2M_100_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"M2M100ForConditionalGeneration", | ||
"M2M100Model", | ||
] | ||
) | ||
_import_structure["models.marian"].extend(["MarianForCausalLM", "MarianModel", "MarianMTModel"]) | ||
_import_structure["models.mbart"].extend( | ||
[ | ||
"MBartForCausalLM", | ||
|
@@ -752,7 +733,7 @@ | |
] | ||
) | ||
_import_structure["models.pegasus"].extend( | ||
["PegasusForConditionalGeneration", "PegasusModel", "PegasusForCausalLM"] | ||
["PegasusForCausalLM", "PegasusForConditionalGeneration", "PegasusModel"] | ||
) | ||
_import_structure["models.prophetnet"].extend( | ||
[ | ||
|
@@ -793,6 +774,13 @@ | |
"RobertaModel", | ||
] | ||
) | ||
_import_structure["models.speech_to_text"].extend( | ||
[ | ||
"SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"Speech2TextForConditionalGeneration", | ||
"Speech2TextModel", | ||
] | ||
) | ||
_import_structure["models.squeezebert"].extend( | ||
[ | ||
"SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -836,6 +824,15 @@ | |
"load_tf_weights_in_transfo_xl", | ||
] | ||
) | ||
_import_structure["models.wav2vec2"].extend( | ||
[ | ||
"WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"Wav2Vec2ForCTC", | ||
"Wav2Vec2ForMaskedLM", | ||
"Wav2Vec2Model", | ||
"Wav2Vec2PreTrainedModel", | ||
] | ||
) | ||
_import_structure["models.xlm"].extend( | ||
[ | ||
"XLM_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -916,20 +913,6 @@ | |
"shape_list", | ||
] | ||
# TensorFlow models structure | ||
|
||
_import_structure["models.convbert"].extend( | ||
[ | ||
"TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"TFConvBertForMaskedLM", | ||
"TFConvBertForMultipleChoice", | ||
"TFConvBertForQuestionAnswering", | ||
"TFConvBertForSequenceClassification", | ||
"TFConvBertForTokenClassification", | ||
"TFConvBertLayer", | ||
"TFConvBertModel", | ||
"TFConvBertPreTrainedModel", | ||
] | ||
) | ||
_import_structure["models.albert"].extend( | ||
[ | ||
"TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -1002,6 +985,19 @@ | |
"TFCamembertModel", | ||
] | ||
) | ||
_import_structure["models.convbert"].extend( | ||
[ | ||
"TF_CONVBERT_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
"TFConvBertForMaskedLM", | ||
"TFConvBertForMultipleChoice", | ||
"TFConvBertForQuestionAnswering", | ||
"TFConvBertForSequenceClassification", | ||
"TFConvBertForTokenClassification", | ||
"TFConvBertLayer", | ||
"TFConvBertModel", | ||
"TFConvBertPreTrainedModel", | ||
] | ||
) | ||
_import_structure["models.ctrl"].extend( | ||
[ | ||
"TF_CTRL_PRETRAINED_MODEL_ARCHIVE_LIST", | ||
|
@@ -1108,7 +1104,7 @@ | |
"TFLxmertVisualFeatureEncoder", | ||
] | ||
) | ||
_import_structure["models.marian"].extend(["TFMarianMTModel", "TFMarianModel"]) | ||
_import_structure["models.marian"].extend(["TFMarianModel", "TFMarianMTModel"]) | ||
_import_structure["models.mbart"].extend(["TFMBartForConditionalGeneration", "TFMBartModel"]) | ||
_import_structure["models.mobilebert"].extend( | ||
[ | ||
|
@@ -2170,7 +2166,7 @@ | |
TFLxmertPreTrainedModel, | ||
TFLxmertVisualFeatureEncoder, | ||
) | ||
from .models.marian import TFMarian, TFMarianMTModel | ||
from .models.marian import TFMarianModel, TFMarianMTModel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Completely unrelated to this PR, renamed that object to its proper name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! |
||
from .models.mbart import TFMBartForConditionalGeneration, TFMBartModel | ||
from .models.mobilebert import ( | ||
TF_MOBILEBERT_PRETRAINED_MODEL_ARCHIVE_LIST, | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put this in the
extra_quality_checks
too so that it runs withmake fixup