Mlflow
zenml.integrations.mlflow
Initialization for the ZenML MLflow integration.
The MLflow integrations currently enables you to use MLflow tracking as a convenient way to visualize your experiment runs within the MLflow UI.
Attributes
MLFLOW = 'mlflow'
module-attribute
MLFLOW_MODEL_DEPLOYER_FLAVOR = 'mlflow'
module-attribute
MLFLOW_MODEL_EXPERIMENT_TRACKER_FLAVOR = 'mlflow'
module-attribute
MLFLOW_MODEL_REGISTRY_FLAVOR = 'mlflow'
module-attribute
logger = get_logger(__name__)
module-attribute
Classes
Flavor
Class for ZenML Flavors.
Attributes
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig
config class.
Returns:
Type | Description |
---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The config schema. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
Type | Description |
---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
Type | Description |
---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
Functions
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
Type | Description |
---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
Type | Description |
---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.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 |
|
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. |
True
|
Returns:
Type | Description |
---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
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 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
Integration
Base class for integration in ZenML.
Functions
activate() -> None
classmethod
Abstract method to activate the integration.
Source code in src/zenml/integrations/integration.py
175 176 177 |
|
check_installation() -> bool
classmethod
Method to check whether the required packages are installed.
Returns:
Type | Description |
---|---|
bool
|
True if all required packages are installed, False otherwise. |
Source code in src/zenml/integrations/integration.py
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
flavors() -> List[Type[Flavor]]
classmethod
Abstract method to declare new stack component flavors.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
A list of new stack component flavors. |
Source code in src/zenml/integrations/integration.py
179 180 181 182 183 184 185 186 |
|
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
get_uninstall_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the uninstall requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Abstract method to declare new plugin flavors.
Returns:
Type | Description |
---|---|
List[Type[BasePluginFlavor]]
|
A list of new plugin flavors. |
Source code in src/zenml/integrations/integration.py
188 189 190 191 192 193 194 195 |
|
MlflowIntegration
Bases: Integration
Definition of MLflow integration for ZenML.
Functions
activate() -> None
classmethod
Activate the MLflow integration.
Source code in src/zenml/integrations/mlflow/__init__.py
74 75 76 77 |
|
flavors() -> List[Type[Flavor]]
classmethod
Declare the stack component flavors for the MLflow integration.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
List of stack component flavors for this integration. |
Source code in src/zenml/integrations/mlflow/__init__.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/mlflow/__init__.py
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 |
|
Functions
get_logger(logger_name: str) -> logging.Logger
Main function to get logger name,.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger_name
|
str
|
Name of logger to initialize. |
required |
Returns:
Type | Description |
---|---|
Logger
|
A logger object. |
Source code in src/zenml/logger.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
Modules
experiment_trackers
Initialization of the MLflow experiment tracker.
Classes
MLFlowExperimentTracker(*args: Any, **kwargs: Any)
Bases: BaseExperimentTracker
Track experiments using MLflow.
Initialize the experiment tracker and validate the tracking uri.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Any
|
Variable length argument list. |
()
|
**kwargs
|
Any
|
Arbitrary keyword arguments. |
{}
|
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
66 67 68 69 70 71 72 73 74 |
|
config: MLFlowExperimentTrackerConfig
property
Returns the MLFlowExperimentTrackerConfig
config.
Returns:
Type | Description |
---|---|
MLFlowExperimentTrackerConfig
|
The configuration. |
local_path: Optional[str]
property
Path to the local directory where the MLflow artifacts are stored.
Returns:
Type | Description |
---|---|
Optional[str]
|
None if configured with a remote tracking URI, otherwise the |
Optional[str]
|
path to the local MLflow artifact store directory. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Mlflow experiment tracker.
Returns:
Type | Description |
---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Checks the stack has a LocalArtifactStore
if no tracking uri was specified.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
An optional |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Stops active MLflow runs and resets the MLflow tracking uri.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed or not. |
required |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
configure_mlflow() -> None
Configures the MLflow tracking URI and any additional credentials.
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
disable_autologging() -> None
Disables MLflow autologging for all supported frameworks.
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
get_run_id(experiment_name: str, run_name: str) -> Optional[str]
Gets the if of a run with the given name and experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment_name
|
str
|
Name of the experiment in which to search for the run. |
required |
run_name
|
str
|
Name of the run to search. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The id of the run if it exists. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
get_step_run_metadata(info: StepRunInfo) -> Dict[str, MetadataType]
Get component- and step-specific metadata after a step ran.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
Type | Description |
---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
get_tracking_uri(as_plain_text: bool = True) -> str
Returns the configured tracking URI or a local fallback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_plain_text
|
bool
|
Whether to return the tracking URI as plain text. |
True
|
Returns:
Type | Description |
---|---|
str
|
The tracking URI. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
prepare_step_run(info: StepRunInfo) -> None
Sets the MLflow tracking uri and credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
Modules
mlflow_experiment_tracker
Implementation of the MLflow experiment tracker for ZenML.
MLFlowExperimentTracker(*args: Any, **kwargs: Any)
Bases: BaseExperimentTracker
Track experiments using MLflow.
Initialize the experiment tracker and validate the tracking uri.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Any
|
Variable length argument list. |
()
|
**kwargs
|
Any
|
Arbitrary keyword arguments. |
{}
|
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
66 67 68 69 70 71 72 73 74 |
|
config: MLFlowExperimentTrackerConfig
property
Returns the MLFlowExperimentTrackerConfig
config.
Returns:
Type | Description |
---|---|
MLFlowExperimentTrackerConfig
|
The configuration. |
local_path: Optional[str]
property
Path to the local directory where the MLflow artifacts are stored.
Returns:
Type | Description |
---|---|
Optional[str]
|
None if configured with a remote tracking URI, otherwise the |
Optional[str]
|
path to the local MLflow artifact store directory. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Mlflow experiment tracker.
Returns:
Type | Description |
---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Checks the stack has a LocalArtifactStore
if no tracking uri was specified.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
An optional |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Stops active MLflow runs and resets the MLflow tracking uri.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed or not. |
required |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
configure_mlflow() -> None
Configures the MLflow tracking URI and any additional credentials.
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
disable_autologging() -> None
Disables MLflow autologging for all supported frameworks.
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
get_run_id(experiment_name: str, run_name: str) -> Optional[str]
Gets the if of a run with the given name and experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
experiment_name
|
str
|
Name of the experiment in which to search for the run. |
required |
run_name
|
str
|
Name of the run to search. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
The id of the run if it exists. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
|
get_step_run_metadata(info: StepRunInfo) -> Dict[str, MetadataType]
Get component- and step-specific metadata after a step ran.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
Type | Description |
---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
get_tracking_uri(as_plain_text: bool = True) -> str
Returns the configured tracking URI or a local fallback.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_plain_text
|
bool
|
Whether to return the tracking URI as plain text. |
True
|
Returns:
Type | Description |
---|---|
str
|
The tracking URI. |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
prepare_step_run(info: StepRunInfo) -> None
Sets the MLflow tracking uri and credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/integrations/mlflow/experiment_trackers/mlflow_experiment_tracker.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|
flavors
MLFlow integration flavors.
Classes
MLFlowExperimentTrackerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseExperimentTrackerConfig
, MLFlowExperimentTrackerSettings
Config for the MLflow experiment tracker.
Attributes:
Name | Type | Description |
---|---|---|
tracking_uri |
Optional[str]
|
The uri of the mlflow tracking server. If no uri is set,
your stack must contain a |
tracking_username |
Optional[str]
|
Username for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_password |
Optional[str]
|
Password for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_token |
Optional[str]
|
Token for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_insecure_tls |
bool
|
Skips verification of TLS connection to the
MLflow tracking server if set to |
databricks_host |
Optional[str]
|
The host of the Databricks workspace with the MLflow
managed server to connect to. This is only required if
|
enable_unity_catalog |
bool
|
If |
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
is_local: bool
property
Checks if this stack component is running locally.
Returns:
Type | Description |
---|---|
bool
|
True if this config is for a local component, False otherwise. |
MLFlowExperimentTrackerFlavor
Bases: BaseExperimentTrackerFlavor
Class for the MLFlowExperimentTrackerFlavor
.
config_class: Type[MLFlowExperimentTrackerConfig]
property
Returns MLFlowExperimentTrackerConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowExperimentTrackerConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowExperimentTracker]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowExperimentTracker]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
MLFlowModelDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModelDeployerConfig
Configuration for the MLflow model deployer.
Attributes:
Name | Type | Description |
---|---|---|
service_path |
str
|
the path where the local MLflow deployment service configuration, PID and log files are stored. |
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
is_local: bool
property
Checks if this stack component is running locally.
Returns:
Type | Description |
---|---|
bool
|
True if this config is for a local component, False otherwise. |
MLFlowModelDeployerFlavor
Bases: BaseModelDeployerFlavor
Model deployer flavor for MLflow models.
config_class: Type[MLFlowModelDeployerConfig]
property
Returns MLFlowModelDeployerConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowModelDeployerConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowModelDeployer]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowModelDeployer]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
MLFlowModelRegistryConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModelRegistryConfig
Configuration for the MLflow model registry.
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
MLFlowModelRegistryFlavor
Bases: BaseModelRegistryFlavor
Model registry flavor for MLflow models.
config_class: Type[MLFlowModelRegistryConfig]
property
Returns MLFlowModelRegistryConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowModelRegistryConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowModelRegistry]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowModelRegistry]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
Modules
mlflow_experiment_tracker_flavor
MLflow experiment tracker flavor.
MLFlowExperimentTrackerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseExperimentTrackerConfig
, MLFlowExperimentTrackerSettings
Config for the MLflow experiment tracker.
Attributes:
Name | Type | Description |
---|---|---|
tracking_uri |
Optional[str]
|
The uri of the mlflow tracking server. If no uri is set,
your stack must contain a |
tracking_username |
Optional[str]
|
Username for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_password |
Optional[str]
|
Password for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_token |
Optional[str]
|
Token for authenticating with the MLflow
tracking server. When a remote tracking uri is specified,
either |
tracking_insecure_tls |
bool
|
Skips verification of TLS connection to the
MLflow tracking server if set to |
databricks_host |
Optional[str]
|
The host of the Databricks workspace with the MLflow
managed server to connect to. This is only required if
|
enable_unity_catalog |
bool
|
If |
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
is_local: bool
property
Checks if this stack component is running locally.
Returns:
Type | Description |
---|---|
bool
|
True if this config is for a local component, False otherwise. |
MLFlowExperimentTrackerFlavor
Bases: BaseExperimentTrackerFlavor
Class for the MLFlowExperimentTrackerFlavor
.
config_class: Type[MLFlowExperimentTrackerConfig]
property
Returns MLFlowExperimentTrackerConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowExperimentTrackerConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowExperimentTracker]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowExperimentTracker]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
MLFlowExperimentTrackerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Settings for the MLflow experiment tracker.
Attributes:
Name | Type | Description |
---|---|---|
experiment_name |
Optional[str]
|
The MLflow experiment name. |
nested |
bool
|
If |
tags |
Dict[str, Any]
|
Tags for the Mlflow run. |
Source code in src/zenml/config/secret_reference_mixin.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 |
|
is_databricks_tracking_uri(tracking_uri: str) -> bool
Checks whether the given tracking uri is a Databricks tracking uri.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tracking_uri
|
str
|
The tracking uri to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
bool
|
otherwise. |
Source code in src/zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py
48 49 50 51 52 53 54 55 56 57 58 |
|
is_remote_mlflow_tracking_uri(tracking_uri: str) -> bool
Checks whether the given tracking uri is remote or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tracking_uri
|
str
|
The tracking uri to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
Source code in src/zenml/integrations/mlflow/flavors/mlflow_experiment_tracker_flavor.py
34 35 36 37 38 39 40 41 42 43 44 45 |
|
mlflow_model_deployer_flavor
MLflow model deployer flavor.
MLFlowModelDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModelDeployerConfig
Configuration for the MLflow model deployer.
Attributes:
Name | Type | Description |
---|---|---|
service_path |
str
|
the path where the local MLflow deployment service configuration, PID and log files are stored. |
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
is_local: bool
property
Checks if this stack component is running locally.
Returns:
Type | Description |
---|---|
bool
|
True if this config is for a local component, False otherwise. |
MLFlowModelDeployerFlavor
Bases: BaseModelDeployerFlavor
Model deployer flavor for MLflow models.
config_class: Type[MLFlowModelDeployerConfig]
property
Returns MLFlowModelDeployerConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowModelDeployerConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowModelDeployer]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowModelDeployer]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
mlflow_model_registry_flavor
MLflow model registry flavor.
MLFlowModelRegistryConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModelRegistryConfig
Configuration for the MLflow model registry.
Source code in src/zenml/stack/stack_component.py
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 120 121 122 |
|
MLFlowModelRegistryFlavor
Bases: BaseModelRegistryFlavor
Model registry flavor for MLflow models.
config_class: Type[MLFlowModelRegistryConfig]
property
Returns MLFlowModelRegistryConfig
config class.
Returns:
Type | Description |
---|---|
Type[MLFlowModelRegistryConfig]
|
The config class. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[MLFlowModelRegistry]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[MLFlowModelRegistry]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
mlflow_utils
Implementation of utils specific to the MLflow integration.
Classes
Functions
get_missing_mlflow_experiment_tracker_error() -> ValueError
Returns description of how to add an MLflow experiment tracker to your stack.
Returns:
Name | Type | Description |
---|---|---|
ValueError |
ValueError
|
If no MLflow experiment tracker is registered in the active stack. |
Source code in src/zenml/integrations/mlflow/mlflow_utils.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
get_tracking_uri() -> str
Gets the MLflow tracking URI from the active experiment tracking stack component.
noqa: DAR401
Returns:
Type | Description |
---|---|
str
|
MLflow tracking URI. |
Source code in src/zenml/integrations/mlflow/mlflow_utils.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
is_zenml_run(run: Run) -> bool
Checks if a MLflow run is a ZenML run or not.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run
|
Run
|
The run to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
If the run is a ZenML run. |
Source code in src/zenml/integrations/mlflow/mlflow_utils.py
64 65 66 67 68 69 70 71 72 73 |
|
stop_zenml_mlflow_runs(status: str) -> None
Stops active ZenML Mlflow runs.
This function stops all MLflow active runs until no active run exists or a non-ZenML run is active.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
status
|
str
|
The status to set the run to. |
required |
Source code in src/zenml/integrations/mlflow/mlflow_utils.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
model_deployers
Initialization of the MLflow model deployers.
Classes
MLFlowModelDeployer(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseModelDeployer
MLflow implementation of the BaseModelDeployer.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
config: MLFlowModelDeployerConfig
property
Returns the MLFlowModelDeployerConfig
config.
Returns:
Type | Description |
---|---|
MLFlowModelDeployerConfig
|
The configuration. |
local_path: str
property
Returns the path to the root directory.
This is where all configurations for MLflow deployment daemon processes are stored.
If the service path is not set in the config by the user, the path is set to a local default path according to the component ID.
Returns:
Type | Description |
---|---|
str
|
The path to the local service root directory. |
get_model_server_info(service_instance: MLFlowDeploymentService) -> Dict[str, Optional[str]]
staticmethod
Return implementation specific information relevant to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_instance
|
MLFlowDeploymentService
|
Instance of a SeldonDeploymentService |
required |
Returns:
Type | Description |
---|---|
Dict[str, Optional[str]]
|
A dictionary containing the information. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
get_service_path(id_: UUID) -> str
staticmethod
Get the path where local MLflow service information is stored.
This includes the deployment service configuration, PID and log files are stored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
UUID
|
The ID of the MLflow model deployer. |
required |
Returns:
Type | Description |
---|---|
str
|
The service path. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
perform_delete_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT, force: bool = False) -> None
Method to delete all configuration of a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to delete. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
force
|
bool
|
If True, force the service to stop. |
False
|
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
perform_deploy_model(id: UUID, config: ServiceConfig, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> BaseService
Create a new MLflow deployment service or update an existing one.
This should serve the supplied model and deployment configuration.
This method has two modes of operation, depending on the replace
argument value:
-
if
replace
is False, calling this method will create a new MLflow deployment server to reflect the model and other configuration parameters specified in the supplied MLflow serviceconfig
. -
if
replace
is True, this method will first attempt to find an existing MLflow deployment service that is equivalent to the supplied configuration parameters. Two or more MLflow deployment services are considered equivalent if they have the samepipeline_name
,pipeline_step_name
andmodel_name
configuration parameters. To put it differently, two MLflow deployment services are equivalent if they serve versions of the same model deployed by the same pipeline step. If an equivalent MLflow deployment is found, it will be updated in place to reflect the new configuration parameters.
Callers should set replace
to True if they want a continuous model
deployment workflow that doesn't spin up a new MLflow deployment
server for each new model version. If multiple equivalent MLflow
deployment servers are found, one is selected at random to be updated
and the others are deleted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
UUID
|
the ID of the MLflow deployment service to be created or updated. |
required |
config
|
ServiceConfig
|
the configuration of the model to be deployed with MLflow. |
required |
timeout
|
int
|
the timeout in seconds to wait for the MLflow server to be provisioned and successfully started or updated. If set to 0, the method will return immediately after the MLflow server is provisioned, without waiting for it to fully start. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
BaseService
|
The ZenML MLflow deployment service object that can be used to |
BaseService
|
interact with the MLflow model server. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
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 |
|
perform_start_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> BaseService
Method to start a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to start. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to start. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
BaseService
|
The service that was started. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
perform_stop_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT, force: bool = False) -> BaseService
Method to stop a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to stop. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
force
|
bool
|
If True, force the service to stop. |
False
|
Returns:
Type | Description |
---|---|
BaseService
|
The service that was stopped. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
Modules
mlflow_model_deployer
Implementation of the MLflow model deployer.
MLFlowModelDeployer(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseModelDeployer
MLflow implementation of the BaseModelDeployer.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
config: MLFlowModelDeployerConfig
property
Returns the MLFlowModelDeployerConfig
config.
Returns:
Type | Description |
---|---|
MLFlowModelDeployerConfig
|
The configuration. |
local_path: str
property
Returns the path to the root directory.
This is where all configurations for MLflow deployment daemon processes are stored.
If the service path is not set in the config by the user, the path is set to a local default path according to the component ID.
Returns:
Type | Description |
---|---|
str
|
The path to the local service root directory. |
get_model_server_info(service_instance: MLFlowDeploymentService) -> Dict[str, Optional[str]]
staticmethod
Return implementation specific information relevant to the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_instance
|
MLFlowDeploymentService
|
Instance of a SeldonDeploymentService |
required |
Returns:
Type | Description |
---|---|
Dict[str, Optional[str]]
|
A dictionary containing the information. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
get_service_path(id_: UUID) -> str
staticmethod
Get the path where local MLflow service information is stored.
This includes the deployment service configuration, PID and log files are stored.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id_
|
UUID
|
The ID of the MLflow model deployer. |
required |
Returns:
Type | Description |
---|---|
str
|
The service path. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
perform_delete_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT, force: bool = False) -> None
Method to delete all configuration of a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to delete. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
force
|
bool
|
If True, force the service to stop. |
False
|
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
perform_deploy_model(id: UUID, config: ServiceConfig, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> BaseService
Create a new MLflow deployment service or update an existing one.
This should serve the supplied model and deployment configuration.
This method has two modes of operation, depending on the replace
argument value:
-
if
replace
is False, calling this method will create a new MLflow deployment server to reflect the model and other configuration parameters specified in the supplied MLflow serviceconfig
. -
if
replace
is True, this method will first attempt to find an existing MLflow deployment service that is equivalent to the supplied configuration parameters. Two or more MLflow deployment services are considered equivalent if they have the samepipeline_name
,pipeline_step_name
andmodel_name
configuration parameters. To put it differently, two MLflow deployment services are equivalent if they serve versions of the same model deployed by the same pipeline step. If an equivalent MLflow deployment is found, it will be updated in place to reflect the new configuration parameters.
Callers should set replace
to True if they want a continuous model
deployment workflow that doesn't spin up a new MLflow deployment
server for each new model version. If multiple equivalent MLflow
deployment servers are found, one is selected at random to be updated
and the others are deleted.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
UUID
|
the ID of the MLflow deployment service to be created or updated. |
required |
config
|
ServiceConfig
|
the configuration of the model to be deployed with MLflow. |
required |
timeout
|
int
|
the timeout in seconds to wait for the MLflow server to be provisioned and successfully started or updated. If set to 0, the method will return immediately after the MLflow server is provisioned, without waiting for it to fully start. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
BaseService
|
The ZenML MLflow deployment service object that can be used to |
BaseService
|
interact with the MLflow model server. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
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 |
|
perform_start_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> BaseService
Method to start a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to start. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to start. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
BaseService
|
The service that was started. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
perform_stop_model(service: BaseService, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT, force: bool = False) -> BaseService
Method to stop a model server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service
|
BaseService
|
The service to stop. |
required |
timeout
|
int
|
Timeout in seconds to wait for the service to stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
force
|
bool
|
If True, force the service to stop. |
False
|
Returns:
Type | Description |
---|---|
BaseService
|
The service that was stopped. |
Source code in src/zenml/integrations/mlflow/model_deployers/mlflow_model_deployer.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
model_registries
Initialization of the MLflow model registry.
Classes
MLFlowModelRegistry(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseModelRegistry
Register models using MLflow.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
config: MLFlowModelRegistryConfig
property
Returns the MLFlowModelRegistryConfig
config.
Returns:
Type | Description |
---|---|
MLFlowModelRegistryConfig
|
The configuration. |
mlflow_client: MlflowClient
property
Get the MLflow client.
Returns:
Type | Description |
---|---|
MlflowClient
|
The MLFlowClient. |
validator: Optional[StackValidator]
property
Validates that the stack contains an mlflow experiment tracker.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
A StackValidator instance. |
configure_mlflow() -> None
Configures the MLflow Client with the experiment tracker config.
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
111 112 113 114 115 |
|
delete_model(name: str) -> None
Delete a model from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model does not exist. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
delete_model_version(name: str, version: str) -> None
Delete a model version from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to delete the model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
get_model(name: str) -> RegisteredModel
Get a model from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The model. |
Raises:
Type | Description |
---|---|
KeyError
|
If mlflow fails to get the model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
get_model_uri_artifact_store(model_version: RegistryModelVersion) -> str
Get the model URI artifact store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_version
|
RegistryModelVersion
|
The model version. |
required |
Returns:
Type | Description |
---|---|
str
|
The model URI artifact store. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
|
get_model_version(name: str, version: str) -> RegistryModelVersion
Get a model version from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
list_model_versions(name: Optional[str] = None, model_source_uri: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, stage: Optional[ModelVersionStage] = None, count: Optional[int] = None, created_after: Optional[datetime] = None, created_before: Optional[datetime] = None, order_by_date: Optional[str] = None, **kwargs: Any) -> List[RegistryModelVersion]
List model versions from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the model. |
None
|
model_source_uri
|
Optional[str]
|
The model source URI. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The metadata of the model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
count
|
Optional[int]
|
The maximum number of model versions to return. |
None
|
created_after
|
Optional[datetime]
|
The minimum creation time of the model versions. |
None
|
created_before
|
Optional[datetime]
|
The maximum creation time of the model versions. |
None
|
order_by_date
|
Optional[str]
|
The order of the model versions by creation time, either ascending or descending. |
None
|
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
List[RegistryModelVersion]
|
The model versions. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
|
list_models(name: Optional[str] = None, metadata: Optional[Dict[str, str]] = None) -> List[RegisteredModel]
List models in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
A name to filter the models by. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata to filter the models by. |
None
|
Returns:
Type | Description |
---|---|
List[RegisteredModel]
|
A list of models (RegisteredModel) |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
load_model_version(name: str, version: str, **kwargs: Any) -> Any
Load a model version from the MLflow model registry.
This method loads the model version from the MLflow model registry
and returns the model. The model is loaded using the mlflow.pyfunc
module which takes care of loading the model from the model source
URI for the right framework.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The model version. |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
|
register_model(name: str, description: Optional[str] = None, metadata: Optional[Dict[str, str]] = None) -> RegisteredModel
Register a model to the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
description
|
Optional[str]
|
The description of the model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata of the model. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model already exists. |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The registered model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
register_model_version(name: str, version: Optional[str] = None, model_source_uri: Optional[str] = None, description: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, **kwargs: Any) -> RegistryModelVersion
Register a model version to the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
model_source_uri
|
Optional[str]
|
The source URI of the model. |
None
|
version
|
Optional[str]
|
The version of the model. |
None
|
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The registry metadata of the model version. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the registered model does not exist. |
ValueError
|
If no model source URI was provided. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The registered model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
update_model(name: str, description: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, remove_metadata: Optional[List[str]] = None) -> RegisteredModel
Update a model in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
description
|
Optional[str]
|
The description of the model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata of the model. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the model. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to update the model. |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The updated model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
update_model_version(name: str, version: str, description: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, remove_metadata: Optional[List[str]] = None, stage: Optional[ModelVersionStage] = None) -> RegistryModelVersion
Update a model version in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The metadata of the model version. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to update the model version. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The updated model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
Modules
mlflow_model_registry
Implementation of the MLflow model registry for ZenML.
MLFlowModelRegistry(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseModelRegistry
Register models using MLflow.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
config: MLFlowModelRegistryConfig
property
Returns the MLFlowModelRegistryConfig
config.
Returns:
Type | Description |
---|---|
MLFlowModelRegistryConfig
|
The configuration. |
mlflow_client: MlflowClient
property
Get the MLflow client.
Returns:
Type | Description |
---|---|
MlflowClient
|
The MLFlowClient. |
validator: Optional[StackValidator]
property
Validates that the stack contains an mlflow experiment tracker.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
A StackValidator instance. |
configure_mlflow() -> None
Configures the MLflow Client with the experiment tracker config.
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
111 112 113 114 115 |
|
delete_model(name: str) -> None
Delete a model from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model does not exist. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
delete_model_version(name: str, version: str) -> None
Delete a model version from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to delete the model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
get_model(name: str) -> RegisteredModel
Get a model from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The model. |
Raises:
Type | Description |
---|---|
KeyError
|
If mlflow fails to get the model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|
get_model_uri_artifact_store(model_version: RegistryModelVersion) -> str
Get the model URI artifact store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_version
|
RegistryModelVersion
|
The model version. |
required |
Returns:
Type | Description |
---|---|
str
|
The model URI artifact store. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 |
|
get_model_version(name: str, version: str) -> RegistryModelVersion
Get a model version from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
list_model_versions(name: Optional[str] = None, model_source_uri: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, stage: Optional[ModelVersionStage] = None, count: Optional[int] = None, created_after: Optional[datetime] = None, created_before: Optional[datetime] = None, order_by_date: Optional[str] = None, **kwargs: Any) -> List[RegistryModelVersion]
List model versions from the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
The name of the model. |
None
|
model_source_uri
|
Optional[str]
|
The model source URI. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The metadata of the model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
count
|
Optional[int]
|
The maximum number of model versions to return. |
None
|
created_after
|
Optional[datetime]
|
The minimum creation time of the model versions. |
None
|
created_before
|
Optional[datetime]
|
The maximum creation time of the model versions. |
None
|
order_by_date
|
Optional[str]
|
The order of the model versions by creation time, either ascending or descending. |
None
|
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
List[RegistryModelVersion]
|
The model versions. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
|
list_models(name: Optional[str] = None, metadata: Optional[Dict[str, str]] = None) -> List[RegisteredModel]
List models in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
Optional[str]
|
A name to filter the models by. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata to filter the models by. |
None
|
Returns:
Type | Description |
---|---|
List[RegisteredModel]
|
A list of models (RegisteredModel) |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
load_model_version(name: str, version: str, **kwargs: Any) -> Any
Load a model version from the MLflow model registry.
This method loads the model version from the MLflow model registry
and returns the model. The model is loaded using the mlflow.pyfunc
module which takes care of loading the model from the model source
URI for the right framework.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The model version. |
Raises:
Type | Description |
---|---|
KeyError
|
If the model version does not exist. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
|
register_model(name: str, description: Optional[str] = None, metadata: Optional[Dict[str, str]] = None) -> RegisteredModel
Register a model to the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
description
|
Optional[str]
|
The description of the model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata of the model. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the model already exists. |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The registered model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
register_model_version(name: str, version: Optional[str] = None, model_source_uri: Optional[str] = None, description: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, **kwargs: Any) -> RegistryModelVersion
Register a model version to the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
model_source_uri
|
Optional[str]
|
The source URI of the model. |
None
|
version
|
Optional[str]
|
The version of the model. |
None
|
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The registry metadata of the model version. |
None
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the registered model does not exist. |
ValueError
|
If no model source URI was provided. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The registered model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
update_model(name: str, description: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, remove_metadata: Optional[List[str]] = None) -> RegisteredModel
Update a model in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
description
|
Optional[str]
|
The description of the model. |
None
|
metadata
|
Optional[Dict[str, str]]
|
The metadata of the model. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the model. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to update the model. |
Returns:
Type | Description |
---|---|
RegisteredModel
|
The updated model. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
update_model_version(name: str, version: str, description: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None, remove_metadata: Optional[List[str]] = None, stage: Optional[ModelVersionStage] = None) -> RegistryModelVersion
Update a model version in the MLflow model registry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the model. |
required |
version
|
str
|
The version of the model. |
required |
description
|
Optional[str]
|
The description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
The metadata of the model version. |
None
|
remove_metadata
|
Optional[List[str]]
|
The metadata to remove from the model version. |
None
|
stage
|
Optional[ModelVersionStage]
|
The stage of the model version. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If mlflow fails to update the model version. |
Returns:
Type | Description |
---|---|
RegistryModelVersion
|
The updated model version. |
Source code in src/zenml/integrations/mlflow/model_registries/mlflow_model_registry.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
services
Initialization of the MLflow Service.
Classes
Modules
mlflow_deployment
Implementation of the MLflow deployment functionality.
MLFlowDeploymentConfig(**data: Any)
Bases: LocalDaemonServiceConfig
MLflow model deployment configuration.
Attributes:
Name | Type | Description |
---|---|---|
model_uri |
str
|
URI of the MLflow model to serve |
model_name |
str
|
the name of the model |
workers |
int
|
number of workers to use for the prediction service |
registry_model_name |
Optional[str]
|
the name of the model in the registry |
registry_model_version |
Optional[str]
|
the version of the model in the registry |
mlserver |
bool
|
set to True to use the MLflow MLServer backend (see https://github.com/SeldonIO/MLServer). If False, the MLflow built-in scoring server will be used. |
timeout |
int
|
timeout in seconds for starting and stopping the service |
Source code in src/zenml/services/service.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
validate_mlserver_python_version(mlserver: bool) -> bool
classmethod
Validates the Python version if mlserver is used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mlserver
|
bool
|
set to True if the MLflow MLServer backend is used, else set to False and MLflow built-in scoring server will be used. |
required |
Returns:
Type | Description |
---|---|
bool
|
the validated value |
Raises:
Type | Description |
---|---|
ValueError
|
if mlserver packages are not installed |
Source code in src/zenml/integrations/mlflow/services/mlflow_deployment.py
116 117 118 119 120 121 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 |
|
MLFlowDeploymentEndpoint(*args: Any, **kwargs: Any)
Bases: LocalDaemonServiceEndpoint
A service endpoint exposed by the MLflow deployment daemon.
Attributes:
Name | Type | Description |
---|---|---|
config |
MLFlowDeploymentEndpointConfig
|
service endpoint configuration |
monitor |
HTTPEndpointHealthMonitor
|
optional service endpoint health monitor |
Source code in src/zenml/services/service_endpoint.py
111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
prediction_url: Optional[str]
property
Gets the prediction URL for the endpoint.
Returns:
Type | Description |
---|---|
Optional[str]
|
the prediction URL for the endpoint |
MLFlowDeploymentEndpointConfig
Bases: LocalDaemonServiceEndpointConfig
MLflow daemon service endpoint configuration.
Attributes:
Name | Type | Description |
---|---|---|
prediction_url_path |
str
|
URI subpath for prediction requests |
MLFlowDeploymentService(config: Union[MLFlowDeploymentConfig, Dict[str, Any]], **attrs: Any)
Bases: LocalDaemonService
, BaseDeploymentService
MLflow deployment service used to start a local prediction server for MLflow models.
Attributes:
Name | Type | Description |
---|---|---|
SERVICE_TYPE |
a service type descriptor with information describing the MLflow deployment service class |
|
config |
MLFlowDeploymentConfig
|
service configuration |
endpoint |
MLFlowDeploymentEndpoint
|
optional service endpoint |
Initialize the MLflow deployment service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
Union[MLFlowDeploymentConfig, Dict[str, Any]]
|
service configuration |
required |
attrs
|
Any
|
additional attributes to set on the service |
{}
|
Source code in src/zenml/integrations/mlflow/services/mlflow_deployment.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
prediction_url: Optional[str]
property
Get the URI where the prediction service is answering requests.
Returns:
Type | Description |
---|---|
Optional[str]
|
The URI where the prediction service can be contacted to process |
Optional[str]
|
HTTP/REST inference requests, or None, if the service isn't running. |
predict(request: Union[NDArray[Any], pd.DataFrame]) -> NDArray[Any]
Make a prediction using the service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request
|
Union[NDArray[Any], DataFrame]
|
a Numpy Array or Pandas DataFrame representing the request |
required |
Returns:
Type | Description |
---|---|
NDArray[Any]
|
A numpy array representing the prediction returned by the service. |
Raises:
Type | Description |
---|---|
Exception
|
if the service is not running |
ValueError
|
if the prediction endpoint is unknown. |
Source code in src/zenml/integrations/mlflow/services/mlflow_deployment.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
|
run() -> None
Start the service.
Raises:
Type | Description |
---|---|
ValueError
|
if the active stack doesn't have an MLflow experiment tracker |
Source code in src/zenml/integrations/mlflow/services/mlflow_deployment.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
steps
Initialization of the MLflow standard interface steps.
Functions
Modules
mlflow_deployer
Implementation of the MLflow model deployer pipeline step.
mlflow_model_deployer_step(model: UnmaterializedArtifact, deploy_decision: bool = True, experiment_name: Optional[str] = None, run_name: Optional[str] = None, model_name: str = 'model', workers: int = 1, mlserver: bool = False, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> Optional[MLFlowDeploymentService]
Model deployer pipeline step for MLflow.
This step deploys a model logged in the MLflow artifact store to a
deployment service. The user would typically use this step in a pipeline
that deploys a model that was already registered in the MLflow model
registr either manually or by using the mlflow_model_registry_step
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deploy_decision
|
bool
|
whether to deploy the model or not |
True
|
model
|
UnmaterializedArtifact
|
the model artifact to deploy |
required |
experiment_name
|
Optional[str]
|
Name of the MLflow experiment in which the model was logged. |
None
|
run_name
|
Optional[str]
|
Name of the MLflow run in which the model was logged. |
None
|
model_name
|
str
|
the name of the MLflow model logged in the MLflow artifact store for the current pipeline. |
'model'
|
workers
|
int
|
number of workers to use for the prediction service |
1
|
mlserver
|
bool
|
set to True to use the MLflow MLServer backend (see https://github.com/SeldonIO/MLServer). If False, the MLflow built-in scoring server will be used. |
False
|
timeout
|
int
|
the number of seconds to wait for the service to start/stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
Optional[MLFlowDeploymentService]
|
MLflow deployment service or None if no service was deployed or found |
Raises:
Type | Description |
---|---|
ValueError
|
if the MLflow experiment tracker is not found |
Source code in src/zenml/integrations/mlflow/steps/mlflow_deployer.py
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 120 121 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 |
|
mlflow_model_registry_deployer_step(registry_model_name: str, registry_model_version: Optional[str] = None, registry_model_stage: Optional[ModelVersionStage] = None, replace_existing: bool = True, model_name: str = 'model', workers: int = 1, mlserver: bool = False, timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT) -> MLFlowDeploymentService
Model deployer pipeline step for MLflow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
registry_model_name
|
str
|
the name of the model in the model registry |
required |
registry_model_version
|
Optional[str]
|
the version of the model in the model registry |
None
|
registry_model_stage
|
Optional[ModelVersionStage]
|
the stage of the model in the model registry |
None
|
replace_existing
|
bool
|
Whether to create a new deployment service or not |
True
|
model_name
|
str
|
the name of the MLflow model logged in the MLflow artifact store for the current pipeline. |
'model'
|
workers
|
int
|
number of workers to use for the prediction service |
1
|
mlserver
|
bool
|
set to True to use the MLflow MLServer backend (see https://github.com/SeldonIO/MLServer). If False, the MLflow built-in scoring server will be used. |
False
|
timeout
|
int
|
the number of seconds to wait for the service to start/stop. |
DEFAULT_SERVICE_START_STOP_TIMEOUT
|
Returns:
Type | Description |
---|---|
MLFlowDeploymentService
|
MLflow deployment service |
Raises:
Type | Description |
---|---|
ValueError
|
if neither registry_model_version nor registry_model_stage is not provided |
ValueError
|
if No MLflow experiment tracker is found in the current active stack |
LookupError
|
if no model version is found in the MLflow model registry. |
Source code in src/zenml/integrations/mlflow/steps/mlflow_deployer.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
mlflow_registry
Implementation of the MLflow model registration pipeline step.
mlflow_register_model_step(model: UnmaterializedArtifact, name: str, version: Optional[str] = None, trained_model_name: Optional[str] = 'model', model_source_uri: Optional[str] = None, experiment_name: Optional[str] = None, run_name: Optional[str] = None, run_id: Optional[str] = None, description: Optional[str] = None, metadata: Optional[ModelRegistryModelMetadata] = None) -> None
MLflow model registry step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
UnmaterializedArtifact
|
Model to be registered, This is not used in the step, but is required to trigger the step when the model is trained. |
required |
name
|
str
|
The name of the model. |
required |
version
|
Optional[str]
|
The version of the model. |
None
|
trained_model_name
|
Optional[str]
|
Name of the model artifact in MLflow. |
'model'
|
model_source_uri
|
Optional[str]
|
The path to the model. If not provided, the model will
be fetched from the MLflow tracking server via the
|
None
|
experiment_name
|
Optional[str]
|
Name of the experiment to be used for the run. |
None
|
run_name
|
Optional[str]
|
Name of the run to be created. |
None
|
run_id
|
Optional[str]
|
ID of the run to be used. |
None
|
description
|
Optional[str]
|
A description of the model version. |
None
|
metadata
|
Optional[ModelRegistryModelMetadata]
|
A list of metadata to associate with the model version |
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If the model registry is not an MLflow model registry. |
ValueError
|
If the experiment tracker is not an MLflow experiment tracker. |
RuntimeError
|
If no model source URI is provided and no model is found. |
RuntimeError
|
If no run ID is provided and no run is found. |
Source code in src/zenml/integrations/mlflow/steps/mlflow_registry.py
37 38 39 40 41 42 43 44 45 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 120 121 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 |
|