Saad Anwar
09/12/2022, 7:37 PMZach
09/12/2022, 7:55 PMop
. So if you have a python script like this:
#script_to_call.py
def do_something(input_param):
#do the thing
if __name__ == '__main__':
do_something("here's an input")
you could call that same function from an op in a different module like this:
from script_to_call import do_something
from dagster import op, job
@op(config_schema={"input_param": str})
def do_something_op(context):
return do_something(context.op_config["input_param"])
@job
def do_something_job():
do_something_op()
then you can either call your job programmatically using
do_something_job.execute_in_process(run_config={"ops": {"do_something_op": {"config": {"input_param": "some-input"}}}})
or by adding your job to a repository
and spinning up a dagit UI instance to run it fromZach
09/12/2022, 7:57 PMfrom dagster_shell import create_shell_command_op
from dagster import graph
@graph
def my_graph():
a = create_shell_command_op('python script_to_call.py', name="a")
a()
Saad Anwar
09/12/2022, 8:16 PM