Hi there, I am getting started with dagster and ha...
# ask-community
t
Hi there, I am getting started with dagster and have a following case: I would like to have an op that runs a command based on parameters defined in the run_config. Basically I don’t want to reimplement create_shell_command_op/shell_op but reuse it. But I could not invoke them in my op, nor configure them by parameters. What should I do? Many thanks!
y
Hi @Tung Dang could you plz share more context? e.g. code snippets that you expect to work
t
Copy code
@op(config_schema={"content": str})
def command_op(context):
    """
    An op for running a command with parameter provided in the run_config
    """

    command = f'echo "{context.op_config["content"]}"'

    return create_shell_command_op(command, name="example_command")()
Hi @yuhan, this is similar to what I want to achieve. However when I run it, dagster complains that create_shell_command_op is invoked without context.
Generally, I would like to reuse the provided ops by dagster and parameterize them with config. So what is the best way to do it? I thought of converting them into graph but it only supports resources. I am not sure, I could have missed some basics understanding of dagster.
y
Got it - you can try writing an op factory that takes in params and wraps an op definition (
create_shell_command_op
in this case) Here’s an example: https://docs.dagster.io/concepts/ops-jobs-graphs/ops#op-factory
t
@yuhan yes, I have tried it but how can I pass the context config to the factory as parameter inside a job definition?