thousands-car-79657
06/26/2024, 7:02 PMancient-wolf-19325
06/26/2024, 7:02 PMpyflyte run --env
command. This allows you to set environment variables when executing the launch plan.
1. Define the Launch Plan: Create a launch plan with a cron schedule.
2. Set Environment Variables: Use pyflyte run --env
to pass the environment variables during execution.
Example:
from flytekit import LaunchPlan, CronSchedule, task, workflow
@task
def my_task() -> str:
import os
return os.getenv("MY_ENV_VAR", "default_value")
@workflow
def my_workflow() -> str:
return my_task()
cron_lp = LaunchPlan.get_or_create(
name="my_cron_lp",
workflow=my_workflow,
schedule=CronSchedule(schedule="0 */6 * * *"), # Every 6 hours
)
# Run the launch plan with environment variables
# pyflyte run --env MY_ENV_VAR=my_value my_module.py my_workflow
For more details, refer to Flyte discussion on setting environment variables.
Would you like more detail?
Sources:
- Flyte discussion on setting environment variables
- Flyte discussion on passing custom environment variables 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.freezing-airport-6809
thousands-car-79657
07/09/2024, 4:07 PM