getml_mlflow.marshalling
pipeline.download_artifact_pipeline
Downloads a getML pipeline artifact from an MLflow run and saves it as a new project.
This function downloads a pipeline artifact from MLflow and creates a new project with a name derived from the original project name and the pipeline ID: "original_project_name-pipeline_id".
If the project already exists (e.g., when calling this function multiple times with the same parameters), the existing project will be overwritten with the downloaded artifacts.
Experimental feature
This feature is experimental and may change in future releases.
PARAMETER | DESCRIPTION |
---|---|
mlflow_client | An MLflow client instance to interact with MLflow. TYPE: |
run_id | The ID of the MLflow run containing the pipeline artifacts. TYPE: |
pipeline_id | The ID of the pipeline to be downloaded. TYPE: |
original_project_name | The name of the original getML project the pipeline was saved from. If None, uses the current project name. |
projects_path | Path where getML projects are stored. Defaults to TYPE: |
RETURNS | DESCRIPTION |
---|---|
Tuple[str, str] | A tuple containing: - The name of the newly created getML project - The ID of the downloaded pipeline |
Example
# Initialize MLflow client
client = MlflowClient(tracking_uri="http://localhost:5000")
run_id = "abcdef1234567890"
pipeline_id = "l2TCiD"
# Download pipeline artifact from a specific run. This creates a new project
# named "interstate94-l2TCiD" with the pipeline
new_project, pipeline_id = getml_mlflow.marshalling.pipeline.download_artifact_pipeline(
client, run_id, pipeline_id, original_project_name="interstate94"
)
# You can now switch to the new project and load the pipeline
getml.project.set_project(new_project)
pipeline = getml.pipeline.load(pipeline_id)
Source code in getml_mlflow/marshalling/pipeline.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
pipeline.switch_to_artifact_pipeline
Downloads an artifact pipeline from MLflow, switches to the newly created project, and loads the pipeline.
This function simplifies the workflow of retrieving a pipeline stored as an MLflow artifact. It downloads the pipeline into a new getML project (named as "original_project_name-pipeline_id"), automatically switches to that project, and loads the pipeline for immediate use.
Experimental feature
This function is experimental and may change in future releases.
PARAMETER | DESCRIPTION |
---|---|
mlflow_client | The MLflow client instance to use for retrieving the artifact. TYPE: |
run_id | The ID of the MLflow run containing the pipeline artifact. TYPE: |
pipeline_id | The ID of the pipeline to download. TYPE: |
original_project_name | The name of the original project. If None, the current project name is used. Defaults to None. |
projects_path | Path to the getML projects directory. Defaults to TYPE: |
RETURNS | DESCRIPTION |
---|---|
Pipeline | The loaded pipeline object in the newly created project. TYPE: |
Examples:
import mlflow
from mlflow.tracking import MlflowClient
import getml_mlflow
import getml
# Connect to MLflow
client = MlflowClient("http://localhost:5000")
# Download pipeline from run and switch to new project
pipeline = getml_mlflow.marshalling.pipeline.switch_to_artifact_pipeline(
client,
"2960ee40202744daa64aa83d180f0b2f",
"uPe3hR"
)
# Pipeline is ready to use
predictions = pipeline.predict(container.test)
Source code in getml_mlflow/marshalling/pipeline.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|