Skip to content

Commit

Permalink
[Inference Client] Add task parameters and a maintenance script of th…
Browse files Browse the repository at this point in the history
…ese parameters (#2561)

* Add additional parameters to Inference Client tasks

* Add and run task params generation script

* Add back missing test

* Add comments to parameters generation script

* Fix shared classes imports + text-to-speech task

* Satisfy end-of-file-fixer hook

* Move helper function to avoid duplicates across scripts

* Rename helper function for more clarity

* Fix bug in node traversing

* Add comments

* improve docstring formatting

* fixes post-review

* Remove aliases from reference package

* Fix small bug and regenerate task parameters
  • Loading branch information
hanouticelina authored Oct 9, 2024
1 parent dcfb814 commit 613b591
Show file tree
Hide file tree
Showing 23 changed files with 1,653 additions and 223 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +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 type checking at least on huggingface_hub root file to check all modules
# that can be lazy-loaded actually exist.
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ quality:
python utils/check_contrib_list.py
python utils/check_static_imports.py
python utils/generate_async_inference_client.py

mypy src

style:
Expand All @@ -20,11 +21,14 @@ style:
python utils/check_static_imports.py --update
python utils/generate_async_inference_client.py --update

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

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


repocard:
python utils/push_repocard_examples.py
Expand Down
2 changes: 0 additions & 2 deletions docs/source/en/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,5 +398,3 @@ This part of the lib is still under development and will be improved in future r
[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInputData

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionOutputElement


2 changes: 0 additions & 2 deletions docs/source/ko/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,3 @@ rendered properly in your Markdown viewer.
[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInputData

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionOutputElement


1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def get_version() -> str:
extras["quality"] = [
"ruff>=0.5.0",
"mypy==1.5.1",
"libcst==1.4.0",
]

extras["all"] = extras["testing"] + extras["quality"] + extras["typing"]
Expand Down
16 changes: 16 additions & 0 deletions src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@
"inference._generated.types": [
"AudioClassificationInput",
"AudioClassificationOutputElement",
"AudioClassificationOutputTransform",
"AudioClassificationParameters",
"AudioToAudioInput",
"AudioToAudioOutputElement",
"AutomaticSpeechRecognitionEarlyStoppingEnum",
"AutomaticSpeechRecognitionGenerationParameters",
"AutomaticSpeechRecognitionInput",
"AutomaticSpeechRecognitionOutput",
Expand Down Expand Up @@ -328,6 +330,7 @@
"FillMaskParameters",
"ImageClassificationInput",
"ImageClassificationOutputElement",
"ImageClassificationOutputTransform",
"ImageClassificationParameters",
"ImageSegmentationInput",
"ImageSegmentationOutputElement",
Expand All @@ -336,6 +339,7 @@
"ImageToImageOutput",
"ImageToImageParameters",
"ImageToImageTargetSize",
"ImageToTextEarlyStoppingEnum",
"ImageToTextGenerationParameters",
"ImageToTextInput",
"ImageToTextOutput",
Expand All @@ -361,6 +365,7 @@
"Text2TextGenerationParameters",
"TextClassificationInput",
"TextClassificationOutputElement",
"TextClassificationOutputTransform",
"TextClassificationParameters",
"TextGenerationInput",
"TextGenerationInputGenerateParameters",
Expand All @@ -373,6 +378,7 @@
"TextGenerationStreamOutput",
"TextGenerationStreamOutputStreamDetails",
"TextGenerationStreamOutputToken",
"TextToAudioEarlyStoppingEnum",
"TextToAudioGenerationParameters",
"TextToAudioInput",
"TextToAudioOutput",
Expand All @@ -381,6 +387,7 @@
"TextToImageOutput",
"TextToImageParameters",
"TextToImageTargetSize",
"TextToSpeechEarlyStoppingEnum",
"TextToSpeechGenerationParameters",
"TextToSpeechInput",
"TextToSpeechOutput",
Expand All @@ -394,6 +401,7 @@
"TranslationParameters",
"VideoClassificationInput",
"VideoClassificationOutputElement",
"VideoClassificationOutputTransform",
"VideoClassificationParameters",
"VisualQuestionAnsweringInput",
"VisualQuestionAnsweringInputData",
Expand Down Expand Up @@ -796,9 +804,11 @@ def __dir__():
from .inference._generated.types import (
AudioClassificationInput, # noqa: F401
AudioClassificationOutputElement, # noqa: F401
AudioClassificationOutputTransform, # noqa: F401
AudioClassificationParameters, # noqa: F401
AudioToAudioInput, # noqa: F401
AudioToAudioOutputElement, # noqa: F401
AutomaticSpeechRecognitionEarlyStoppingEnum, # noqa: F401
AutomaticSpeechRecognitionGenerationParameters, # noqa: F401
AutomaticSpeechRecognitionInput, # noqa: F401
AutomaticSpeechRecognitionOutput, # noqa: F401
Expand Down Expand Up @@ -843,6 +853,7 @@ def __dir__():
FillMaskParameters, # noqa: F401
ImageClassificationInput, # noqa: F401
ImageClassificationOutputElement, # noqa: F401
ImageClassificationOutputTransform, # noqa: F401
ImageClassificationParameters, # noqa: F401
ImageSegmentationInput, # noqa: F401
ImageSegmentationOutputElement, # noqa: F401
Expand All @@ -851,6 +862,7 @@ def __dir__():
ImageToImageOutput, # noqa: F401
ImageToImageParameters, # noqa: F401
ImageToImageTargetSize, # noqa: F401
ImageToTextEarlyStoppingEnum, # noqa: F401
ImageToTextGenerationParameters, # noqa: F401
ImageToTextInput, # noqa: F401
ImageToTextOutput, # noqa: F401
Expand All @@ -876,6 +888,7 @@ def __dir__():
Text2TextGenerationParameters, # noqa: F401
TextClassificationInput, # noqa: F401
TextClassificationOutputElement, # noqa: F401
TextClassificationOutputTransform, # noqa: F401
TextClassificationParameters, # noqa: F401
TextGenerationInput, # noqa: F401
TextGenerationInputGenerateParameters, # noqa: F401
Expand All @@ -888,6 +901,7 @@ def __dir__():
TextGenerationStreamOutput, # noqa: F401
TextGenerationStreamOutputStreamDetails, # noqa: F401
TextGenerationStreamOutputToken, # noqa: F401
TextToAudioEarlyStoppingEnum, # noqa: F401
TextToAudioGenerationParameters, # noqa: F401
TextToAudioInput, # noqa: F401
TextToAudioOutput, # noqa: F401
Expand All @@ -896,6 +910,7 @@ def __dir__():
TextToImageOutput, # noqa: F401
TextToImageParameters, # noqa: F401
TextToImageTargetSize, # noqa: F401
TextToSpeechEarlyStoppingEnum, # noqa: F401
TextToSpeechGenerationParameters, # noqa: F401
TextToSpeechInput, # noqa: F401
TextToSpeechOutput, # noqa: F401
Expand All @@ -909,6 +924,7 @@ def __dir__():
TranslationParameters, # noqa: F401
VideoClassificationInput, # noqa: F401
VideoClassificationOutputElement, # noqa: F401
VideoClassificationOutputTransform, # noqa: F401
VideoClassificationParameters, # noqa: F401
VisualQuestionAnsweringInput, # noqa: F401
VisualQuestionAnsweringInputData, # noqa: F401
Expand Down
Loading

0 comments on commit 613b591

Please sign in to comment.