Abuzar Shakikh
06/13/2024, 11:16 AMPrefectDeprecationWarning: prefect.infrastructure.process.Process has been deprecated. It will not be available after Sep 2024. Use the process worker instead. Refer to the upgrade guide for more information: <https://docs.prefect.io/latest/guides/upgrade-guide-agents-to-workers/>
What should I change in my deployment below so that the warning goes away
Deployment.build_from_flow(
flow=bhavcopy_flow,
name=f"{project_name}-{current_file}-{segment}",
version="1",
tags=[project_name],
parameters={"segment": segment},
work_pool_name="local-pool",
work_queue_name="local-queue",
schedules=[cron],
infrastructure=Process(
working_dir=f"/home/{os.environ.get('USER')}/miniflows/"
),
)
Marvin
06/13/2024, 11:16 AMprefect.infrastructure.process.Process
. You should leverage the process worker infrastructure instead. Below is your modified deployment code:
python
from prefect.deployments import Deployment
from prefect.infrastructure import ProcessWorker # Import the ProcessWorker class
Deployment.build_from_flow(
flow=bhavcopy_flow,
name=f"{project_name}-{current_file}-{segment}",
version="1",
tags=[project_name],
parameters={"segment": segment},
work_pool_name="local-pool",
work_queue_name="local-queue",
schedules=[cron],
infrastructure=ProcessWorker(
working_dir=f"/home/{os.environ.get('USER')}/miniflows/"
),
)
Make sure you have the ProcessWorker
class correctly imported and utilized in the deployment configuration.
For further details, you can refer to the Prefect Upgrade Guide.Abuzar Shakikh
06/13/2024, 4:43 PMMarvin
06/13/2024, 4:44 PMjob_variables
section in your deployment YAML or add an env
configuration directly in your deployment code.
2. Use ProcessWorker
and Pass Environment Variables:
Below is an updated version of your deployment code that specifies environment variables within the deployment configuration:
python
from prefect.deployments import Deployment
from prefect.infrastructure import ProcessWorker # Import the ProcessWorker class
Deployment.build_from_flow(
flow=bhavcopy_flow,
name=f"{project_name}-{current_file}-{segment}",
version="1",
tags=[project_name],
parameters={"segment": segment},
work_pool_name="local-pool",
work_queue_name="local-queue",
schedules=[cron],
infrastructure=ProcessWorker(
env={
"USER": os.environ.get("USER") # Add your required environment variables here
},
working_dir=f"/home/{os.environ.get('USER')}/miniflows/"
),
)
3. Check Work Pool and Work Queue Configuration:
Depending on how your work pool and queue are configured, you might need to set environment variables there as well.
4. Ensure Correct Override Mechanism:
Refer to the deployment guide to ensure correct override mechanisms are used for job variables. See the Overriding Job Variables guide for more details.
### Relevant Issues from GitHub
You might find useful insights or workarounds regarding this in relevant GitHub issues:
- Job variables should use a deep merge rather than shallow merge of dictionaries
- build_from_flow docstring is wrong for ENV and infra_overrides are not validated
- There is no way to pass secrets to ECSTask
Implementing these changes should help ensure that your environment variables are picked up during flow deployment.Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by