https://dagster.io/ logo
Title
y

Yang

11/02/2022, 6:44 PM
Hello! In some cases, I want to use an op in a graph, but with one input hardcoded. How do I do this? It doesn't seem like I can pass a string in the graph definition. Thanks!
@graph
def my_graph(fiscal_year):
    pillar = compute_pillar("esg", fiscal_year)
a

alex

11/02/2022, 6:48 PM
you can set a default input value on the graph
@graph
def my_graph(fiscal_year, some_param="esg"):
    pillar = compute_pillar(some_param, fiscal_year)
y

Yang

11/02/2022, 7:12 PM
oh gotcha, ok thanks!
hmm, that didn't work. maybe bc I'm using
AssetDefinitions.from_graph
? Or do I need to explicitly make the input optional?
dagster._core.errors.DagsterInvalidDefinitionError: Input asset '["pillar_name"]' for asset '["esg_scores"]' is not produced by any of the provided asset ops and is not one of the provided sources
guess I need to specify that the input is optional. is the syntax the same for graphs as ops?
a

alex

11/03/2022, 2:15 PM
bc I’m using AssetDefinitions.from_graph
I think so - you may be able to work around it by nesting the graph again, though thats cumbersome
y

Yang

11/03/2022, 5:17 PM
I tried making it a regular job, but the input was still required. I need to add
ins
to the decorator?
a

alex

11/03/2022, 5:33 PM
what exact error did you get ?
y

Yang

11/03/2022, 5:42 PM
I'm defining the graph like this
@graph
def esg_scores(pillar_name:str="esg"):
    ...
    return pillar_scores
and the job like this
@job(resource_defs=r_defs, executor_def=esg_executor)
def esg_scores_op_job():
    esg_scores()
and in the launchpad, it says
Missing required config entry "inputs"
a

alex

11/03/2022, 5:57 PM
ahh sorry for the bad lead - this pattern worked on some of our older abstractions. You can use
input_values
on
to_job
/
@job
- maybe that would work for you
from dagster import graph, job, op


@op
def echo(x):
    return x


@graph
def test_g(y):
    echo(y)


print(test_g.execute_in_process(input_values={"y": 4}).success)


@job(input_values={"z": 4})
def test_j(z):
    test_g(z)


print(test_j.execute_in_process().success)
y

Yang

11/03/2022, 6:40 PM
ooh great. is there an equivalent for
define_asset_job
? I'd need to make
pillar_name
a SourceAsset?