-
Notifications
You must be signed in to change notification settings - Fork 538
Huggingface Model Deployer #2376
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
Merged
safoinme
merged 48 commits into
zenml-io:develop
from
dudeperf3ct:huggingface-model-deployer
Mar 8, 2024
Merged
Changes from 3 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
0f7840d
Initial implementation of huggingface model deployer
dudeperf3ct 0c1a1de
Add missing step init
dudeperf3ct 1355422
Simplify modify_endpoint_name function and fix docstrings
dudeperf3ct f7ddd6b
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct 2fdde4b
Formatting logger
dudeperf3ct 44c8cd0
Add License to new files
dudeperf3ct a6231fa
Enhancements as per PR review comments
dudeperf3ct 51e83d1
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct 3c34a80
Add logging message to catch KeyError
dudeperf3ct efb9158
Merge branch 'develop' into huggingface-model-deployer
avishniakov 446454d
Remove duplicate variable
dudeperf3ct 3d5593a
Reorder lines for clarity
dudeperf3ct d619519
Merge branch 'develop' into huggingface-model-deployer
safoinme 33ea8a4
Add docs for huggingface model deployer
dudeperf3ct 147ec07
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct d9b16fa
Merge branch 'develop' into huggingface-model-deployer
strickvl cd17777
Fix CI errors
dudeperf3ct d9f3069
Merge remote-tracking branch 'origin/huggingface-model-deployer' into…
dudeperf3ct 479166b
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct d2dc135
Fix get_model_info function arguments
dudeperf3ct b2452aa
More CI fixes
dudeperf3ct f88a675
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct 3d97c26
Add minimal supported version for Inference Endpoint API in huggingfa…
dudeperf3ct 7e6a7d9
Merge branch 'develop' into huggingface-model-deployer
strickvl 8c96a8f
Relax 'adlfs' package requirement in azure integrations
dudeperf3ct f141fed
update TOC (#2406)
strickvl 1a1bd40
Relax 's3fs' version in s3 integration
dudeperf3ct fe8534a
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct f98ed17
Bugs fixed running a test deployment pipeline
dudeperf3ct e85a0e8
Add deployment pipelines to huggingface integration test
dudeperf3ct 06d52ec
Remove not required check on service running in tests
dudeperf3ct 9a400b4
Merge branch 'develop' into huggingface-model-deployer
strickvl 3acaa80
Address PR comments on documentation and suggested renaming in code
dudeperf3ct 5b96840
Merge remote-tracking branch 'origin/huggingface-model-deployer' into…
dudeperf3ct 5dd45d8
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct 2c9c5a2
Add partial test for huggingface_deployment
dudeperf3ct c3caa59
Fix typo in test function
dudeperf3ct 4dde857
Merge branch 'develop' into huggingface-model-deployer
dudeperf3ct 3eab2e0
Merge branch 'develop' into huggingface-model-deployer
strickvl 3de4783
Merge branch 'develop' into huggingface-model-deployer
strickvl a8f5e1d
Update pyproject.toml
strickvl 9e17cb1
Update pyproject.toml
strickvl 85277a7
Merge branch 'develop' into huggingface-model-deployer
strickvl 68557b3
Relax gcfs
strickvl 6eb5b64
Update model deployers table
dudeperf3ct fa17af1
Merge 'develop' branch into 'huggingface-model-deployer' branch
dudeperf3ct f7daf26
Fix lint issue
dudeperf3ct 76206a9
Merge branch 'develop' into huggingface-model-deployer
strickvl 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Huggingface integration flavors.""" | ||
|
||
from zenml.integrations.huggingface.flavors.huggingface_model_deployer_flavor import ( # noqa | ||
HuggingFaceModelDeployerConfig, | ||
HuggingFaceModelDeployerFlavor, | ||
HuggingFaceBaseConfig, | ||
) | ||
|
||
__all__ = [ | ||
"HuggingFaceModelDeployerConfig", | ||
"HuggingFaceModelDeployerFlavor", | ||
"HuggingFaceBaseConfig", | ||
] |
122 changes: 122 additions & 0 deletions
122
src/zenml/integrations/huggingface/flavors/huggingface_model_deployer_flavor.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
"""Huggingface model deployer flavor.""" | ||
dudeperf3ct marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from typing import TYPE_CHECKING, Dict, Optional, Type | ||
|
||
from pydantic import BaseModel | ||
|
||
from zenml.config.base_settings import BaseSettings | ||
from zenml.integrations.huggingface import HUGGINGFACE_MODEL_DEPLOYER_FLAVOR | ||
from zenml.model_deployers.base_model_deployer import ( | ||
BaseModelDeployerConfig, | ||
BaseModelDeployerFlavor, | ||
) | ||
from zenml.utils.secret_utils import SecretField | ||
|
||
if TYPE_CHECKING: | ||
from zenml.integrations.huggingface.model_deployers.huggingface_model_deployer import ( | ||
HuggingFaceModelDeployer, | ||
) | ||
|
||
|
||
class HuggingFaceBaseConfig(BaseModel): | ||
"""Huggingface Inference Endpoint configuration.""" | ||
|
||
endpoint_name: Optional[str] = "zenml-" | ||
repository: Optional[str] = None | ||
framework: Optional[str] = None | ||
accelerator: Optional[str] = None | ||
instance_size: Optional[str] = None | ||
instance_type: Optional[str] = None | ||
region: Optional[str] = None | ||
vendor: Optional[str] = None | ||
token: Optional[str] = None | ||
account_id: Optional[str] = None | ||
min_replica: Optional[int] = 0 | ||
max_replica: Optional[int] = 1 | ||
revision: Optional[str] = None | ||
task: Optional[str] = None | ||
custom_image: Optional[Dict] = None | ||
namespace: Optional[str] = None | ||
endpoint_type: str = "public" | ||
|
||
|
||
class HuggingFaceModelDeployerSettings(HuggingFaceBaseConfig, BaseSettings): | ||
"""Settings for the Huggingface model deployer.""" | ||
|
||
|
||
class HuggingFaceModelDeployerConfig( | ||
BaseModelDeployerConfig, HuggingFaceModelDeployerSettings | ||
): | ||
"""Configuration for the Huggingface model deployer. | ||
|
||
Attributes: | ||
token: Huggingface token used for authentication | ||
namespace: Huggingface namespace used to list endpoints | ||
""" | ||
|
||
token: str = SecretField() | ||
|
||
# The namespace to list endpoints for. Set to `"*"` to list all endpoints | ||
# from all namespaces (i.e. personal namespace and all orgs the user belongs to). | ||
namespace: str | ||
|
||
|
||
class HuggingFaceModelDeployerFlavor(BaseModelDeployerFlavor): | ||
"""Huggingface Endpoint model deployer flavor.""" | ||
|
||
@property | ||
def name(self) -> str: | ||
"""Name of the flavor. | ||
|
||
Returns: | ||
The name of the flavor. | ||
""" | ||
return HUGGINGFACE_MODEL_DEPLOYER_FLAVOR | ||
|
||
@property | ||
def docs_url(self) -> Optional[str]: | ||
"""A url to point at docs explaining this flavor. | ||
|
||
Returns: | ||
A flavor docs url. | ||
""" | ||
return self.generate_default_docs_url() | ||
|
||
@property | ||
def sdk_docs_url(self) -> Optional[str]: | ||
"""A url to point at SDK docs explaining this flavor. | ||
|
||
Returns: | ||
A flavor SDK docs url. | ||
""" | ||
return self.generate_default_sdk_docs_url() | ||
|
||
@property | ||
def logo_url(self) -> str: | ||
"""A url to represent the flavor in the dashboard. | ||
|
||
Returns: | ||
The flavor logo. | ||
""" | ||
return "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/model_registry/huggingface.png" | ||
|
||
@property | ||
def config_class(self) -> Type[HuggingFaceModelDeployerConfig]: | ||
"""Returns `HuggingFaceModelDeployerConfig` config class. | ||
|
||
Returns: | ||
The config class. | ||
""" | ||
return HuggingFaceModelDeployerConfig | ||
|
||
@property | ||
def implementation_class(self) -> Type["HuggingFaceModelDeployer"]: | ||
"""Implementation class for this flavor. | ||
|
||
Returns: | ||
The implementation class. | ||
""" | ||
from zenml.integrations.huggingface.model_deployers.huggingface_model_deployer import ( | ||
HuggingFaceModelDeployer, | ||
) | ||
|
||
return HuggingFaceModelDeployer |
6 changes: 6 additions & 0 deletions
6
src/zenml/integrations/huggingface/model_deployers/__init__.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""Initialization of the Huggingface model deployers.""" | ||
dudeperf3ct marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from zenml.integrations.huggingface.model_deployers.huggingface_model_deployer import ( # noqa | ||
HuggingFaceModelDeployer, | ||
) | ||
|
||
__all__ = ["HuggingFaceModelDeployer"] |
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.
Uh oh!
There was an error while loading. Please reload this page.