|
| 1 | +--- |
| 2 | +description: Deploying pipelines on your local machine as background processes. |
| 3 | +--- |
| 4 | + |
| 5 | +# Local Deployer |
| 6 | + |
| 7 | +The local deployer is a [deployer](./) flavor that comes built-in with ZenML and deploys pipelines on your local machine as background processes. |
| 8 | + |
| 9 | +### When to use it |
| 10 | + |
| 11 | +The local deployer is part of your default stack when you're first getting started with ZenML. Due to it running locally on your machine, it requires no additional setup and is easy to use and debug. |
| 12 | + |
| 13 | +You should use the local deployer if: |
| 14 | + |
| 15 | +* you're just getting started with ZenML and want to deploy pipelines without setting up any cloud infrastructure. |
| 16 | +* you're writing a new pipeline and want to experiment and debug quickly |
| 17 | + |
| 18 | +### How to deploy it |
| 19 | + |
| 20 | +The local deployer comes with ZenML and works without any additional setup. |
| 21 | + |
| 22 | +### How to use it |
| 23 | + |
| 24 | +To use the local deployer, you can register it and use it in your active stack: |
| 25 | + |
| 26 | +```shell |
| 27 | +zenml deployer register <DEPLOYER_NAME> --flavor=local |
| 28 | + |
| 29 | +# Register and activate a stack with the new deployer |
| 30 | +zenml stack register <STACK_NAME> -D <DEPLOYER_NAME> ... --set |
| 31 | +``` |
| 32 | + |
| 33 | +You can now [deploy any ZenML pipeline](https://docs.zenml.io/concepts/deployment) using the local deployer: |
| 34 | + |
| 35 | +```shell |
| 36 | +zenml pipeline deploy --name my_deployment my_module.my_pipeline |
| 37 | +``` |
| 38 | +### Additional configuration |
| 39 | + |
| 40 | +For additional configuration of the Local deployer, you can pass the following `LocalDeployerSettings` attributes defined in the `zenml.deployers.local.local_deployer` module when configuring the deployer or defining or deploying your pipeline: |
| 41 | + |
| 42 | +* Basic settings common to all Deployers: |
| 43 | + |
| 44 | + * `auth_key`: A user-defined authentication key to use to authenticate with deployment API calls. |
| 45 | + * `generate_auth_key`: Whether to generate and use a random authentication key instead of the user-defined one. |
| 46 | + * `lcm_timeout`: The maximum time in seconds to wait for the deployment lifecycle management to complete. |
| 47 | + |
| 48 | +* Settings specific to the Local deployer: |
| 49 | + |
| 50 | + * `port`: A custom port that the deployment server will listen on. Not set by default. |
| 51 | + * `allocate_port_if_busy`: If True, allocate a free port if the configured `port` is busy or not set. Defaults to True. |
| 52 | + * `port_range`: The range of ports to search for a free port. Defaults to `(8000, 65535)`. |
| 53 | + * `address`: The address that the deployment server will listen on. Defaults to `127.0.0.1`. |
| 54 | + * `blocking`: Whether to run the deployment in the current process instead of running it as a daemon process. Defaults to False. Use this if you want to debug issues with the deployment ASGI application itself. |
| 55 | + |
| 56 | +Check out [this docs page](https://docs.zenml.io/concepts/steps_and_pipelines/configuration) for more information on how to specify settings. |
| 57 | + |
| 58 | +For example, if you wanted to specify the port to use for the deployment, you would configure settings as follows: |
| 59 | + |
| 60 | +```python |
| 61 | +from zenml import step, pipeline |
| 62 | +from zenml.deployers.local.local_deployer import LocalDeployerSettings |
| 63 | + |
| 64 | + |
| 65 | +@step |
| 66 | +def greet(name: str) -> str: |
| 67 | + return f"Hello {name}!" |
| 68 | + |
| 69 | + |
| 70 | +settings = { |
| 71 | + "deployer": LocalDeployerSettings( |
| 72 | + port=8000 |
| 73 | + ) |
| 74 | +} |
| 75 | + |
| 76 | +@pipeline(settings=settings) |
| 77 | +def greet_pipeline(name: str = "John"): |
| 78 | + greet(name=name) |
| 79 | +``` |
0 commit comments