https://dagster.io/ logo
#ask-community
Title
# ask-community
i

Ignas Kizelevičius

03/23/2023, 4:42 PM
Hello, is it possible to use an
op
inside another
op
? I want to use
shell_op
inside my custom
op
j

jamie

03/23/2023, 4:52 PM
hey @Ignas Kizelevičius calling an op within another op is not supported/ an anti-pattern. Instead you could do something like this
Copy code
@op
def before_shell_op():
    # do computation
    return value

@op 
def after_shell_op(x):
     # do computation on x

@job 
def my_job():
       value = before_shell_op()
       shell_out = shell_op(value) 
       after_shell_op(shell_out)
i

Ignas Kizelevičius

03/23/2023, 5:10 PM
Hi @jamie, thanks for the answer. The shell command materializes an asset, thus I wanted to log the materialization in the same op
j

jamie

03/23/2023, 5:19 PM
huh interesting. another option would be to just directly execute the command within your op using
subprocess
rather than using the
shell_op
i

Ignas Kizelevičius

03/23/2023, 5:29 PM
Yeah i guess thats my next option, thanks 🙂
7 Views