Does anyone know how do we construct a python Asse...
# ask-community
Does anyone know how do we construct a python Asset or Resource within Dagster? For example, if I have a Python script on my system “”, what Dagster API can I use to turn this script into an Asset or Resource and then execute it? I am struggling with the Documentation. Thank you!
dagster bot responded by community 1
🤖 1
it might be best to keep it simple when getting started and just call your script from an
. So if you have a python script like this:
Copy code
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:
Copy code
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"])

def do_something_job():
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
and spinning up a dagit UI instance to run it from
if you need to call your script from the command-line, i.e. it's not importable from your dagster code, you can use the `dagster-shell` library like this:
Copy code
from dagster_shell import create_shell_command_op

from dagster import graph

def my_graph():
    a = create_shell_command_op('python', name="a")
Thank you very much, this was very helpful!
🎉 1