zenml-nightly 0.63.0.dev20240801__py3-none-any.whl → 0.64.0.dev20240811__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.
Files changed (198) hide show
  1. README.md +2 -2
  2. RELEASE_NOTES.md +79 -0
  3. zenml/VERSION +1 -1
  4. zenml/__init__.py +0 -4
  5. zenml/analytics/enums.py +0 -6
  6. zenml/cli/__init__.py +0 -61
  7. zenml/cli/base.py +1 -1
  8. zenml/cli/web_login.py +8 -0
  9. zenml/client.py +0 -4
  10. zenml/config/build_configuration.py +43 -17
  11. zenml/config/docker_settings.py +80 -57
  12. zenml/config/source.py +58 -0
  13. zenml/constants.py +9 -2
  14. zenml/entrypoints/base_entrypoint_configuration.py +53 -8
  15. zenml/enums.py +1 -1
  16. zenml/environment.py +25 -9
  17. zenml/image_builders/base_image_builder.py +1 -1
  18. zenml/image_builders/build_context.py +25 -72
  19. zenml/integrations/azure/__init__.py +4 -0
  20. zenml/integrations/azure/flavors/__init__.py +11 -0
  21. zenml/integrations/azure/flavors/azureml_orchestrator_flavor.py +263 -0
  22. zenml/{_hub → integrations/azure/orchestrators}/__init__.py +7 -2
  23. zenml/integrations/azure/orchestrators/azureml_orchestrator.py +544 -0
  24. zenml/integrations/azure/orchestrators/azureml_orchestrator_entrypoint_config.py +86 -0
  25. zenml/integrations/azure/step_operators/azureml_step_operator.py +3 -0
  26. zenml/integrations/databricks/flavors/databricks_orchestrator_flavor.py +9 -0
  27. zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +7 -2
  28. zenml/integrations/gcp/service_connectors/gcp_service_connector.py +123 -6
  29. zenml/integrations/kaniko/image_builders/kaniko_image_builder.py +1 -1
  30. zenml/integrations/mlflow/__init__.py +1 -1
  31. zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py +3 -1
  32. zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py +3 -0
  33. zenml/logger.py +13 -0
  34. zenml/models/__init__.py +0 -12
  35. zenml/models/v2/core/pipeline_deployment.py +21 -29
  36. zenml/models/v2/core/pipeline_run.py +13 -0
  37. zenml/models/v2/core/server_settings.py +12 -0
  38. zenml/models/v2/core/user.py +0 -21
  39. zenml/models/v2/misc/server_models.py +7 -1
  40. zenml/models/v2/misc/user_auth.py +0 -7
  41. zenml/new/pipelines/build_utils.py +193 -38
  42. zenml/new/pipelines/code_archive.py +157 -0
  43. zenml/new/pipelines/pipeline.py +29 -2
  44. zenml/new/pipelines/run_utils.py +67 -1
  45. zenml/service_connectors/service_connector_utils.py +14 -0
  46. zenml/stack_deployments/aws_stack_deployment.py +26 -3
  47. zenml/stack_deployments/azure_stack_deployment.py +11 -6
  48. zenml/stack_deployments/gcp_stack_deployment.py +24 -2
  49. zenml/stack_deployments/stack_deployment.py +17 -2
  50. zenml/steps/base_step.py +3 -0
  51. zenml/utils/archivable.py +149 -0
  52. zenml/utils/code_utils.py +244 -0
  53. zenml/utils/notebook_utils.py +122 -0
  54. zenml/utils/pipeline_docker_image_builder.py +3 -96
  55. zenml/utils/source_utils.py +109 -1
  56. zenml/zen_server/dashboard/assets/{404-CI13wQp4.js → 404-CRAA_Lew.js} +1 -1
  57. zenml/zen_server/dashboard/assets/@radix-BXWm7HOa.js +85 -0
  58. zenml/zen_server/dashboard/assets/{@react-router-CO-OsFwI.js → @react-router-l3lMcXA2.js} +1 -1
  59. zenml/zen_server/dashboard/assets/{@reactflow-DIYUhKYX.js → @reactflow-CeVxyqYT.js} +2 -2
  60. zenml/zen_server/dashboard/assets/{@tanstack-k96lU_C-.js → @tanstack-FmcYZMuX.js} +4 -4
  61. zenml/zen_server/dashboard/assets/AlertDialogDropdownItem-ErO9aOgK.js +1 -0
  62. zenml/zen_server/dashboard/assets/{AwarenessChannel-BNg5uWgI.js → AwarenessChannel-CLXo5rKM.js} +1 -1
  63. zenml/zen_server/dashboard/assets/{CodeSnippet-Cyp7f4dM.js → CodeSnippet-D0VLxT2A.js} +1 -1
  64. zenml/zen_server/dashboard/assets/{CollapsibleCard-Cu_A9W57.js → CollapsibleCard-BaUPiVg0.js} +1 -1
  65. zenml/zen_server/dashboard/assets/{Commands-DmQwTXjj.js → Commands-JrcZK-3j.js} +1 -1
  66. zenml/zen_server/dashboard/assets/CopyButton-Dbo52T1K.js +2 -0
  67. zenml/zen_server/dashboard/assets/{CsvVizualization-BvqItd-O.js → CsvVizualization-D3kAypDj.js} +3 -3
  68. zenml/zen_server/dashboard/assets/DisplayDate-DizbSeT-.js +1 -0
  69. zenml/zen_server/dashboard/assets/EditSecretDialog-Bd7mFLS4.js +1 -0
  70. zenml/zen_server/dashboard/assets/{EmptyState-BMLnFVlB.js → EmptyState-BHblM39I.js} +1 -1
  71. zenml/zen_server/dashboard/assets/{Error-DbXCTGua.js → Error-C6LeJSER.js} +1 -1
  72. zenml/zen_server/dashboard/assets/{ExecutionStatus-9zM7eaLh.js → ExecutionStatus-jH4OrWBq.js} +1 -1
  73. zenml/zen_server/dashboard/assets/{Helpbox-BIiNc-uH.js → Helpbox-aAB2XP-z.js} +1 -1
  74. zenml/zen_server/dashboard/assets/{Infobox-iv1Nu1A0.js → Infobox-BQ0aty32.js} +1 -1
  75. zenml/zen_server/dashboard/assets/{InlineAvatar-BvBtO2Dp.js → InlineAvatar-DpTLgM3Q.js} +1 -1
  76. zenml/zen_server/dashboard/assets/Lock-CNyJvf2r.js +1 -0
  77. zenml/zen_server/dashboard/assets/{MarkdownVisualization-xp3hhULl.js → MarkdownVisualization-Bajxn0HY.js} +1 -1
  78. zenml/zen_server/dashboard/assets/NumberBox-BmKE0qnO.js +1 -0
  79. zenml/zen_server/dashboard/assets/{PasswordChecker-DUveqlva.js → PasswordChecker-yGGoJSB-.js} +1 -1
  80. zenml/zen_server/dashboard/assets/{ProviderRadio-pSAvrGRS.js → ProviderRadio-BBqkIuTd.js} +1 -1
  81. zenml/zen_server/dashboard/assets/RadioItem-xLhXoiFV.js +1 -0
  82. zenml/zen_server/dashboard/assets/SearchField-C9R0mdaX.js +1 -0
  83. zenml/zen_server/dashboard/assets/{SetPassword-BOxpgh6N.js → SetPassword-52sNxNiO.js} +1 -1
  84. zenml/zen_server/dashboard/assets/{SuccessStep-CTSKN2lp.js → SuccessStep-DlkItqYG.js} +1 -1
  85. zenml/zen_server/dashboard/assets/{Tick-Bnr2TpW6.js → Tick-uxv80Q6a.js} +1 -1
  86. zenml/zen_server/dashboard/assets/{UpdatePasswordSchemas-BeCeaRW5.js → UpdatePasswordSchemas-oN4G3sKz.js} +1 -1
  87. zenml/zen_server/dashboard/assets/{aws-BgKTfTfx.js → aws-0_3UsPif.js} +1 -1
  88. zenml/zen_server/dashboard/assets/{check-circle-i56092KI.js → check-circle-1_I207rW.js} +1 -1
  89. zenml/zen_server/dashboard/assets/{chevron-down-D_ZlKMqH.js → chevron-down-BpaF8JqM.js} +1 -1
  90. zenml/zen_server/dashboard/assets/{chevron-right-double-CZBOf6JM.js → chevron-right-double-Dk8e2L99.js} +1 -1
  91. zenml/zen_server/dashboard/assets/{cloud-only-qelmY92E.js → cloud-only-BkUuI0lZ.js} +1 -1
  92. zenml/zen_server/dashboard/assets/components-Br2ezRib.js +1 -0
  93. zenml/zen_server/dashboard/assets/{copy-BXNk6BjL.js → copy-f3XGPPxt.js} +1 -1
  94. zenml/zen_server/dashboard/assets/{database-1xWSgZfO.js → database-cXYNX9tt.js} +1 -1
  95. zenml/zen_server/dashboard/assets/{docker-CQMVm_4d.js → docker-8uj__HHK.js} +1 -1
  96. zenml/zen_server/dashboard/assets/{dots-horizontal-BObFzD5l.js → dots-horizontal-sKQlWEni.js} +1 -1
  97. zenml/zen_server/dashboard/assets/edit-C0MVvPD2.js +1 -0
  98. zenml/zen_server/dashboard/assets/{file-text-CqD_iu6l.js → file-text-B9JibxTs.js} +1 -1
  99. zenml/zen_server/dashboard/assets/{help-bu_DgLKI.js → help-FuHlZwn0.js} +1 -1
  100. zenml/zen_server/dashboard/assets/index-Bd1xgUQG.js +1 -0
  101. zenml/zen_server/dashboard/assets/index-DaGknux4.css +1 -0
  102. zenml/zen_server/dashboard/assets/{index-KsTz2dHG.js → index-DhIZtpxB.js} +5 -5
  103. zenml/zen_server/dashboard/assets/{index.esm-CbHNSeVw.js → index.esm-DT4uyn2i.js} +1 -1
  104. zenml/zen_server/dashboard/assets/layout-D6oiSbfd.js +1 -0
  105. zenml/zen_server/dashboard/assets/{login-mutation-DRpbESS7.js → login-mutation-13A_JSVA.js} +1 -1
  106. zenml/zen_server/dashboard/assets/{logs-D8k8BVFf.js → logs-CgeE2vZP.js} +1 -1
  107. zenml/zen_server/dashboard/assets/{not-found-Dfx9hfkf.js → not-found-B0Mmb90p.js} +1 -1
  108. zenml/zen_server/dashboard/assets/{package-ClbU3KUi.js → package-DdkziX79.js} +1 -1
  109. zenml/zen_server/dashboard/assets/page-7-v2OBm-.js +1 -0
  110. zenml/zen_server/dashboard/assets/{page-f3jBVI5Z.js → page-B3ozwdD1.js} +1 -1
  111. zenml/zen_server/dashboard/assets/{page-DYBNGxJt.js → page-BGwA9B1M.js} +1 -1
  112. zenml/zen_server/dashboard/assets/{page-C176KxyB.js → page-BkjAUyTA.js} +1 -1
  113. zenml/zen_server/dashboard/assets/page-BnacgBiy.js +1 -0
  114. zenml/zen_server/dashboard/assets/{page-CzucfYPo.js → page-BxF_KMQ3.js} +2 -2
  115. zenml/zen_server/dashboard/assets/page-C4POHC0K.js +1 -0
  116. zenml/zen_server/dashboard/assets/page-C9kudd44.js +9 -0
  117. zenml/zen_server/dashboard/assets/page-CA1j3GpJ.js +1 -0
  118. zenml/zen_server/dashboard/assets/page-CCY6yfmu.js +1 -0
  119. zenml/zen_server/dashboard/assets/page-CgTe7Bme.js +1 -0
  120. zenml/zen_server/dashboard/assets/{page-DtpwnNXq.js → page-Cgn-6v2Y.js} +1 -1
  121. zenml/zen_server/dashboard/assets/page-CxQmQqDw.js +1 -0
  122. zenml/zen_server/dashboard/assets/page-D2Goey3H.js +1 -0
  123. zenml/zen_server/dashboard/assets/page-DLpOnf7u.js +1 -0
  124. zenml/zen_server/dashboard/assets/{page-DVPxY5fT.js → page-DSTQnBk-.js} +1 -1
  125. zenml/zen_server/dashboard/assets/{page-BoFtUD9H.js → page-DTysUGOy.js} +1 -1
  126. zenml/zen_server/dashboard/assets/{page-p2hLJdS2.js → page-D_EXUFJb.js} +1 -1
  127. zenml/zen_server/dashboard/assets/page-Db15QzsM.js +1 -0
  128. zenml/zen_server/dashboard/assets/{page-Btu39x7k.js → page-DugsjcQ_.js} +1 -1
  129. zenml/zen_server/dashboard/assets/{page-CZe9GEBF.js → page-OFKSPyN7.js} +1 -1
  130. zenml/zen_server/dashboard/assets/{page-CDgZmwxP.js → page-RnG-qhv9.js} +1 -1
  131. zenml/zen_server/dashboard/assets/{page-Cjn97HMv.js → page-T2BtjwPl.js} +1 -1
  132. zenml/zen_server/dashboard/assets/page-TXe1Eo3Z.js +1 -0
  133. zenml/zen_server/dashboard/assets/{page-BxiWdeyg.js → page-YiF_fNbe.js} +1 -1
  134. zenml/zen_server/dashboard/assets/{page-399pVZHU.js → page-hQaiQXfg.js} +1 -1
  135. zenml/zen_server/dashboard/assets/persist-3-5nOJ6m.js +1 -0
  136. zenml/zen_server/dashboard/assets/{play-circle-CNtZKDnW.js → play-circle-XSkLR12B.js} +1 -1
  137. zenml/zen_server/dashboard/assets/{plus-DOeLmm7C.js → plus-FB9-lEq_.js} +1 -1
  138. zenml/zen_server/dashboard/assets/refresh-COb6KYDi.js +1 -0
  139. zenml/zen_server/dashboard/assets/sharedSchema-BoYx_B_L.js +14 -0
  140. zenml/zen_server/dashboard/assets/{stack-detail-query-Ck7j7BP_.js → stack-detail-query-B-US_-wa.js} +1 -1
  141. zenml/zen_server/dashboard/assets/{terminal-By9cErXc.js → terminal-grtjrIEJ.js} +1 -1
  142. zenml/zen_server/dashboard/assets/trash-Cd5CSFqA.js +1 -0
  143. zenml/zen_server/dashboard/assets/{update-server-settings-mutation-f3ZT7psb.js → update-server-settings-mutation-B8GB_ubU.js} +1 -1
  144. zenml/zen_server/dashboard/assets/{url-rGEp5Umh.js → url-hcMJkz8p.js} +1 -1
  145. zenml/zen_server/dashboard/assets/{zod-BtSyGx4C.js → zod-CnykDKJj.js} +1 -1
  146. zenml/zen_server/dashboard/index.html +7 -7
  147. zenml/zen_server/dashboard_legacy/asset-manifest.json +4 -4
  148. zenml/zen_server/dashboard_legacy/index.html +1 -1
  149. zenml/zen_server/dashboard_legacy/{precache-manifest.2fa6e528a6e7447caaf35dadfe7514bb.js → precache-manifest.9c473c96a43298343a7ce1256183123b.js} +4 -4
  150. zenml/zen_server/dashboard_legacy/service-worker.js +1 -1
  151. zenml/zen_server/dashboard_legacy/static/js/{main.4aab7e98.chunk.js → main.463c90b9.chunk.js} +2 -2
  152. zenml/zen_server/dashboard_legacy/static/js/{main.4aab7e98.chunk.js.map → main.463c90b9.chunk.js.map} +1 -1
  153. zenml/zen_server/deploy/helm/Chart.yaml +1 -1
  154. zenml/zen_server/deploy/helm/README.md +2 -2
  155. zenml/zen_server/routers/stack_deployment_endpoints.py +6 -0
  156. zenml/zen_server/routers/users_endpoints.py +0 -7
  157. zenml/zen_server/utils.py +75 -0
  158. zenml/zen_server/zen_server_api.py +52 -1
  159. zenml/zen_stores/base_zen_store.py +7 -1
  160. zenml/zen_stores/migrations/versions/0.64.0_release.py +23 -0
  161. zenml/zen_stores/migrations/versions/026d4577b6a0_add_code_path.py +39 -0
  162. zenml/zen_stores/migrations/versions/3dcc5d20e82f_add_last_user_activity.py +51 -0
  163. zenml/zen_stores/migrations/versions/909550c7c4da_remove_user_hub_token.py +36 -0
  164. zenml/zen_stores/rest_zen_store.py +5 -3
  165. zenml/zen_stores/schemas/pipeline_deployment_schemas.py +3 -0
  166. zenml/zen_stores/schemas/pipeline_run_schemas.py +3 -0
  167. zenml/zen_stores/schemas/server_settings_schemas.py +2 -0
  168. zenml/zen_stores/schemas/user_schemas.py +0 -2
  169. zenml/zen_stores/sql_zen_store.py +25 -1
  170. {zenml_nightly-0.63.0.dev20240801.dist-info → zenml_nightly-0.64.0.dev20240811.dist-info}/METADATA +3 -3
  171. {zenml_nightly-0.63.0.dev20240801.dist-info → zenml_nightly-0.64.0.dev20240811.dist-info}/RECORD +174 -157
  172. zenml/_hub/client.py +0 -289
  173. zenml/_hub/constants.py +0 -21
  174. zenml/_hub/utils.py +0 -79
  175. zenml/cli/hub.py +0 -1116
  176. zenml/models/v2/misc/hub_plugin_models.py +0 -79
  177. zenml/zen_server/dashboard/assets/@radix-CFOkMR_E.js +0 -85
  178. zenml/zen_server/dashboard/assets/CopyButton-B3sWVJ4Z.js +0 -2
  179. zenml/zen_server/dashboard/assets/DisplayDate-DYgIjlDF.js +0 -1
  180. zenml/zen_server/dashboard/assets/SearchField-CXoBknpt.js +0 -1
  181. zenml/zen_server/dashboard/assets/components-DWe4cTjS.js +0 -1
  182. zenml/zen_server/dashboard/assets/index-vfjX_fJV.css +0 -1
  183. zenml/zen_server/dashboard/assets/page-C6tXXjnK.js +0 -1
  184. zenml/zen_server/dashboard/assets/page-CP9obrnG.js +0 -1
  185. zenml/zen_server/dashboard/assets/page-CaTOsNNw.js +0 -1
  186. zenml/zen_server/dashboard/assets/page-CmXmB_5i.js +0 -1
  187. zenml/zen_server/dashboard/assets/page-CvGAOfad.js +0 -1
  188. zenml/zen_server/dashboard/assets/page-D0bbc-qr.js +0 -5
  189. zenml/zen_server/dashboard/assets/page-DLEtD2ex.js +0 -1
  190. zenml/zen_server/dashboard/assets/page-DupV0aBd.js +0 -1
  191. zenml/zen_server/dashboard/assets/page-EweAR81y.js +0 -1
  192. zenml/zen_server/dashboard/assets/page-w-YaL77M.js +0 -9
  193. zenml/zen_server/dashboard/assets/persist-BReKApOc.js +0 -14
  194. zenml/zen_server/dashboard/assets/secrets-video-OBJ6irhH.svg +0 -21
  195. zenml/zen_server/dashboard/assets/stacks-video-7gfxpAq4.svg +0 -21
  196. {zenml_nightly-0.63.0.dev20240801.dist-info → zenml_nightly-0.64.0.dev20240811.dist-info}/LICENSE +0 -0
  197. {zenml_nightly-0.63.0.dev20240801.dist-info → zenml_nightly-0.64.0.dev20240811.dist-info}/WHEEL +0 -0
  198. {zenml_nightly-0.63.0.dev20240801.dist-info → zenml_nightly-0.64.0.dev20240811.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}"