Skip to content

Commit

Permalink
[InferenceClient] Automatically handle outdated task parameters (#2633)
Browse files Browse the repository at this point in the history
* wip: handle outdated task params

* fix script documentation

* remove text_to_image arg deprecation for now

* Fix check task params script

* Fix docstrings

* Fix docstrings again

* Fix imports

* Improve logging

* Rename cst visitor class for clarity

---------

Co-authored-by: Lucain <lucain@huggingface.co>
  • Loading branch information
hanouticelina and Wauplin authored Nov 18, 2024
1 parent 948f855 commit 96e297f
Show file tree
Hide file tree
Showing 9 changed files with 1,019 additions and 730 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- run: .venv/bin/python utils/check_static_imports.py
- run: .venv/bin/python utils/generate_async_inference_client.py
- run: .venv/bin/python utils/generate_inference_types.py
- run: .venv/bin/python utils/generate_task_parameters.py
- run: .venv/bin/python utils/check_task_parameters.py

# Run type checking at least on huggingface_hub root file to check all modules
# that can be lazy-loaded actually exist.
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ style:

inference_check:
python utils/generate_inference_types.py
python utils/generate_task_parameters.py
python utils/check_task_parameters.py

inference_update:
python utils/generate_inference_types.py --update
python utils/generate_task_parameters.py --update
python utils/check_task_parameters.py --update


repocard:
Expand Down
20 changes: 20 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@
"ChatCompletionInputFunctionDefinition",
"ChatCompletionInputFunctionName",
"ChatCompletionInputGrammarType",
"ChatCompletionInputGrammarTypeType",
"ChatCompletionInputMessage",
"ChatCompletionInputMessageChunk",
"ChatCompletionInputMessageChunkType",
"ChatCompletionInputStreamOptions",
"ChatCompletionInputToolType",
"ChatCompletionInputURL",
Expand Down Expand Up @@ -322,6 +324,7 @@
"DocumentQuestionAnsweringOutputElement",
"DocumentQuestionAnsweringParameters",
"FeatureExtractionInput",
"FeatureExtractionInputTruncationDirection",
"FillMaskInput",
"FillMaskOutputElement",
"FillMaskParameters",
Expand All @@ -332,6 +335,7 @@
"ImageSegmentationInput",
"ImageSegmentationOutputElement",
"ImageSegmentationParameters",
"ImageSegmentationSubtask",
"ImageToImageInput",
"ImageToImageOutput",
"ImageToImageParameters",
Expand All @@ -354,12 +358,14 @@
"SummarizationInput",
"SummarizationOutput",
"SummarizationParameters",
"SummarizationTruncationStrategy",
"TableQuestionAnsweringInput",
"TableQuestionAnsweringInputData",
"TableQuestionAnsweringOutputElement",
"Text2TextGenerationInput",
"Text2TextGenerationOutput",
"Text2TextGenerationParameters",
"Text2TextGenerationTruncationStrategy",
"TextClassificationInput",
"TextClassificationOutputElement",
"TextClassificationOutputTransform",
Expand All @@ -370,6 +376,7 @@
"TextGenerationOutput",
"TextGenerationOutputBestOfSequence",
"TextGenerationOutputDetails",
"TextGenerationOutputFinishReason",
"TextGenerationOutputPrefillToken",
"TextGenerationOutputToken",
"TextGenerationStreamOutput",
Expand All @@ -389,13 +396,16 @@
"TextToSpeechInput",
"TextToSpeechOutput",
"TextToSpeechParameters",
"TokenClassificationAggregationStrategy",
"TokenClassificationInput",
"TokenClassificationOutputElement",
"TokenClassificationParameters",
"ToolElement",
"TranslationInput",
"TranslationOutput",
"TranslationParameters",
"TranslationTruncationStrategy",
"TypeEnum",
"VideoClassificationInput",
"VideoClassificationOutputElement",
"VideoClassificationOutputTransform",
Expand Down Expand Up @@ -812,8 +822,10 @@ def __dir__():
ChatCompletionInputFunctionDefinition, # noqa: F401
ChatCompletionInputFunctionName, # noqa: F401
ChatCompletionInputGrammarType, # noqa: F401
ChatCompletionInputGrammarTypeType, # noqa: F401
ChatCompletionInputMessage, # noqa: F401
ChatCompletionInputMessageChunk, # noqa: F401
ChatCompletionInputMessageChunkType, # noqa: F401
ChatCompletionInputStreamOptions, # noqa: F401
ChatCompletionInputToolType, # noqa: F401
ChatCompletionInputURL, # noqa: F401
Expand Down Expand Up @@ -842,6 +854,7 @@ def __dir__():
DocumentQuestionAnsweringOutputElement, # noqa: F401
DocumentQuestionAnsweringParameters, # noqa: F401
FeatureExtractionInput, # noqa: F401
FeatureExtractionInputTruncationDirection, # noqa: F401
FillMaskInput, # noqa: F401
FillMaskOutputElement, # noqa: F401
FillMaskParameters, # noqa: F401
Expand All @@ -852,6 +865,7 @@ def __dir__():
ImageSegmentationInput, # noqa: F401
ImageSegmentationOutputElement, # noqa: F401
ImageSegmentationParameters, # noqa: F401
ImageSegmentationSubtask, # noqa: F401
ImageToImageInput, # noqa: F401
ImageToImageOutput, # noqa: F401
ImageToImageParameters, # noqa: F401
Expand All @@ -874,12 +888,14 @@ def __dir__():
SummarizationInput, # noqa: F401
SummarizationOutput, # noqa: F401
SummarizationParameters, # noqa: F401
SummarizationTruncationStrategy, # noqa: F401
TableQuestionAnsweringInput, # noqa: F401
TableQuestionAnsweringInputData, # noqa: F401
TableQuestionAnsweringOutputElement, # noqa: F401
Text2TextGenerationInput, # noqa: F401
Text2TextGenerationOutput, # noqa: F401
Text2TextGenerationParameters, # noqa: F401
Text2TextGenerationTruncationStrategy, # noqa: F401
TextClassificationInput, # noqa: F401
TextClassificationOutputElement, # noqa: F401
TextClassificationOutputTransform, # noqa: F401
Expand All @@ -890,6 +906,7 @@ def __dir__():
TextGenerationOutput, # noqa: F401
TextGenerationOutputBestOfSequence, # noqa: F401
TextGenerationOutputDetails, # noqa: F401
TextGenerationOutputFinishReason, # noqa: F401
TextGenerationOutputPrefillToken, # noqa: F401
TextGenerationOutputToken, # noqa: F401
TextGenerationStreamOutput, # noqa: F401
Expand All @@ -909,13 +926,16 @@ def __dir__():
TextToSpeechInput, # noqa: F401
TextToSpeechOutput, # noqa: F401
TextToSpeechParameters, # noqa: F401
TokenClassificationAggregationStrategy, # noqa: F401
TokenClassificationInput, # noqa: F401
TokenClassificationOutputElement, # noqa: F401
TokenClassificationParameters, # noqa: F401
ToolElement, # noqa: F401
TranslationInput, # noqa: F401
TranslationOutput, # noqa: F401
TranslationParameters, # noqa: F401
TranslationTruncationStrategy, # noqa: F401
TypeEnum, # noqa: F401
VideoClassificationInput, # noqa: F401
VideoClassificationOutputElement, # noqa: F401
VideoClassificationOutputTransform, # noqa: F401
Expand Down
Loading

0 comments on commit 96e297f

Please sign in to comment.