Oliver Tedder
12/09/2024, 12:34 PMflow.from_source
so that in the UI on the server it has a different name?Marvin
12/09/2024, 12:34 PMdeployment.yaml
file. Ensure this file specifies the desired flow deployment name.
In Prefect 3.x, the deployment name should be unique for each flow and is set through a configuration format similar to:
name: new-deployment-name
2. Create the Deployment: Utilize the prefect deployment build
or similar CLI commands to build and apply the deployment configuration. Prefect usually requires each deployment to have unique names for the flows to distinguish between them. Here’s an example on Prefect documentation.
3. Use Prefix: You can prefix the deployment name with the flow name if you have multiple deployments of the same flow to ensure uniqueness. This is detailed in Prefect 2.x documentation.
After updating the deployment, it will appear with the new name in the Prefect server UI.
I hope this solution helps, but if it doesn't seem right, Prefect might have undergone changes so double-check these settings as needed. Ah, the joys of versioning. Happy deploying!Oliver Tedder
12/09/2024, 12:35 PMMarvin
12/09/2024, 12:36 PMdeploy
method on a flow retrieved via flow.from_source
. Here's an example using Prefect 2.x:
python
from prefect import flow
from prefect.storage import GitHub
if __name__ == "__main__":
flow.from_source(
source=GitHub.load("demo-repo"),
entrypoint="example.py:my_flow"
).deploy(
name="my-deployment", # Set your desired deployment name here
work_pool_name="my-k8s-job",
job_variables=dict(pull_policy="Never"),
parameters=dict(name="Marvin"),
)
More details can be found here.
### In Prefect 3.x:
The approach is similar, using flow.deploy
to specify the deployment name. For Prefect 3.x, your Python script might look like this:
python
from prefect import flow
@flow(log_prints=True)
def my_flow(name: str = "world"):
print(f"Hello {name}! I'm a flow!")
if __name__ == "__main__":
my_flow.deploy(
name="my-new-deployment", # Set your desired deployment name here
work_pool_name="my-k8s-job",
job_variables=dict(pull_policy="Never"),
parameters=dict(name="Marvin"),
)
For more details, you can refer to the documentation here.
This should allow you to specify the deployment name directly in your Python script, enabling the desired name to appear in the Prefect UI. I hope this helps change your deployment name with minimal fuss!