Skip to content

Commit

Permalink
Merge branch 'doc/factory-generation-steps' of github.com:zenml-io/ze…
Browse files Browse the repository at this point in the history
…nml into doc/factory-generation-steps
  • Loading branch information
strickvl committed Oct 15, 2024
2 parents 6d0d522 + 53f12ba commit 57e830d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 9 deletions.
Binary file modified docs/book/.gitbook/assets/dynamic_artifact_pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/book/.gitbook/assets/metadata_artifact_pipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ In ZenML pipelines, you often need to reuse the same step multiple times with
different inputs, resulting in multiple artifacts. However, the default naming
convention for artifacts can make it challenging to track and differentiate
between these outputs, especially when they need to be used in subsequent
pipelines. Below you can find a detailed exploration of how you might go about dynamically generating steps and artifacts to improve pipeline
flexibility and maintainability.
pipelines. Below you can find a detailed exploration of how you might go about dynamically generating steps and artifacts to improve pipeline flexibility and maintainability.

By default, ZenML uses type annotations in function definitions to determine artifact names. While this works well for steps used once in a pipeline, it becomes problematic when:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,16 @@ def get_step_run_metadata(
Returns:
A dictionary of metadata.
"""
return {
metadata: Dict[str, Any] = {
METADATA_EXPERIMENT_TRACKER_URL: Uri(
self.get_tracking_uri(as_plain_text=False)
),
"mlflow_run_id": mlflow.active_run().info.run_id,
"mlflow_experiment_id": mlflow.active_run().info.experiment_id,
}
if run := mlflow.active_run():
metadata["mlflow_run_id"] = run.info.run_id
metadata["mlflow_experiment_id"] = run.info.experiment_id

return metadata

def disable_autologging(self) -> None:
"""Disables MLflow autologging for all supported frameworks."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,16 @@ def register_model_version(
Raises:
RuntimeError: If the registered model does not exist.
ValueError: If no model source URI was provided.
Returns:
The registered model version.
"""
if not model_source_uri:
raise ValueError(
"Unable to register model version without model source URI."
)

# Check if the model exists, if not create it.
try:
self.get_model(name=name)
Expand Down
4 changes: 2 additions & 2 deletions src/zenml/integrations/mlflow/services/mlflow_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def run(self) -> None:
# to run the deploy the model on the local running environment
if int(mlflow_version[0]) >= 2:
backend_kwargs["env_manager"] = "local"
backend = PyFuncBackend(
backend = PyFuncBackend( # type: ignore[no-untyped-call]
config={},
no_conda=True,
workers=self.config.workers,
Expand All @@ -240,7 +240,7 @@ def run(self) -> None:
"stack."
)
experiment_tracker.configure_mlflow()
backend.serve(
backend.serve( # type: ignore[no-untyped-call]
model_uri=self.config.model_uri,
port=self.endpoint.status.port,
host="localhost",
Expand Down
2 changes: 1 addition & 1 deletion src/zenml/integrations/mlflow/steps/mlflow_deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def mlflow_model_deployer_step(
# Fetch the model URI from the MLflow artifact store
model_uri = ""
if mlflow_run_id and client.list_artifacts(mlflow_run_id, model_name):
model_uri = artifact_utils.get_artifact_uri(
model_uri = artifact_utils.get_artifact_uri( # type: ignore[no-untyped-call]
run_id=mlflow_run_id, artifact_path=model_name
)

Expand Down
2 changes: 1 addition & 1 deletion src/zenml/integrations/mlflow/steps/mlflow_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def mlflow_register_model_step(
if not model_source_uri and client.list_artifacts(
mlflow_run_id, trained_model_name
):
model_source_uri = artifact_utils.get_artifact_uri(
model_source_uri = artifact_utils.get_artifact_uri( # type: ignore[no-untyped-call]
run_id=mlflow_run_id, artifact_path=trained_model_name
)
if not model_source_uri:
Expand Down

0 comments on commit 57e830d

Please sign in to comment.