zenml-nightly 0.62.0.dev20240729__py3-none-any.whl → 0.64.0.dev20240809__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- README.md +2 -2
- RELEASE_NOTES.md +120 -0
- zenml/VERSION +1 -1
- zenml/__init__.py +0 -4
- zenml/actions/pipeline_run/pipeline_run_action.py +19 -17
- zenml/analytics/enums.py +4 -6
- zenml/cli/__init__.py +28 -76
- zenml/cli/base.py +2 -2
- zenml/cli/pipeline.py +54 -61
- zenml/cli/stack.py +6 -8
- zenml/cli/web_login.py +8 -0
- zenml/client.py +232 -103
- zenml/config/build_configuration.py +43 -17
- zenml/config/compiler.py +14 -22
- zenml/config/docker_settings.py +80 -57
- zenml/config/pipeline_run_configuration.py +3 -0
- zenml/config/server_config.py +3 -0
- zenml/config/source.py +60 -1
- zenml/constants.py +11 -2
- zenml/entrypoints/base_entrypoint_configuration.py +53 -8
- zenml/enums.py +4 -1
- zenml/environment.py +25 -9
- zenml/image_builders/base_image_builder.py +1 -1
- zenml/image_builders/build_context.py +25 -72
- zenml/integrations/aws/orchestrators/sagemaker_orchestrator.py +13 -4
- zenml/integrations/azure/__init__.py +4 -0
- zenml/integrations/azure/flavors/__init__.py +11 -0
- zenml/integrations/azure/flavors/azureml_orchestrator_flavor.py +263 -0
- zenml/{_hub → integrations/azure/orchestrators}/__init__.py +7 -2
- zenml/integrations/azure/orchestrators/azureml_orchestrator.py +544 -0
- zenml/integrations/azure/orchestrators/azureml_orchestrator_entrypoint_config.py +86 -0
- zenml/integrations/azure/step_operators/azureml_step_operator.py +3 -0
- zenml/integrations/databricks/flavors/databricks_orchestrator_flavor.py +20 -2
- zenml/integrations/databricks/orchestrators/databricks_orchestrator.py +19 -13
- zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +7 -2
- zenml/integrations/gcp/service_connectors/gcp_service_connector.py +123 -6
- zenml/integrations/kaniko/image_builders/kaniko_image_builder.py +1 -1
- zenml/integrations/mlflow/__init__.py +1 -1
- zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py +3 -1
- zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py +3 -0
- zenml/logger.py +13 -0
- zenml/models/__init__.py +26 -22
- zenml/models/v2/base/filter.py +32 -0
- zenml/models/v2/core/pipeline.py +73 -89
- zenml/models/v2/core/pipeline_build.py +15 -11
- zenml/models/v2/core/pipeline_deployment.py +72 -24
- zenml/models/v2/core/pipeline_run.py +65 -1
- zenml/models/v2/core/run_template.py +393 -0
- zenml/models/v2/core/server_settings.py +12 -0
- zenml/models/v2/core/user.py +0 -21
- zenml/models/v2/misc/server_models.py +7 -1
- zenml/models/v2/misc/stack_deployment.py +5 -0
- zenml/models/v2/misc/user_auth.py +0 -7
- zenml/new/pipelines/build_utils.py +220 -89
- zenml/new/pipelines/code_archive.py +157 -0
- zenml/new/pipelines/pipeline.py +46 -78
- zenml/new/pipelines/run_utils.py +79 -1
- zenml/post_execution/pipeline.py +1 -4
- zenml/service_connectors/service_connector_utils.py +18 -2
- zenml/stack_deployments/aws_stack_deployment.py +32 -8
- zenml/stack_deployments/azure_stack_deployment.py +122 -10
- zenml/stack_deployments/gcp_stack_deployment.py +36 -7
- zenml/stack_deployments/stack_deployment.py +23 -7
- zenml/steps/base_step.py +3 -0
- zenml/steps/utils.py +0 -4
- zenml/utils/archivable.py +149 -0
- zenml/utils/code_utils.py +244 -0
- zenml/utils/notebook_utils.py +122 -0
- zenml/utils/package_utils.py +39 -0
- zenml/utils/pipeline_docker_image_builder.py +3 -96
- zenml/utils/source_utils.py +109 -1
- zenml/zen_server/dashboard/assets/{404-B_YdvmwS.js → 404-CRAA_Lew.js} +1 -1
- zenml/zen_server/dashboard/assets/@radix-BXWm7HOa.js +85 -0
- zenml/zen_server/dashboard/assets/{@react-router-CO-OsFwI.js → @react-router-l3lMcXA2.js} +1 -1
- zenml/zen_server/dashboard/assets/{@reactflow-l_1hUr1S.js → @reactflow-CeVxyqYT.js} +2 -2
- zenml/zen_server/dashboard/assets/{@tanstack-DYiOyJUL.js → @tanstack-FmcYZMuX.js} +4 -4
- zenml/zen_server/dashboard/assets/AlertDialogDropdownItem-ErO9aOgK.js +1 -0
- zenml/zen_server/dashboard/assets/{AwarenessChannel-CFg5iX4Z.js → AwarenessChannel-CLXo5rKM.js} +1 -1
- zenml/zen_server/dashboard/assets/{CodeSnippet-Dvkx_82E.js → CodeSnippet-D0VLxT2A.js} +2 -2
- zenml/zen_server/dashboard/assets/CollapsibleCard-BaUPiVg0.js +1 -0
- zenml/zen_server/dashboard/assets/{Commands-DoN1xrEq.js → Commands-JrcZK-3j.js} +1 -1
- zenml/zen_server/dashboard/assets/CopyButton-Dbo52T1K.js +2 -0
- zenml/zen_server/dashboard/assets/{CsvVizualization-Ck-nZ43m.js → CsvVizualization-D3kAypDj.js} +3 -3
- zenml/zen_server/dashboard/assets/DisplayDate-DizbSeT-.js +1 -0
- zenml/zen_server/dashboard/assets/EditSecretDialog-Bd7mFLS4.js +1 -0
- zenml/zen_server/dashboard/assets/{EmptyState-BMLnFVlB.js → EmptyState-BHblM39I.js} +1 -1
- zenml/zen_server/dashboard/assets/{Error-kLtljEOM.js → Error-C6LeJSER.js} +1 -1
- zenml/zen_server/dashboard/assets/{ExecutionStatus-DguLLgTK.js → ExecutionStatus-jH4OrWBq.js} +1 -1
- zenml/zen_server/dashboard/assets/{Helpbox-BXUMP21n.js → Helpbox-aAB2XP-z.js} +1 -1
- zenml/zen_server/dashboard/assets/{Infobox-DSt0O-dm.js → Infobox-BQ0aty32.js} +1 -1
- zenml/zen_server/dashboard/assets/{InlineAvatar-xsrsIGE-.js → InlineAvatar-DpTLgM3Q.js} +1 -1
- zenml/zen_server/dashboard/assets/Lock-CNyJvf2r.js +1 -0
- zenml/zen_server/dashboard/assets/{MarkdownVisualization-xp3hhULl.js → MarkdownVisualization-Bajxn0HY.js} +1 -1
- zenml/zen_server/dashboard/assets/NumberBox-BmKE0qnO.js +1 -0
- zenml/zen_server/dashboard/assets/{PasswordChecker-DUveqlva.js → PasswordChecker-yGGoJSB-.js} +1 -1
- zenml/zen_server/dashboard/assets/ProviderRadio-BBqkIuTd.js +1 -0
- zenml/zen_server/dashboard/assets/RadioItem-xLhXoiFV.js +1 -0
- zenml/zen_server/dashboard/assets/SearchField-C9R0mdaX.js +1 -0
- zenml/zen_server/dashboard/assets/{SetPassword-BXGTWiwj.js → SetPassword-52sNxNiO.js} +1 -1
- zenml/zen_server/dashboard/assets/{SuccessStep-DZC60t0x.js → SuccessStep-DlkItqYG.js} +1 -1
- zenml/zen_server/dashboard/assets/Tick-uxv80Q6a.js +1 -0
- zenml/zen_server/dashboard/assets/{UpdatePasswordSchemas-DGvwFWO1.js → UpdatePasswordSchemas-oN4G3sKz.js} +1 -1
- zenml/zen_server/dashboard/assets/{aws-BgKTfTfx.js → aws-0_3UsPif.js} +1 -1
- zenml/zen_server/dashboard/assets/{check-circle-i56092KI.js → check-circle-1_I207rW.js} +1 -1
- zenml/zen_server/dashboard/assets/chevron-down-BpaF8JqM.js +1 -0
- zenml/zen_server/dashboard/assets/{chevron-right-double-CZBOf6JM.js → chevron-right-double-Dk8e2L99.js} +1 -1
- zenml/zen_server/dashboard/assets/{cloud-only-C_yFCAkP.js → cloud-only-BkUuI0lZ.js} +1 -1
- zenml/zen_server/dashboard/assets/components-Br2ezRib.js +1 -0
- zenml/zen_server/dashboard/assets/{copy-BXNk6BjL.js → copy-f3XGPPxt.js} +1 -1
- zenml/zen_server/dashboard/assets/{database-1xWSgZfO.js → database-cXYNX9tt.js} +1 -1
- zenml/zen_server/dashboard/assets/{docker-CQMVm_4d.js → docker-8uj__HHK.js} +1 -1
- zenml/zen_server/dashboard/assets/dots-horizontal-sKQlWEni.js +1 -0
- zenml/zen_server/dashboard/assets/edit-C0MVvPD2.js +1 -0
- zenml/zen_server/dashboard/assets/{file-text-CqD_iu6l.js → file-text-B9JibxTs.js} +1 -1
- zenml/zen_server/dashboard/assets/{help-bu_DgLKI.js → help-FuHlZwn0.js} +1 -1
- zenml/zen_server/dashboard/assets/{index-rK_Wuy2W.js → index-Bd1xgUQG.js} +1 -1
- zenml/zen_server/dashboard/assets/index-DaGknux4.css +1 -0
- zenml/zen_server/dashboard/assets/{index-BczVOqUf.js → index-DhIZtpxB.js} +5 -5
- zenml/zen_server/dashboard/assets/index.esm-DT4uyn2i.js +1 -0
- zenml/zen_server/dashboard/assets/layout-D6oiSbfd.js +1 -0
- zenml/zen_server/dashboard/assets/{login-mutation-CrHrndTI.js → login-mutation-13A_JSVA.js} +1 -1
- zenml/zen_server/dashboard/assets/{logs-D8k8BVFf.js → logs-CgeE2vZP.js} +1 -1
- zenml/zen_server/dashboard/assets/{not-found-DYa4pC-C.js → not-found-B0Mmb90p.js} +1 -1
- zenml/zen_server/dashboard/assets/package-DdkziX79.js +1 -0
- zenml/zen_server/dashboard/assets/page-7-v2OBm-.js +1 -0
- zenml/zen_server/dashboard/assets/{page-MFQyIJd3.js → page-B3ozwdD1.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-BkuQDIf-.js → page-BGwA9B1M.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-1iL8aMqs.js → page-BkjAUyTA.js} +1 -1
- zenml/zen_server/dashboard/assets/page-BnacgBiy.js +1 -0
- zenml/zen_server/dashboard/assets/page-BxF_KMQ3.js +2 -0
- zenml/zen_server/dashboard/assets/page-C4POHC0K.js +1 -0
- zenml/zen_server/dashboard/assets/page-C9kudd44.js +9 -0
- zenml/zen_server/dashboard/assets/page-CA1j3GpJ.js +1 -0
- zenml/zen_server/dashboard/assets/page-CCY6yfmu.js +1 -0
- zenml/zen_server/dashboard/assets/page-CgTe7Bme.js +1 -0
- zenml/zen_server/dashboard/assets/{page-8a4UMKXZ.js → page-Cgn-6v2Y.js} +1 -1
- zenml/zen_server/dashboard/assets/page-CxQmQqDw.js +1 -0
- zenml/zen_server/dashboard/assets/page-D2Goey3H.js +1 -0
- zenml/zen_server/dashboard/assets/page-DLpOnf7u.js +1 -0
- zenml/zen_server/dashboard/assets/{page-BhgCDInH.js → page-DSTQnBk-.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-1h_sD1jz.js → page-DTysUGOy.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-2grKx_MY.js → page-D_EXUFJb.js} +1 -1
- zenml/zen_server/dashboard/assets/page-Db15QzsM.js +1 -0
- zenml/zen_server/dashboard/assets/{page-BDns21Iz.js → page-DugsjcQ_.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-C6-UGEbH.js → page-OFKSPyN7.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-BkeAAYwp.js → page-RnG-qhv9.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-CCNRIt_f.js → page-T2BtjwPl.js} +1 -1
- zenml/zen_server/dashboard/assets/page-TXe1Eo3Z.js +1 -0
- zenml/zen_server/dashboard/assets/{page-BnaevhnB.js → page-YiF_fNbe.js} +1 -1
- zenml/zen_server/dashboard/assets/{page-uA5prJGY.js → page-hQaiQXfg.js} +1 -1
- zenml/zen_server/dashboard/assets/persist-3-5nOJ6m.js +1 -0
- zenml/zen_server/dashboard/assets/{play-circle-CNtZKDnW.js → play-circle-XSkLR12B.js} +1 -1
- zenml/zen_server/dashboard/assets/plus-FB9-lEq_.js +1 -0
- zenml/zen_server/dashboard/assets/refresh-COb6KYDi.js +1 -0
- zenml/zen_server/dashboard/assets/sharedSchema-BoYx_B_L.js +14 -0
- zenml/zen_server/dashboard/assets/{stack-detail-query-Cficsl6d.js → stack-detail-query-B-US_-wa.js} +1 -1
- zenml/zen_server/dashboard/assets/{terminal-By9cErXc.js → terminal-grtjrIEJ.js} +1 -1
- zenml/zen_server/dashboard/assets/trash-Cd5CSFqA.js +1 -0
- zenml/zen_server/dashboard/assets/{update-server-settings-mutation-7d8xi1tS.js → update-server-settings-mutation-B8GB_ubU.js} +1 -1
- zenml/zen_server/dashboard/assets/{url-D7mAQGUM.js → url-hcMJkz8p.js} +1 -1
- zenml/zen_server/dashboard/assets/{zod-BhoGpZ63.js → zod-CnykDKJj.js} +1 -1
- zenml/zen_server/dashboard/index.html +7 -7
- zenml/zen_server/dashboard_legacy/asset-manifest.json +4 -4
- zenml/zen_server/dashboard_legacy/index.html +1 -1
- zenml/zen_server/dashboard_legacy/{precache-manifest.12246c7548e71e2c4438e496360de80c.js → precache-manifest.9c473c96a43298343a7ce1256183123b.js} +4 -4
- zenml/zen_server/dashboard_legacy/service-worker.js +1 -1
- zenml/zen_server/dashboard_legacy/static/js/{main.3b27024b.chunk.js → main.463c90b9.chunk.js} +2 -2
- zenml/zen_server/dashboard_legacy/static/js/{main.3b27024b.chunk.js.map → main.463c90b9.chunk.js.map} +1 -1
- zenml/zen_server/deploy/helm/Chart.yaml +1 -1
- zenml/zen_server/deploy/helm/README.md +2 -2
- zenml/zen_server/rbac/models.py +1 -0
- zenml/zen_server/rbac/utils.py +4 -0
- zenml/zen_server/routers/pipeline_builds_endpoints.py +2 -66
- zenml/zen_server/routers/pipeline_deployments_endpoints.py +2 -53
- zenml/zen_server/routers/pipelines_endpoints.py +1 -74
- zenml/zen_server/routers/run_templates_endpoints.py +212 -0
- zenml/zen_server/routers/stack_deployment_endpoints.py +6 -0
- zenml/zen_server/routers/users_endpoints.py +0 -7
- zenml/zen_server/routers/workspaces_endpoints.py +79 -0
- zenml/zen_server/{pipeline_deployment → template_execution}/runner_entrypoint_configuration.py +1 -8
- zenml/zen_server/{pipeline_deployment → template_execution}/utils.py +214 -92
- zenml/zen_server/utils.py +77 -2
- zenml/zen_server/zen_server_api.py +54 -2
- zenml/zen_stores/base_zen_store.py +7 -1
- zenml/zen_stores/migrations/versions/0.63.0_release.py +23 -0
- zenml/zen_stores/migrations/versions/0.64.0_release.py +23 -0
- zenml/zen_stores/migrations/versions/026d4577b6a0_add_code_path.py +39 -0
- zenml/zen_stores/migrations/versions/3dcc5d20e82f_add_last_user_activity.py +51 -0
- zenml/zen_stores/migrations/versions/7d1919bb1ef0_add_run_templates.py +100 -0
- zenml/zen_stores/migrations/versions/909550c7c4da_remove_user_hub_token.py +36 -0
- zenml/zen_stores/migrations/versions/b59aa68fdb1f_simplify_pipelines.py +139 -0
- zenml/zen_stores/rest_zen_store.py +112 -39
- zenml/zen_stores/schemas/__init__.py +2 -0
- zenml/zen_stores/schemas/pipeline_build_schemas.py +3 -3
- zenml/zen_stores/schemas/pipeline_deployment_schemas.py +32 -2
- zenml/zen_stores/schemas/pipeline_run_schemas.py +29 -3
- zenml/zen_stores/schemas/pipeline_schemas.py +29 -30
- zenml/zen_stores/schemas/run_template_schemas.py +264 -0
- zenml/zen_stores/schemas/server_settings_schemas.py +2 -0
- zenml/zen_stores/schemas/step_run_schemas.py +11 -4
- zenml/zen_stores/schemas/user_schemas.py +0 -2
- zenml/zen_stores/sql_zen_store.py +389 -151
- zenml/zen_stores/template_utils.py +261 -0
- zenml/zen_stores/zen_store_interface.py +93 -20
- {zenml_nightly-0.62.0.dev20240729.dist-info → zenml_nightly-0.64.0.dev20240809.dist-info}/METADATA +3 -3
- {zenml_nightly-0.62.0.dev20240729.dist-info → zenml_nightly-0.64.0.dev20240809.dist-info}/RECORD +211 -184
- zenml/_hub/client.py +0 -289
- zenml/_hub/constants.py +0 -21
- zenml/_hub/utils.py +0 -79
- zenml/cli/hub.py +0 -1116
- zenml/models/v2/core/pipeline_namespace.py +0 -113
- zenml/models/v2/misc/hub_plugin_models.py +0 -79
- zenml/new/pipelines/deserialization_utils.py +0 -292
- zenml/zen_server/dashboard/assets/@radix-CFOkMR_E.js +0 -85
- zenml/zen_server/dashboard/assets/CollapsibleCard-opiuBHHc.js +0 -1
- zenml/zen_server/dashboard/assets/CopyButton-Cr7xYEPb.js +0 -2
- zenml/zen_server/dashboard/assets/DisplayDate-DYgIjlDF.js +0 -1
- zenml/zen_server/dashboard/assets/Pagination-C6X-mifw.js +0 -1
- zenml/zen_server/dashboard/assets/index-EpMIKgrI.css +0 -1
- zenml/zen_server/dashboard/assets/index.esm-Corw4lXQ.js +0 -1
- zenml/zen_server/dashboard/assets/package-B3fWP-Dh.js +0 -1
- zenml/zen_server/dashboard/assets/page-5NCOHOsy.js +0 -1
- zenml/zen_server/dashboard/assets/page-B6h3iaHJ.js +0 -1
- zenml/zen_server/dashboard/assets/page-Bi-wtWiO.js +0 -5
- zenml/zen_server/dashboard/assets/page-Bq0YxkLV.js +0 -1
- zenml/zen_server/dashboard/assets/page-Bs2F4eoD.js +0 -2
- zenml/zen_server/dashboard/assets/page-CHNxpz3n.js +0 -1
- zenml/zen_server/dashboard/assets/page-DgorQFqi.js +0 -1
- zenml/zen_server/dashboard/assets/page-K8ebxVIs.js +0 -1
- zenml/zen_server/dashboard/assets/page-TgCF0P_U.js +0 -1
- zenml/zen_server/dashboard/assets/page-ZnCEe-eK.js +0 -9
- zenml/zen_server/dashboard/assets/persist-D7HJNBWx.js +0 -1
- zenml/zen_server/dashboard/assets/plus-C8WOyCzt.js +0 -1
- zenml/zen_server/dashboard/assets/secrets-video-OBJ6irhH.svg +0 -21
- zenml/zen_server/dashboard/assets/stacks-video-7gfxpAq4.svg +0 -21
- /zenml/zen_server/{pipeline_deployment → template_execution}/__init__.py +0 -0
- /zenml/zen_server/{pipeline_deployment → template_execution}/workload_manager_interface.py +0 -0
- {zenml_nightly-0.62.0.dev20240729.dist-info → zenml_nightly-0.64.0.dev20240809.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.62.0.dev20240729.dist-info → zenml_nightly-0.64.0.dev20240809.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.62.0.dev20240729.dist-info → zenml_nightly-0.64.0.dev20240809.dist-info}/entry_points.txt +0 -0
zenml/_hub/client.py
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
# Copyright (c) ZenML GmbH 2023. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at:
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
12
|
-
# or implied. See the License for the specific language governing
|
13
|
-
# permissions and limitations under the License.
|
14
|
-
"""Client for the ZenML Hub."""
|
15
|
-
|
16
|
-
import os
|
17
|
-
from json import JSONDecodeError
|
18
|
-
from typing import Any, Dict, List, Optional
|
19
|
-
|
20
|
-
import requests
|
21
|
-
|
22
|
-
from zenml._hub.constants import (
|
23
|
-
ZENML_HUB_ADMIN_USERNAME,
|
24
|
-
ZENML_HUB_CLIENT_TIMEOUT,
|
25
|
-
ZENML_HUB_CLIENT_VERIFY,
|
26
|
-
ZENML_HUB_DEFAULT_URL,
|
27
|
-
)
|
28
|
-
from zenml.analytics import source_context
|
29
|
-
from zenml.client import Client
|
30
|
-
from zenml.constants import ENV_ZENML_HUB_URL, IS_DEBUG_ENV
|
31
|
-
from zenml.logger import get_logger
|
32
|
-
from zenml.models import (
|
33
|
-
HubPluginRequestModel,
|
34
|
-
HubPluginResponseModel,
|
35
|
-
HubUserResponseModel,
|
36
|
-
)
|
37
|
-
|
38
|
-
logger = get_logger(__name__)
|
39
|
-
|
40
|
-
|
41
|
-
class HubAPIError(Exception):
|
42
|
-
"""Exception raised when the Hub returns an error or unexpected response."""
|
43
|
-
|
44
|
-
|
45
|
-
class HubClient:
|
46
|
-
"""Client for the ZenML Hub."""
|
47
|
-
|
48
|
-
def __init__(self, url: Optional[str] = None) -> None:
|
49
|
-
"""Initialize the client.
|
50
|
-
|
51
|
-
Args:
|
52
|
-
url: The URL of the ZenML Hub.
|
53
|
-
"""
|
54
|
-
self.url = url or self.get_default_url()
|
55
|
-
self.auth_token = Client().active_user.hub_token
|
56
|
-
|
57
|
-
@staticmethod
|
58
|
-
def get_default_url() -> str:
|
59
|
-
"""Get the default URL of the ZenML Hub.
|
60
|
-
|
61
|
-
Returns:
|
62
|
-
The default URL of the ZenML Hub.
|
63
|
-
"""
|
64
|
-
return os.getenv(ENV_ZENML_HUB_URL, default=ZENML_HUB_DEFAULT_URL)
|
65
|
-
|
66
|
-
def list_plugins(self, **params: Any) -> List[HubPluginResponseModel]:
|
67
|
-
"""List all plugins in the hub.
|
68
|
-
|
69
|
-
Args:
|
70
|
-
**params: The query parameters to send in the request.
|
71
|
-
|
72
|
-
Returns:
|
73
|
-
The list of plugin response models.
|
74
|
-
"""
|
75
|
-
response = self._request("GET", "/plugins", params=params)
|
76
|
-
if not isinstance(response, list):
|
77
|
-
return []
|
78
|
-
return [
|
79
|
-
HubPluginResponseModel.model_validate(plugin)
|
80
|
-
for plugin in response
|
81
|
-
]
|
82
|
-
|
83
|
-
def get_plugin(
|
84
|
-
self,
|
85
|
-
name: str,
|
86
|
-
version: Optional[str] = None,
|
87
|
-
author: Optional[str] = None,
|
88
|
-
) -> Optional[HubPluginResponseModel]:
|
89
|
-
"""Get a specific plugin from the hub.
|
90
|
-
|
91
|
-
Args:
|
92
|
-
name: The name of the plugin.
|
93
|
-
version: The version of the plugin. If not specified, the latest
|
94
|
-
version will be returned.
|
95
|
-
author: Username of the author of the plugin.
|
96
|
-
|
97
|
-
Returns:
|
98
|
-
The plugin response model or None if the plugin does not exist.
|
99
|
-
"""
|
100
|
-
route = "/plugins"
|
101
|
-
if not author:
|
102
|
-
author = ZENML_HUB_ADMIN_USERNAME
|
103
|
-
options = [
|
104
|
-
f"name={name}",
|
105
|
-
f"username={author}",
|
106
|
-
]
|
107
|
-
if version:
|
108
|
-
options.append(f"version={version}")
|
109
|
-
if options:
|
110
|
-
route += "?" + "&".join(options)
|
111
|
-
try:
|
112
|
-
response = self._request("GET", route)
|
113
|
-
except HubAPIError:
|
114
|
-
return None
|
115
|
-
if not isinstance(response, list) or len(response) == 0:
|
116
|
-
return None
|
117
|
-
return HubPluginResponseModel.model_validate(response[0])
|
118
|
-
|
119
|
-
def create_plugin(
|
120
|
-
self, plugin_request: HubPluginRequestModel
|
121
|
-
) -> HubPluginResponseModel:
|
122
|
-
"""Create a plugin in the hub.
|
123
|
-
|
124
|
-
Args:
|
125
|
-
plugin_request: The plugin request model.
|
126
|
-
|
127
|
-
Returns:
|
128
|
-
The plugin response model.
|
129
|
-
"""
|
130
|
-
route = "/plugins"
|
131
|
-
response = self._request(
|
132
|
-
"POST", route, data=plugin_request.model_dump_json()
|
133
|
-
)
|
134
|
-
return HubPluginResponseModel.model_validate(response)
|
135
|
-
|
136
|
-
# TODO: Potentially reenable this later if hub adds logs streaming endpoint
|
137
|
-
# def stream_plugin_build_logs(
|
138
|
-
# self, plugin_name: str, plugin_version: str
|
139
|
-
# ) -> bool:
|
140
|
-
# """Stream the build logs of a plugin.
|
141
|
-
|
142
|
-
# Args:
|
143
|
-
# plugin_name: The name of the plugin.
|
144
|
-
# plugin_version: The version of the plugin. If not specified, the
|
145
|
-
# latest version will be used.
|
146
|
-
|
147
|
-
# Returns:
|
148
|
-
# Whether any logs were found.
|
149
|
-
|
150
|
-
# Raises:
|
151
|
-
# HubAPIError: If the build failed.
|
152
|
-
# """
|
153
|
-
# route = f"plugins/{plugin_name}/versions/{plugin_version}/logs"
|
154
|
-
# logs_url = os.path.join(self.url, route)
|
155
|
-
|
156
|
-
# found_logs = False
|
157
|
-
# with requests.get(logs_url, stream=True) as response:
|
158
|
-
# for line in response.iter_lines(
|
159
|
-
# chunk_size=None, decode_unicode=True
|
160
|
-
# ):
|
161
|
-
# found_logs = True
|
162
|
-
# if line.startswith("Build failed"):
|
163
|
-
# raise HubAPIError(line)
|
164
|
-
# else:
|
165
|
-
# logger.info(line)
|
166
|
-
# return found_logs
|
167
|
-
|
168
|
-
def login(self, username: str, password: str) -> None:
|
169
|
-
"""Login to the ZenML Hub.
|
170
|
-
|
171
|
-
Args:
|
172
|
-
username: The username of the user in the ZenML Hub.
|
173
|
-
password: The password of the user in the ZenML Hub.
|
174
|
-
|
175
|
-
Raises:
|
176
|
-
HubAPIError: If the login failed.
|
177
|
-
"""
|
178
|
-
route = "/auth/jwt/login"
|
179
|
-
response = self._request(
|
180
|
-
method="POST",
|
181
|
-
route=route,
|
182
|
-
data={"username": username, "password": password},
|
183
|
-
content_type="application/x-www-form-urlencoded",
|
184
|
-
)
|
185
|
-
if isinstance(response, dict):
|
186
|
-
auth_token = response.get("access_token")
|
187
|
-
if auth_token:
|
188
|
-
self.set_auth_token(str(auth_token))
|
189
|
-
return
|
190
|
-
raise HubAPIError(f"Unexpected response: {response}")
|
191
|
-
|
192
|
-
def set_auth_token(self, auth_token: Optional[str]) -> None:
|
193
|
-
"""Set the auth token.
|
194
|
-
|
195
|
-
Args:
|
196
|
-
auth_token: The auth token to set.
|
197
|
-
"""
|
198
|
-
client = Client()
|
199
|
-
client.update_user(
|
200
|
-
name_id_or_prefix=client.active_user.id,
|
201
|
-
updated_hub_token=auth_token,
|
202
|
-
)
|
203
|
-
self.auth_token = auth_token
|
204
|
-
|
205
|
-
def get_github_login_url(self) -> str:
|
206
|
-
"""Get the GitHub login URL.
|
207
|
-
|
208
|
-
Returns:
|
209
|
-
The GitHub login URL.
|
210
|
-
|
211
|
-
Raises:
|
212
|
-
HubAPIError: If the request failed.
|
213
|
-
"""
|
214
|
-
route = "/auth/github/authorize"
|
215
|
-
response = self._request("GET", route)
|
216
|
-
if isinstance(response, dict):
|
217
|
-
auth_url = response.get("authorization_url")
|
218
|
-
if auth_url:
|
219
|
-
return str(auth_url)
|
220
|
-
raise HubAPIError(f"Unexpected response: {str(response)}")
|
221
|
-
|
222
|
-
def get_me(self) -> Optional[HubUserResponseModel]:
|
223
|
-
"""Get the current user.
|
224
|
-
|
225
|
-
Returns:
|
226
|
-
The user response model or None if the user does not exist.
|
227
|
-
"""
|
228
|
-
try:
|
229
|
-
response = self._request("GET", "/users/me")
|
230
|
-
return HubUserResponseModel.model_validate(response)
|
231
|
-
except HubAPIError:
|
232
|
-
return None
|
233
|
-
|
234
|
-
def _request(
|
235
|
-
self,
|
236
|
-
method: str,
|
237
|
-
route: str,
|
238
|
-
data: Optional[Any] = None,
|
239
|
-
params: Optional[Dict[str, Any]] = None,
|
240
|
-
content_type: str = "application/json",
|
241
|
-
) -> Any:
|
242
|
-
"""Helper function to make a request to the hub.
|
243
|
-
|
244
|
-
Args:
|
245
|
-
method: The HTTP method to use.
|
246
|
-
route: The route to send the request to, e.g., "/plugins".
|
247
|
-
data: The data to send in the request.
|
248
|
-
params: The query parameters to send in the request.
|
249
|
-
content_type: The content type of the request.
|
250
|
-
|
251
|
-
Returns:
|
252
|
-
The response JSON.
|
253
|
-
|
254
|
-
Raises:
|
255
|
-
HubAPIError: If the request failed.
|
256
|
-
"""
|
257
|
-
session = requests.Session()
|
258
|
-
|
259
|
-
# Define headers
|
260
|
-
headers = {
|
261
|
-
"Accept": "application/json",
|
262
|
-
"Content-Type": content_type,
|
263
|
-
"Debug-Context": str(IS_DEBUG_ENV),
|
264
|
-
"Source-Context": str(source_context.get().value),
|
265
|
-
}
|
266
|
-
if self.auth_token:
|
267
|
-
headers["Authorization"] = f"Bearer {self.auth_token}"
|
268
|
-
|
269
|
-
# Make the request
|
270
|
-
route = route.lstrip("/")
|
271
|
-
endpoint_url = os.path.join(self.url, route)
|
272
|
-
response = session.request(
|
273
|
-
method=method,
|
274
|
-
url=endpoint_url,
|
275
|
-
data=data,
|
276
|
-
headers=headers,
|
277
|
-
params=params,
|
278
|
-
verify=ZENML_HUB_CLIENT_VERIFY,
|
279
|
-
timeout=ZENML_HUB_CLIENT_TIMEOUT,
|
280
|
-
)
|
281
|
-
|
282
|
-
# Parse and return the response
|
283
|
-
if 200 <= response.status_code < 300:
|
284
|
-
return response.json()
|
285
|
-
try:
|
286
|
-
error_msg = response.json().get("detail", response.text)
|
287
|
-
except JSONDecodeError:
|
288
|
-
error_msg = response.text
|
289
|
-
raise HubAPIError(f"Request to ZenML Hub failed: {error_msg}")
|
zenml/_hub/constants.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# Copyright (c) ZenML GmbH 2023. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at:
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
12
|
-
# or implied. See the License for the specific language governing
|
13
|
-
# permissions and limitations under the License.
|
14
|
-
"""Constants for the ZenML hub."""
|
15
|
-
|
16
|
-
ZENML_HUB_DEFAULT_URL = "https://hubapi.zenml.io/"
|
17
|
-
ZENML_HUB_ADMIN_USERNAME = "ZenML"
|
18
|
-
ZENML_HUB_CLIENT_VERIFY = True
|
19
|
-
ZENML_HUB_CLIENT_TIMEOUT = 10
|
20
|
-
ZENML_HUB_INTERNAL_TAG_PREFIX = "zenml-"
|
21
|
-
ZENML_HUB_VERIFIED_TAG = "zenml-badge-verified"
|
zenml/_hub/utils.py
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# Copyright (c) ZenML GmbH 2023. All Rights Reserved.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at:
|
6
|
-
#
|
7
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
12
|
-
# or implied. See the License for the specific language governing
|
13
|
-
# permissions and limitations under the License.
|
14
|
-
"""Utility functions for the ZenML Hub."""
|
15
|
-
|
16
|
-
from typing import Optional, Tuple
|
17
|
-
|
18
|
-
from zenml._hub.constants import ZENML_HUB_ADMIN_USERNAME
|
19
|
-
|
20
|
-
|
21
|
-
def parse_plugin_name(
|
22
|
-
plugin_name: str, author_separator: str = "/", version_separator: str = ":"
|
23
|
-
) -> Tuple[Optional[str], str, str]:
|
24
|
-
"""Helper function to parse a plugin name.
|
25
|
-
|
26
|
-
Args:
|
27
|
-
plugin_name: The user-provided plugin name.
|
28
|
-
author_separator: The separator between the author username and the
|
29
|
-
plugin name.
|
30
|
-
version_separator: The separator between the plugin name and the
|
31
|
-
plugin version.
|
32
|
-
|
33
|
-
Returns:
|
34
|
-
- The author username or None if no author was specified.
|
35
|
-
- The plugin name.
|
36
|
-
- The plugin version or "latest" if no version was specified.
|
37
|
-
|
38
|
-
Raises:
|
39
|
-
ValueError: If the plugin name is invalid.
|
40
|
-
"""
|
41
|
-
invalid_format_err_msg = (
|
42
|
-
f"Invalid plugin name '{plugin_name}'. Expected format: "
|
43
|
-
f"`(<author_username>{author_separator})<plugin_name>({version_separator}<version>)`."
|
44
|
-
)
|
45
|
-
|
46
|
-
parts = plugin_name.split(version_separator)
|
47
|
-
if len(parts) > 2:
|
48
|
-
raise ValueError(invalid_format_err_msg)
|
49
|
-
name, version = parts[0], "latest" if len(parts) == 1 else parts[1]
|
50
|
-
|
51
|
-
parts = name.split(author_separator)
|
52
|
-
if len(parts) > 2:
|
53
|
-
raise ValueError(invalid_format_err_msg)
|
54
|
-
name, author = parts[-1], None if len(parts) == 1 else parts[0]
|
55
|
-
|
56
|
-
if not name:
|
57
|
-
raise ValueError(invalid_format_err_msg)
|
58
|
-
|
59
|
-
return author, name, version
|
60
|
-
|
61
|
-
|
62
|
-
def plugin_display_name(
|
63
|
-
name: str, version: Optional[str], author: Optional[str]
|
64
|
-
) -> str:
|
65
|
-
"""Helper function to get the display name of a plugin.
|
66
|
-
|
67
|
-
Args:
|
68
|
-
name: Name of the plugin.
|
69
|
-
version: Version of the plugin.
|
70
|
-
author: Username of the plugin author.
|
71
|
-
|
72
|
-
Returns:
|
73
|
-
Display name of the plugin.
|
74
|
-
"""
|
75
|
-
author_prefix = ""
|
76
|
-
if author and author != ZENML_HUB_ADMIN_USERNAME:
|
77
|
-
author_prefix = f"{author}/"
|
78
|
-
version_suffix = f":{version}" if version else ":latest"
|
79
|
-
return f"{author_prefix}{name}{version_suffix}"
|