Hi folks, was just looking at prefect example like...
# ask-community
s
Hi folks, was just looking at prefect example like this.. However, let's say instead of running the steps as python code, i have some cli commands.
Copy code
with Flow("NLP") as nlp_flow:
    aws s3 cp blah blah
    sometool /data/a.csv
Is it possible to add the steps as cli commands instead ?
k
Hey @st dabu, this can be done with the ShellTask . Sample usage like this:
Copy code
from prefect.utilities.tasks import task
from prefect import task, Flow
from prefect.tasks.shell import ShellTask
@task
def files():
    return [
        '/opt/file1.txt',
        '/opt/file2.txt',
        '/opt/file3.txt',
        '/opt/file4.txt',
    ]
@task
def format_commands(file_name):
    return f'echo "{file_name}"'
rm_task = ShellTask()
with Flow('shell') as flow:
    files_to_delete = files()
    commands = format_commands.map(files_to_delete)
    rm_task.map(command=commands)
flow.run()
1
s
thanks got it