https://dagster.io/ logo
Title
m

Martin Carlsson

11/04/2021, 1:34 PM
I’m trying to figure out how to pass a parameter to an
op
within a
job
. I’m trying to follow this one https://docs.dagster.io/concepts/io-management/unconnected-inputs#loading-a-built-in-dagster-type-from-config But when I run dagit it still require me to add configs. Actually, what I’m looking for is a way to have an
op
that takes a parameter (a string), and then pass that parameter to the
op
from a
job
.
Technically, I want to do something like this:
Of cause … I can do this, but it seems a bit ugly
j

Jordan W

11/04/2021, 1:53 PM
m

Martin Carlsson

11/04/2021, 1:54 PM
@Jordan W how do I add that to the code?
j

Jordan W

11/04/2021, 1:54 PM
what you would need is
@op(config_schema={"input_string": str})
def my_op(context):
    in_string = context.op_config["input_string"]
m

Martin Carlsson

11/04/2021, 1:58 PM
@Jordan W ok, but how to I supply the parameter to the
op
within the
job
How should I write my
job
j

Jordan W

11/04/2021, 1:58 PM
that depends where you are executing the job
in code, dagit, or on the cli
m

Martin Carlsson

11/04/2021, 2:00 PM
All of them. I want to define the input im my code, so it can run from the cli, dagit - and later maybe via the python api
From the link … what I want is to add a parameter here
I am able to do this
But not this
j

Jordan W

11/04/2021, 2:06 PM
a job doesnt allow for any hard coded values in an `op`'s parameters. Everything parameter within a job needs to be a result from a previous solid. in your case, with your first solid requiring a parameter, that would be done through the run_config
d

daniel

11/04/2021, 2:16 PM
Martin you might find this example useful, you can specify default config on the job which could help here: https://docs.dagster.io/concepts/ops-jobs-graphs/jobs-graphs#hardcoded-configuration
m

Martin Carlsson

11/04/2021, 3:42 PM
@Jordan W @daniel thanks a lot for the help. I'm now 99% sure that the way I'm building my program is subpar - and there is a good reason for ops in jobs don't take string parameters. Does anyone know why this is? I mean why Dagster doesn't allow this?
a

Alex Saltzman

11/09/2021, 4:17 PM
I'm new here but my guess is Dagster is designed the way it is to remain modular and flexible with minimal / no changes necessary to the actual op/job code logic when you "simply" are changing inputs
1