gentle-scientist-22504
10/03/2024, 2:48 PMjolly-florist-66728
10/03/2024, 2:48 PMargparse
with a pyflyte
script, you need to modify your script to handle command-line arguments. However, it's recommended to use pyflyte run
for running workflows as it simplifies the process. Here's how you can do it:
1. Modify your script to use argparse
:
Add an argparse
block to handle command-line arguments.
2. Run the script using pyflyte run
:
Use pyflyte run
to execute the script with the specified arguments.
Example:
import argparse
from flytekit import task, workflow
@task
def my_task(name: str) -> str:
return f"Hello, {name}!"
@workflow
def my_workflow(name: str) -> str:
return my_task(name=name)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run Flyte workflow")
parser.add_argument("--name", type=str, required=True, help="Name to greet")
args = parser.parse_args()
print(my_workflow(name=args.name))
Run the script with `pyflyte run`:
pyflyte run my_script.py my_workflow --name "Flyte"
Would you like more detail?
Sources:
- Running a workflow locally 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.freezing-airport-6809
freezing-airport-6809