-
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
Sort init import #10801
Changes from 5 commits
16f9479
ce520fa
ae154f6
3e78efb
ff01e89
66ba6b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,32 +21,36 @@ deps_table_update: | |
|
||
# Check that source code meets quality standards | ||
|
||
extra_quality_checks: deps_table_update | ||
extra_quality_checks: | ||
python utils/check_copies.py | ||
python utils/check_table.py | ||
python utils/check_dummies.py | ||
python utils/check_repo.py | ||
python utils/style_doc.py src/transformers docs/source --max_len 119 | ||
python utils/class_mapping_update.py | ||
|
||
# this target runs checks on all files | ||
quality: | ||
black --check $(check_dirs) | ||
isort --check-only $(check_dirs) | ||
python utils/custom_init_isort.py --check_only | ||
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. I would put this in the |
||
flake8 $(check_dirs) | ||
python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only | ||
${MAKE} extra_quality_checks | ||
|
||
# Format source code automatically and check is there are any problems left that need manual fixing | ||
|
||
style: deps_table_update | ||
extra_style_checks: deps_table_update | ||
python utils/custom_init_isort.py | ||
python utils/style_doc.py src/transformers docs/source --max_len 119 | ||
|
||
# this target runs checks on all files | ||
style: | ||
stas00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
black $(check_dirs) | ||
isort $(check_dirs) | ||
python utils/style_doc.py src/transformers docs/source --max_len 119 | ||
${MAKE} extra_style_checks | ||
|
||
# Super fast fix and check target that only works on relevant modified files since the branch was made | ||
|
||
fixup: modified_only_fixup extra_quality_checks | ||
fixup: modified_only_fixup extra_style_checks extra_quality_checks | ||
|
||
# Make marked copies of snippets of codes conform to the original | ||
|
||
|
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, | ||
|
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.
should we create a new target for all the auto-generation items so it's loud-n-clear? It'd be something like:
as these aren't style or quality
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.
Oh I hadn't realized
class_mapping_update
was writing things. It should also disappear frommake quality
then to go with the others inextra_style_checks
.For me:
make fixup
-> applies the styling patches and checks everything passes quicklymake style
-> applying styling patches and other auto-generated codemake quality
-> only checks, does not write anythingThere 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 only ever use
make fixup
- the initial design was thatfixup
=style+quality
on only modified files.So it was created before we added 2 items that generated code, so if others prefer the quick version then
fixup
should include the autogenerate target too.Actually, is there is a situation where
fixup
won't do the right thing already? When does one need to run the fullmake style
?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.
class_mapping_update
doesn't do anything if the relevant file hasn't changed so it's blazingly fastwe can do the same for
deps_table_update
so it'd be instant 99% of the time, as currently it always runs.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.
Yes
fixup
isstyle+quality
on only modified files. My problem is that some processes that modify files have been added toextra-quality-checks
which is run byquality
on top offixup
. Sofixup
runsextra-quality-checks
as well asextra-styling-checks
to do both, I don't want to change that part.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.
See latest version for my proposal:
extra-quality-checks
common processes for quality and fixup, checks that are fast or need to run on all files, not changing any fileextra-style-checks
common processes for style and fixup, checks that are fast or need to run on all files, changing files if necessarystyle
style all files + other checks that are "writing" the right thingquality
check all files + other checks (in check only mode)fixup
same asstyle
+quality
but only on modified files.