zenml-nightly 0.70.0.dev20241125__py3-none-any.whl → 0.70.0.dev20241201__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 (91) hide show
  1. zenml/VERSION +1 -1
  2. zenml/artifact_stores/base_artifact_store.py +2 -2
  3. zenml/artifacts/artifact_config.py +7 -1
  4. zenml/artifacts/utils.py +56 -31
  5. zenml/cli/__init__.py +18 -0
  6. zenml/cli/base.py +4 -4
  7. zenml/cli/login.py +26 -0
  8. zenml/cli/pipeline.py +80 -0
  9. zenml/cli/server.py +1 -1
  10. zenml/cli/service_connectors.py +3 -3
  11. zenml/cli/stack.py +0 -3
  12. zenml/cli/stack_components.py +0 -1
  13. zenml/cli/utils.py +0 -5
  14. zenml/client.py +8 -18
  15. zenml/config/compiler.py +12 -3
  16. zenml/config/pipeline_configurations.py +20 -0
  17. zenml/config/pipeline_run_configuration.py +1 -0
  18. zenml/config/step_configurations.py +21 -0
  19. zenml/enums.py +1 -0
  20. zenml/image_builders/local_image_builder.py +13 -3
  21. zenml/integrations/__init__.py +1 -0
  22. zenml/integrations/aws/orchestrators/sagemaker_orchestrator.py +14 -6
  23. zenml/integrations/constants.py +1 -0
  24. zenml/integrations/feast/__init__.py +1 -1
  25. zenml/integrations/feast/feature_stores/feast_feature_store.py +13 -9
  26. zenml/integrations/kubernetes/orchestrators/kube_utils.py +46 -2
  27. zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator.py +13 -2
  28. zenml/integrations/kubernetes/orchestrators/kubernetes_orchestrator_entrypoint.py +3 -1
  29. zenml/integrations/kubernetes/orchestrators/manifest_utils.py +3 -2
  30. zenml/integrations/kubernetes/step_operators/kubernetes_step_operator.py +3 -1
  31. zenml/integrations/modal/__init__.py +46 -0
  32. zenml/integrations/modal/flavors/__init__.py +26 -0
  33. zenml/integrations/modal/flavors/modal_step_operator_flavor.py +125 -0
  34. zenml/integrations/modal/step_operators/__init__.py +22 -0
  35. zenml/integrations/modal/step_operators/modal_step_operator.py +242 -0
  36. zenml/io/filesystem.py +2 -2
  37. zenml/io/local_filesystem.py +3 -3
  38. zenml/materializers/built_in_materializer.py +18 -1
  39. zenml/materializers/structured_string_materializer.py +8 -3
  40. zenml/model/model.py +11 -85
  41. zenml/model/utils.py +18 -16
  42. zenml/models/__init__.py +6 -0
  43. zenml/models/v2/core/artifact_version.py +6 -3
  44. zenml/models/v2/core/component.py +0 -22
  45. zenml/models/v2/core/model_version.py +6 -3
  46. zenml/models/v2/core/pipeline_run.py +19 -3
  47. zenml/models/v2/core/run_metadata.py +30 -9
  48. zenml/models/v2/core/step_run.py +6 -4
  49. zenml/models/v2/misc/run_metadata.py +38 -0
  50. zenml/orchestrators/input_utils.py +19 -6
  51. zenml/orchestrators/publish_utils.py +12 -5
  52. zenml/orchestrators/step_launcher.py +7 -3
  53. zenml/orchestrators/step_run_utils.py +26 -9
  54. zenml/orchestrators/step_runner.py +40 -3
  55. zenml/orchestrators/utils.py +24 -23
  56. zenml/pipelines/pipeline_decorator.py +4 -0
  57. zenml/pipelines/pipeline_definition.py +26 -8
  58. zenml/pipelines/run_utils.py +9 -5
  59. zenml/steps/base_step.py +11 -1
  60. zenml/steps/entrypoint_function_utils.py +7 -3
  61. zenml/steps/step_decorator.py +4 -0
  62. zenml/steps/utils.py +23 -7
  63. zenml/types.py +4 -0
  64. zenml/utils/metadata_utils.py +186 -153
  65. zenml/utils/string_utils.py +41 -16
  66. zenml/utils/visualization_utils.py +4 -1
  67. zenml/zen_server/cloud_utils.py +3 -1
  68. zenml/zen_server/rbac/endpoint_utils.py +6 -4
  69. zenml/zen_server/rbac/models.py +3 -2
  70. zenml/zen_server/rbac/utils.py +4 -7
  71. zenml/zen_server/routers/users_endpoints.py +35 -37
  72. zenml/zen_server/routers/workspaces_endpoints.py +44 -55
  73. zenml/zen_server/template_execution/utils.py +1 -0
  74. zenml/zen_stores/migrations/versions/b73bc71f1106_remove_component_spec_path.py +36 -0
  75. zenml/zen_stores/migrations/versions/cc269488e5a9_separate_run_metadata.py +135 -0
  76. zenml/zen_stores/migrations/versions/ec6307720f92_simplify_model_version_links.py +7 -6
  77. zenml/zen_stores/schemas/__init__.py +5 -1
  78. zenml/zen_stores/schemas/artifact_schemas.py +12 -11
  79. zenml/zen_stores/schemas/component_schemas.py +0 -3
  80. zenml/zen_stores/schemas/model_schemas.py +13 -11
  81. zenml/zen_stores/schemas/pipeline_run_schemas.py +44 -16
  82. zenml/zen_stores/schemas/run_metadata_schemas.py +66 -31
  83. zenml/zen_stores/schemas/step_run_schemas.py +32 -12
  84. zenml/zen_stores/schemas/utils.py +47 -3
  85. zenml/zen_stores/sql_zen_store.py +130 -34
  86. {zenml_nightly-0.70.0.dev20241125.dist-info → zenml_nightly-0.70.0.dev20241201.dist-info}/METADATA +1 -1
  87. {zenml_nightly-0.70.0.dev20241125.dist-info → zenml_nightly-0.70.0.dev20241201.dist-info}/RECORD +90 -83
  88. zenml/utils/cloud_utils.py +0 -40
  89. {zenml_nightly-0.70.0.dev20241125.dist-info → zenml_nightly-0.70.0.dev20241201.dist-info}/LICENSE +0 -0
  90. {zenml_nightly-0.70.0.dev20241125.dist-info → zenml_nightly-0.70.0.dev20241201.dist-info}/WHEEL +0 -0
  91. {zenml_nightly-0.70.0.dev20241125.dist-info → zenml_nightly-0.70.0.dev20241201.dist-info}/entry_points.txt +0 -0
zenml/enums.py CHANGED
@@ -60,6 +60,7 @@ class VisualizationType(StrEnum):
60
60
  HTML = "html"
61
61
  IMAGE = "image"
62
62
  MARKDOWN = "markdown"
63
+ JSON = "json"
63
64
 
64
65
 
65
66
  class ZenMLServiceType(StrEnum):
@@ -68,15 +68,25 @@ class LocalImageBuilder(BaseImageBuilder):
68
68
  )
69
69
 
70
70
  if not docker_utils.check_docker():
71
+ # For 3., this is not supported by the python docker library
72
+ # https://github.com/docker/docker-py/issues/3146
71
73
  raise RuntimeError(
72
- "Unable to connect to the Docker daemon. There are two "
74
+ "Unable to connect to the Docker daemon. There are three "
73
75
  "common causes for this:\n"
74
76
  "1) The Docker daemon isn't running.\n"
75
77
  "2) The Docker client isn't configured correctly. The client "
76
78
  "loads its configuration from the following file: "
77
79
  "$HOME/.docker/config.json. If your configuration file is in a "
78
- "different location, set it using the `DOCKER_CONFIG` "
79
- "environment variable."
80
+ "different location, set the `DOCKER_CONFIG` environment "
81
+ "variable to the directory that contains your `config.json` "
82
+ "file.\n"
83
+ "3) If your Docker CLI is working fine but you ran into this "
84
+ "issue, you might be using a non-default Docker context which "
85
+ "is not supported by the Docker python library. To verify "
86
+ "this, run `docker context ls` and check which context has a "
87
+ "`*` next to it. If this is not the `default` context, copy "
88
+ "the `DOCKER ENDPOINT` value of that context and set the "
89
+ "`DOCKER_HOST` environment variable to that value."
80
90
  )
81
91
 
82
92
  def build(
@@ -48,6 +48,7 @@ from zenml.integrations.lightgbm import LightGBMIntegration # noqa
48
48
 
49
49
  # from zenml.integrations.llama_index import LlamaIndexIntegration # noqa
50
50
  from zenml.integrations.mlflow import MlflowIntegration # noqa
51
+ from zenml.integrations.modal import ModalIntegration # noqa
51
52
  from zenml.integrations.neptune import NeptuneIntegration # noqa
52
53
  from zenml.integrations.neural_prophet import NeuralProphetIntegration # noqa
53
54
  from zenml.integrations.numpy import NumpyIntegration # noqa
@@ -305,8 +305,21 @@ class SagemakerOrchestrator(ContainerizedOrchestrator):
305
305
  # Retrieve Executor arguments provided in the Step settings.
306
306
  if use_training_step:
307
307
  args_for_step_executor = step_settings.estimator_args or {}
308
+ args_for_step_executor.setdefault(
309
+ "volume_size", step_settings.volume_size_in_gb
310
+ )
311
+ args_for_step_executor.setdefault(
312
+ "max_run", step_settings.max_runtime_in_seconds
313
+ )
308
314
  else:
309
315
  args_for_step_executor = step_settings.processor_args or {}
316
+ args_for_step_executor.setdefault(
317
+ "volume_size_in_gb", step_settings.volume_size_in_gb
318
+ )
319
+ args_for_step_executor.setdefault(
320
+ "max_runtime_in_seconds",
321
+ step_settings.max_runtime_in_seconds,
322
+ )
310
323
 
311
324
  # Set default values from configured orchestrator Component to
312
325
  # arguments to be used when they are not present in processor_args.
@@ -314,12 +327,7 @@ class SagemakerOrchestrator(ContainerizedOrchestrator):
314
327
  "role",
315
328
  step_settings.execution_role or self.config.execution_role,
316
329
  )
317
- args_for_step_executor.setdefault(
318
- "volume_size_in_gb", step_settings.volume_size_in_gb
319
- )
320
- args_for_step_executor.setdefault(
321
- "max_runtime_in_seconds", step_settings.max_runtime_in_seconds
322
- )
330
+
323
331
  tags = step_settings.tags
324
332
  args_for_step_executor.setdefault(
325
333
  "tags",
@@ -42,6 +42,7 @@ LANGCHAIN = "langchain"
42
42
  LIGHTGBM = "lightgbm"
43
43
  # LLAMA_INDEX = "llama_index"
44
44
  MLFLOW = "mlflow"
45
+ MODAL = "modal"
45
46
  NEPTUNE = "neptune"
46
47
  NEURAL_PROPHET = "neural_prophet"
47
48
  NUMPY = "numpy"
@@ -31,7 +31,7 @@ class FeastIntegration(Integration):
31
31
 
32
32
  NAME = FEAST
33
33
  # click is added to keep the feast click version in sync with ZenML's click
34
- REQUIREMENTS = ["feast", "click>=8.0.1,<8.1.4"]
34
+ REQUIREMENTS = ["feast>=0.12.0", "click>=8.0.1,<8.1.4"]
35
35
  REQUIREMENTS_IGNORED_ON_UNINSTALL = ["click", "pandas"]
36
36
 
37
37
  @classmethod
@@ -16,7 +16,7 @@
16
16
  from typing import Any, Dict, List, Union, cast
17
17
 
18
18
  import pandas as pd
19
- from feast import FeatureStore # type: ignore
19
+ from feast import FeatureService, FeatureStore # type: ignore
20
20
  from feast.infra.registry.base_registry import BaseRegistry # type: ignore
21
21
 
22
22
  from zenml.feature_stores.base_feature_store import BaseFeatureStore
@@ -43,14 +43,14 @@ class FeastFeatureStore(BaseFeatureStore):
43
43
  def get_historical_features(
44
44
  self,
45
45
  entity_df: Union[pd.DataFrame, str],
46
- features: List[str],
46
+ features: Union[List[str], FeatureService],
47
47
  full_feature_names: bool = False,
48
48
  ) -> pd.DataFrame:
49
49
  """Returns the historical features for training or batch scoring.
50
50
 
51
51
  Args:
52
52
  entity_df: The entity DataFrame or entity name.
53
- features: The features to retrieve.
53
+ features: The features to retrieve or a FeatureService.
54
54
  full_feature_names: Whether to return the full feature names.
55
55
 
56
56
  Raise:
@@ -70,14 +70,14 @@ class FeastFeatureStore(BaseFeatureStore):
70
70
  def get_online_features(
71
71
  self,
72
72
  entity_rows: List[Dict[str, Any]],
73
- features: List[str],
73
+ features: Union[List[str], FeatureService],
74
74
  full_feature_names: bool = False,
75
75
  ) -> Dict[str, Any]:
76
76
  """Returns the latest online feature data.
77
77
 
78
78
  Args:
79
79
  entity_rows: The entity rows to retrieve.
80
- features: The features to retrieve.
80
+ features: The features to retrieve or a FeatureService.
81
81
  full_feature_names: Whether to return the full feature names.
82
82
 
83
83
  Raise:
@@ -118,17 +118,21 @@ class FeastFeatureStore(BaseFeatureStore):
118
118
  fs = FeatureStore(repo_path=self.config.feast_repo)
119
119
  return [ds.name for ds in fs.list_entities()]
120
120
 
121
- def get_feature_services(self) -> List[str]:
122
- """Returns the feature service names.
121
+ def get_feature_services(self) -> List[FeatureService]:
122
+ """Returns the feature services.
123
123
 
124
124
  Raise:
125
125
  ConnectionError: If the online component (Redis) is not available.
126
126
 
127
127
  Returns:
128
- The feature service names.
128
+ The feature services.
129
129
  """
130
130
  fs = FeatureStore(repo_path=self.config.feast_repo)
131
- return [ds.name for ds in fs.list_feature_services()]
131
+ feature_services: List[FeatureService] = list(
132
+ fs.list_feature_services()
133
+ )
134
+
135
+ return feature_services
132
136
 
133
137
  def get_feature_views(self) -> List[str]:
134
138
  """Returns the feature view names.
@@ -94,18 +94,62 @@ def load_kube_config(
94
94
  k8s_config.load_kube_config(context=context)
95
95
 
96
96
 
97
- def sanitize_pod_name(pod_name: str) -> str:
97
+ def calculate_max_pod_name_length_for_namespace(namespace: str) -> int:
98
+ """Calculate the max pod length for a certain namespace.
99
+
100
+ Args:
101
+ namespace: The namespace in which the pod will be created.
102
+
103
+ Returns:
104
+ The maximum pod name length.
105
+ """
106
+ # Kubernetes allows Pod names to have 253 characters. However, when
107
+ # creating a pod they try to create a log file which is called
108
+ # <NAMESPACE>_<POD_NAME>_<UUID>, which adds additional characters and
109
+ # runs into filesystem limitations for filename lengths (255). We therefore
110
+ # subtract the length of a UUID (36), the two underscores and the
111
+ # namespace length from the max filename length.
112
+ return 255 - 38 - len(namespace)
113
+
114
+
115
+ def sanitize_pod_name(pod_name: str, namespace: str) -> str:
98
116
  """Sanitize pod names so they conform to Kubernetes pod naming convention.
99
117
 
100
118
  Args:
101
119
  pod_name: Arbitrary input pod name.
120
+ namespace: Namespace in which the Pod will be created.
102
121
 
103
122
  Returns:
104
123
  Sanitized pod name.
105
124
  """
125
+ # https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names
106
126
  pod_name = re.sub(r"[^a-z0-9-]", "-", pod_name.lower())
107
127
  pod_name = re.sub(r"^[-]+", "", pod_name)
108
- return re.sub(r"[-]+", "-", pod_name)
128
+ pod_name = re.sub(r"[-]+$", "", pod_name)
129
+ pod_name = re.sub(r"[-]+", "-", pod_name)
130
+
131
+ allowed_length = calculate_max_pod_name_length_for_namespace(
132
+ namespace=namespace
133
+ )
134
+ return pod_name[:allowed_length]
135
+
136
+
137
+ def sanitize_label(label: str) -> str:
138
+ """Sanitize a label for a Kubernetes resource.
139
+
140
+ Args:
141
+ label: The label to sanitize.
142
+
143
+ Returns:
144
+ The sanitized label.
145
+ """
146
+ # https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names
147
+ label = re.sub(r"[^a-z0-9-]", "-", label.lower())
148
+ label = re.sub(r"^[-]+", "", label)
149
+ label = re.sub(r"[-]+$", "", label)
150
+ label = re.sub(r"[-]+", "-", label)
151
+
152
+ return label[:63]
109
153
 
110
154
 
111
155
  def pod_is_not_pending(pod: k8s_client.V1Pod) -> bool:
@@ -395,8 +395,19 @@ class KubernetesOrchestrator(ContainerizedOrchestrator):
395
395
  )
396
396
 
397
397
  pipeline_name = deployment.pipeline_configuration.name
398
- orchestrator_run_name = get_orchestrator_run_name(pipeline_name)
399
- pod_name = kube_utils.sanitize_pod_name(orchestrator_run_name)
398
+
399
+ # We already make sure the orchestrator run name has the correct length
400
+ # to make sure we don't cut off the randomized suffix later when
401
+ # sanitizing the pod name. This avoids any pod naming collisions.
402
+ max_length = kube_utils.calculate_max_pod_name_length_for_namespace(
403
+ namespace=self.config.kubernetes_namespace
404
+ )
405
+ orchestrator_run_name = get_orchestrator_run_name(
406
+ pipeline_name, max_length=max_length
407
+ )
408
+ pod_name = kube_utils.sanitize_pod_name(
409
+ orchestrator_run_name, namespace=self.config.kubernetes_namespace
410
+ )
400
411
 
401
412
  assert stack.container_registry
402
413
 
@@ -90,7 +90,9 @@ def main() -> None:
90
90
  """
91
91
  # Define Kubernetes pod name.
92
92
  pod_name = f"{orchestrator_run_id}-{step_name}"
93
- pod_name = kube_utils.sanitize_pod_name(pod_name)
93
+ pod_name = kube_utils.sanitize_pod_name(
94
+ pod_name, namespace=args.kubernetes_namespace
95
+ )
94
96
 
95
97
  image = KubernetesOrchestrator.get_image(
96
98
  deployment=deployment_config, step_name=step_name
@@ -25,6 +25,7 @@ from zenml.constants import ENV_ZENML_ENABLE_REPO_INIT_WARNINGS
25
25
  from zenml.integrations.airflow.orchestrators.dag_generator import (
26
26
  ENV_ZENML_LOCAL_STORES_PATH,
27
27
  )
28
+ from zenml.integrations.kubernetes.orchestrators import kube_utils
28
29
  from zenml.integrations.kubernetes.pod_settings import KubernetesPodSettings
29
30
 
30
31
 
@@ -167,8 +168,8 @@ def build_pod_manifest(
167
168
  # Add run_name and pipeline_name to the labels
168
169
  labels.update(
169
170
  {
170
- "run": run_name,
171
- "pipeline": pipeline_name,
171
+ "run": kube_utils.sanitize_label(run_name),
172
+ "pipeline": kube_utils.sanitize_label(pipeline_name),
172
173
  }
173
174
  )
174
175
 
@@ -197,7 +197,9 @@ class KubernetesStepOperator(BaseStepOperator):
197
197
  )
198
198
 
199
199
  pod_name = f"{info.run_name}_{info.pipeline_step_name}"
200
- pod_name = kube_utils.sanitize_pod_name(pod_name)
200
+ pod_name = kube_utils.sanitize_pod_name(
201
+ pod_name, namespace=self.config.kubernetes_namespace
202
+ )
201
203
 
202
204
  command = entrypoint_command[:3]
203
205
  args = entrypoint_command[3:]
@@ -0,0 +1,46 @@
1
+ # Copyright (c) ZenML GmbH 2024. 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
+ """Modal integration for cloud-native step execution.
15
+
16
+ The Modal integration sub-module provides a step operator flavor that allows
17
+ executing steps on Modal's cloud infrastructure.
18
+ """
19
+ from typing import List, Type
20
+
21
+ from zenml.integrations.constants import MODAL
22
+ from zenml.integrations.integration import Integration
23
+ from zenml.stack import Flavor
24
+
25
+ MODAL_STEP_OPERATOR_FLAVOR = "modal"
26
+
27
+
28
+ class ModalIntegration(Integration):
29
+ """Definition of Modal integration for ZenML."""
30
+
31
+ NAME = MODAL
32
+ REQUIREMENTS = ["modal>=0.64.49,<1"]
33
+
34
+ @classmethod
35
+ def flavors(cls) -> List[Type[Flavor]]:
36
+ """Declare the stack component flavors for the Modal integration.
37
+
38
+ Returns:
39
+ List of new stack component flavors.
40
+ """
41
+ from zenml.integrations.modal.flavors import ModalStepOperatorFlavor
42
+
43
+ return [ModalStepOperatorFlavor]
44
+
45
+
46
+ ModalIntegration.check_installation()
@@ -0,0 +1,26 @@
1
+ # Copyright (c) ZenML GmbH 2024. 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
+ """Modal integration flavors."""
15
+
16
+ from zenml.integrations.modal.flavors.modal_step_operator_flavor import (
17
+ ModalStepOperatorConfig,
18
+ ModalStepOperatorFlavor,
19
+ ModalStepOperatorSettings,
20
+ )
21
+
22
+ __all__ = [
23
+ "ModalStepOperatorConfig",
24
+ "ModalStepOperatorFlavor",
25
+ "ModalStepOperatorSettings",
26
+ ]
@@ -0,0 +1,125 @@
1
+ # Copyright (c) ZenML GmbH 2024. 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
+ """Modal step operator flavor."""
15
+
16
+ from typing import TYPE_CHECKING, Optional, Type
17
+
18
+ from zenml.config.base_settings import BaseSettings
19
+ from zenml.integrations.modal import MODAL_STEP_OPERATOR_FLAVOR
20
+ from zenml.step_operators import BaseStepOperatorConfig, BaseStepOperatorFlavor
21
+
22
+ if TYPE_CHECKING:
23
+ from zenml.integrations.modal.step_operators import ModalStepOperator
24
+
25
+
26
+ class ModalStepOperatorSettings(BaseSettings):
27
+ """Settings for the Modal step operator.
28
+
29
+ Specifying the region and cloud provider is only available for Enterprise
30
+ and Team plan customers.
31
+
32
+ Certain combinations of settings are not available. It is suggested to err
33
+ on the side of looser settings rather than more restrictive ones to avoid
34
+ pipeline execution failures. In the case of failures, however, Modal
35
+ provides detailed error messages that can help identify what is
36
+ incompatible. See more in the Modal docs at https://modal.com/docs/guide/region-selection.
37
+
38
+ Attributes:
39
+ gpu: The type of GPU to use for the step execution.
40
+ region: The region to use for the step execution.
41
+ cloud: The cloud provider to use for the step execution.
42
+ """
43
+
44
+ gpu: Optional[str] = None
45
+ region: Optional[str] = None
46
+ cloud: Optional[str] = None
47
+
48
+
49
+ class ModalStepOperatorConfig(
50
+ BaseStepOperatorConfig, ModalStepOperatorSettings
51
+ ):
52
+ """Configuration for the Modal step operator."""
53
+
54
+ @property
55
+ def is_remote(self) -> bool:
56
+ """Checks if this stack component is running remotely.
57
+
58
+ This designation is used to determine if the stack component can be
59
+ used with a local ZenML database or if it requires a remote ZenML
60
+ server.
61
+
62
+ Returns:
63
+ True if this config is for a remote component, False otherwise.
64
+ """
65
+ return True
66
+
67
+
68
+ class ModalStepOperatorFlavor(BaseStepOperatorFlavor):
69
+ """Modal step operator flavor."""
70
+
71
+ @property
72
+ def name(self) -> str:
73
+ """Name of the flavor.
74
+
75
+ Returns:
76
+ The name of the flavor.
77
+ """
78
+ return MODAL_STEP_OPERATOR_FLAVOR
79
+
80
+ @property
81
+ def docs_url(self) -> Optional[str]:
82
+ """A url to point at docs explaining this flavor.
83
+
84
+ Returns:
85
+ A flavor docs url.
86
+ """
87
+ return self.generate_default_docs_url()
88
+
89
+ @property
90
+ def sdk_docs_url(self) -> Optional[str]:
91
+ """A url to point at SDK docs explaining this flavor.
92
+
93
+ Returns:
94
+ A flavor SDK docs url.
95
+ """
96
+ return self.generate_default_sdk_docs_url()
97
+
98
+ @property
99
+ def logo_url(self) -> str:
100
+ """A url to represent the flavor in the dashboard.
101
+
102
+ Returns:
103
+ The flavor logo.
104
+ """
105
+ return "https://public-flavor-logos.s3.eu-central-1.amazonaws.com/step_operator/modal.png"
106
+
107
+ @property
108
+ def config_class(self) -> Type[ModalStepOperatorConfig]:
109
+ """Returns `ModalStepOperatorConfig` config class.
110
+
111
+ Returns:
112
+ The config class.
113
+ """
114
+ return ModalStepOperatorConfig
115
+
116
+ @property
117
+ def implementation_class(self) -> Type["ModalStepOperator"]:
118
+ """Implementation class for this flavor.
119
+
120
+ Returns:
121
+ The implementation class.
122
+ """
123
+ from zenml.integrations.modal.step_operators import ModalStepOperator
124
+
125
+ return ModalStepOperator
@@ -0,0 +1,22 @@
1
+ # Copyright (c) ZenML GmbH 2024. 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
+ """Modal step operator."""
15
+
16
+ from zenml.integrations.modal.step_operators.modal_step_operator import (
17
+ ModalStepOperator,
18
+ )
19
+
20
+ __all__ = [
21
+ "ModalStepOperator",
22
+ ]