Orchestrators
Initialization for ZenML orchestrators.
An orchestrator is a special kind of backend that manages the running of each step of the pipeline. Orchestrators administer the actual pipeline runs. You can think of it as the 'root' of any pipeline job that you run during your experimentation.
ZenML supports a local orchestrator out of the box which allows you to run your pipelines in a local environment. We also support using Apache Airflow as the orchestrator to handle the steps of your pipeline.
BaseOrchestrator
Bases: StackComponent
, ABC
Base class for all orchestrators.
In order to implement an orchestrator you will need to subclass from this class.
How it works:
The run(...)
method is the entrypoint that is executed when the
pipeline's run method is called within the user code
(pipeline_instance.run(...)
).
This method will do some internal preparation and then call the
prepare_or_run_pipeline(...)
method. BaseOrchestrator subclasses must
implement this method and either run the pipeline steps directly or deploy
the pipeline to some remote infrastructure.
Source code in src/zenml/orchestrators/base_orchestrator.py
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 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 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 323 324 325 326 327 328 329 |
|
config
property
Returns the BaseOrchestratorConfig
config.
Returns:
Type | Description |
---|---|
BaseOrchestratorConfig
|
The configuration. |
fetch_status(run)
Refreshes the status of a specific pipeline run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run
|
PipelineRunResponse
|
A pipeline run response to fetch its status. |
required |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If any orchestrator inheriting from the base class does not implement this logic. |
Source code in src/zenml/orchestrators/base_orchestrator.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
|
get_orchestrator_run_id()
abstractmethod
Returns the run id of the active orchestrator run.
Important: This needs to be a unique ID and return the same value for all steps of a pipeline run.
Returns:
Type | Description |
---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/orchestrators/base_orchestrator.py
126 127 128 129 130 131 132 133 134 135 |
|
prepare_or_run_pipeline(deployment, stack, environment)
abstractmethod
The method needs to be implemented by the respective orchestrator.
Depending on the type of orchestrator you'll have to perform slightly different operations.
Simple Case:
The Steps are run directly from within the same environment in which
the orchestrator code is executed. In this case you will need to
deal with implementation-specific runtime configurations (like the
schedule) and then iterate through the steps and finally call
self.run_step(...)
to execute each step.
Advanced Case:
Most orchestrators will not run the steps directly. Instead, they build some intermediate representation of the pipeline that is then used to create and run the pipeline and its steps on the target environment. For such orchestrators this method will have to build this representation and deploy it.
Regardless of the implementation details, the orchestrator will need
to run each step in the target environment. For this the
self.run_step(...)
method should be used.
The easiest way to make this work is by using an entrypoint
configuration to run single steps (zenml.entrypoints.step_entrypoint_configuration.StepEntrypointConfiguration
)
or entire pipelines (zenml.entrypoints.pipeline_entrypoint_configuration.PipelineEntrypointConfiguration
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentResponse
|
The pipeline deployment to prepare or run. |
required |
stack
|
Stack
|
The stack the pipeline will run on. |
required |
environment
|
Dict[str, str]
|
Environment variables to set in the orchestration environment. These don't need to be set if running locally. |
required |
Yields:
Type | Description |
---|---|
Optional[Iterator[Dict[str, MetadataType]]]
|
Metadata for the pipeline run. |
Source code in src/zenml/orchestrators/base_orchestrator.py
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 |
|
requires_resources_in_orchestration_environment(step)
staticmethod
Checks if the orchestrator should run this step on special resources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step
|
Step
|
The step that will be checked. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the step requires special resources in the orchestration |
bool
|
environment, False otherwise. |
Source code in src/zenml/orchestrators/base_orchestrator.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
run(deployment, stack, placeholder_run=None)
Runs a pipeline on a stack.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentResponse
|
The pipeline deployment. |
required |
stack
|
Stack
|
The stack on which to run the pipeline. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the deployment. This will be deleted in case the pipeline deployment failed. |
None
|
Source code in src/zenml/orchestrators/base_orchestrator.py
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 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 |
|
run_step(step)
Runs the given step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step
|
Step
|
The step to run. |
required |
Source code in src/zenml/orchestrators/base_orchestrator.py
269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
BaseOrchestratorConfig
Bases: StackComponentConfig
Base orchestrator config.
Source code in src/zenml/orchestrators/base_orchestrator.py
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 |
|
is_schedulable
property
Whether the orchestrator is schedulable or not.
Returns:
Type | Description |
---|---|
bool
|
Whether the orchestrator is schedulable or not. |
is_synchronous
property
Whether the orchestrator runs synchronous or not.
Returns:
Type | Description |
---|---|
bool
|
Whether the orchestrator runs synchronous or not. |
supports_client_side_caching
property
Whether the orchestrator supports client side caching.
Returns:
Type | Description |
---|---|
bool
|
Whether the orchestrator supports client side caching. |
BaseOrchestratorFlavor
Bases: Flavor
Base orchestrator flavor class.
Source code in src/zenml/orchestrators/base_orchestrator.py
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 |
|
config_class
property
Config class for the base orchestrator flavor.
Returns:
Type | Description |
---|---|
Type[BaseOrchestratorConfig]
|
The config class. |
implementation_class
abstractmethod
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[BaseOrchestrator]
|
The implementation class. |
type
property
ContainerizedOrchestrator
Bases: BaseOrchestrator
, ABC
Base class for containerized orchestrators.
Source code in src/zenml/orchestrators/containerized_orchestrator.py
25 26 27 28 29 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 90 |
|
get_docker_builds(deployment)
Gets the Docker builds required for the component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentBase
|
The pipeline deployment for which to get the builds. |
required |
Returns:
Type | Description |
---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/orchestrators/containerized_orchestrator.py
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 |
|
get_image(deployment, step_name=None)
staticmethod
Gets the Docker image for the pipeline/a step.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentResponse
|
The deployment from which to get the image. |
required |
step_name
|
Optional[str]
|
Pipeline step name for which to get the image. If not given the generic pipeline image will be returned. |
None
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If the deployment does not have an associated build. |
Returns:
Type | Description |
---|---|
str
|
The image name or digest. |
Source code in src/zenml/orchestrators/containerized_orchestrator.py
28 29 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 |
|
LocalDockerOrchestrator
Bases: ContainerizedOrchestrator
Orchestrator responsible for running pipelines locally using Docker.
This orchestrator does not allow for concurrent execution of steps and also does not support running on a schedule.
Source code in src/zenml/orchestrators/local_docker/local_docker_orchestrator.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 189 190 191 192 193 194 |
|
settings_class
property
Settings class for the Local Docker orchestrator.
Returns:
Type | Description |
---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator
property
Ensures there is an image builder in the stack.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
A |
get_orchestrator_run_id()
Returns the active orchestrator run id.
Raises:
Type | Description |
---|---|
RuntimeError
|
If the environment variable specifying the run id is not set. |
Returns:
Type | Description |
---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/orchestrators/local_docker/local_docker_orchestrator.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
prepare_or_run_pipeline(deployment, stack, environment)
Sequentially runs all pipeline steps in local Docker containers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentResponse
|
The pipeline deployment to prepare or run. |
required |
stack
|
Stack
|
The stack the pipeline will run on. |
required |
environment
|
Dict[str, str]
|
Environment variables to set in the orchestration environment. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If a step fails. |
Source code in src/zenml/orchestrators/local_docker/local_docker_orchestrator.py
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 189 190 191 192 193 194 |
|
LocalDockerOrchestratorFlavor
Bases: BaseOrchestratorFlavor
Flavor for the local Docker orchestrator.
Source code in src/zenml/orchestrators/local_docker/local_docker_orchestrator.py
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 |
|
config_class
property
Config class for the base orchestrator flavor.
Returns:
Type | Description |
---|---|
Type[BaseOrchestratorConfig]
|
The config class. |
docs_url
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[LocalDockerOrchestrator]
|
Implementation class for this flavor. |
logo_url
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name
property
Name of the orchestrator flavor.
Returns:
Type | Description |
---|---|
str
|
Name of the orchestrator flavor. |
sdk_docs_url
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
LocalOrchestrator
Bases: BaseOrchestrator
Orchestrator responsible for running pipelines locally.
This orchestrator does not allow for concurrent execution of steps and also does not support running on a schedule.
Source code in src/zenml/orchestrators/local/local_orchestrator.py
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 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_orchestrator_run_id()
Returns the active orchestrator run id.
Raises:
Type | Description |
---|---|
RuntimeError
|
If no run id exists. This happens when this method gets called while the orchestrator is not running a pipeline. |
Returns:
Type | Description |
---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/orchestrators/local/local_orchestrator.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
prepare_or_run_pipeline(deployment, stack, environment)
Iterates through all steps and executes them sequentially.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
PipelineDeploymentResponse
|
The pipeline deployment to prepare or run. |
required |
stack
|
Stack
|
The stack on which the pipeline is deployed. |
required |
environment
|
Dict[str, str]
|
Environment variables to set in the orchestration environment. |
required |
Source code in src/zenml/orchestrators/local/local_orchestrator.py
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 |
|
LocalOrchestratorFlavor
Bases: BaseOrchestratorFlavor
Class for the LocalOrchestratorFlavor
.
Source code in src/zenml/orchestrators/local/local_orchestrator.py
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 |
|
config_class
property
Config class for the base orchestrator flavor.
Returns:
Type | Description |
---|---|
Type[BaseOrchestratorConfig]
|
The config class. |
docs_url
property
A URL to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[LocalOrchestrator]
|
The implementation class for this flavor. |
logo_url
property
A URL to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name
property
The flavor name.
Returns:
Type | Description |
---|---|
str
|
The flavor name. |
sdk_docs_url
property
A URL to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
WheeledOrchestrator
Bases: BaseOrchestrator
, ABC
Base class for wheeled orchestrators.
Source code in src/zenml/orchestrators/wheeled_orchestrator.py
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 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 |
|
copy_repository_to_temp_dir_and_add_setup_py()
Copy the repository to a temporary directory and add a setup.py file.
Returns:
Type | Description |
---|---|
str
|
Path to the temporary directory containing the copied repository. |
Source code in src/zenml/orchestrators/wheeled_orchestrator.py
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 |
|
create_wheel(temp_dir)
Create a wheel for the package in the given temporary directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temp_dir
|
str
|
Path to the temporary directory containing the package. |
required |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the wheel file could not be created. |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to the created wheel file. |
Source code in src/zenml/orchestrators/wheeled_orchestrator.py
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 |
|
sanitize_name(name)
Sanitize the value to be used in a cluster name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Arbitrary input cluster name. |
required |
Returns:
Type | Description |
---|---|
str
|
Sanitized cluster name. |
Source code in src/zenml/orchestrators/wheeled_orchestrator.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|