It would be great to be able to mix graph inputs a...
# dagster-feedback
m
It would be great to be able to mix graph inputs and constant inputs in `@op`s. I am doing something like this:
Copy code
def mk_my_op(param):
   @op
   def work(context, input):
      do_some_work(input, param)

@graph
def gr():
  input = ..
  mk_my_op(param)(input)
where
input
is only know when the graph runs but
param
is something I know when setting up the graph, like an enum value. Another structure I've used is:
Copy code
@op
def return_constant():
  return 'param'

@op
def work(context, param, input):
  return do_some_work(input, param)

@graph
def gr():
  param = return_constant()
  input = ..
  work(param, input)
However, having too many 'return a constant' ops slows down execution, especially for small/local test runs.
a
depending on how these values are resolved, a
resource
could be an option
you can bind a default value to an input of an op
Copy code
def mk_my_op(param):
   @op
   def work(context, input, x=param):
      do_some_work(input, x)
and it will use that default value if its not hooked up to another ops output
m
Thanks for taking a look! I actually just want to repeat the same work across values of an enum, like:
Copy code
class Workflows(enum.Enum):
  One = 1
  Two = 2
  Three = 3
And then my ops want to use the workflow value -- stick it in logs, pull different config values based on workflow, have slightly branching logic, etc. So the graph is kinda like:
Copy code
@graph
def gr():
  for workflow in Workflows:
     result = my_op(workflow, other_input)
So a default value wouldn't work, because it does need to vary based on different times I'm using the op. I think a resource could work, but it seems a little more cumbersome to implement than wrapping my op in a
mk_my_op
.
a
ya just throwing some other ideas in the mix i think your feedback is good and it would be useful if the system had a more flexible way to plug constant values in
👍🏻 1
👍 1
m
Glad to have other ideas to consider!