Mark Fickett
04/28/2022, 2:12 PMgraph.execute_in_process
with a subgraph which takes an input? For example:
@graph
def my_subgraph(value: int):
a = my_op(value)
return my_other_op(a)
Looking at the testing docs I see ways to test ops and full graphs, but testing subgraphs would be great too.alex
04/28/2022, 3:07 PMrun_config
direct value passing has some prototypes and is something we are working towardsMark Fickett
04/28/2022, 3:11 PMops: {
# these keys align with the names of the ops, or their alias in this job
"my_op": {
# configurably specify input values, keyed by input name
inputs: {
"value": {
# if an dagster_type_loader is specified, that schema must be satisfied here;
# scalar, built-in types will generally allow their values to be specified directly:
"value": 3
}
},
}
},
And I'd just repeat that for each op if multiple ops in the subgraph consume the graph's input(s).alex
04/28/2022, 3:23 PMinputs: value: 3
alex
04/28/2022, 3:24 PMmy_subgraph.execute_in_process(run_config={'inputs': {'value': 3}})
Mark Fickett
04/28/2022, 3:24 PMMark Fickett
04/28/2022, 6:52 PMpipe_to_test_id_list
of type Dict[Pipe, List[str]]
where Pipe
is my enum. It works fine in a full test run, but for execute_in_process
with inputs
in the config, I get an error that it "can not be loaded from configuration" and I should "add a dagster_type_loader for the type 'Dict[Pipe,[String]]'". If I add a type loader for the enum does that resolve the complex type too? Since I'm passing the actual enum value in my config inputs like {'inputs': {'pipe_to_test_id_list': {<http://Pipe.my|Pipe.my>_pipe: ['id1', 'id2']}}}
, I'm not sure what my loader would be.Mark Fickett
04/28/2022, 7:11 PMPipe
enum but it doesn't seem to work, I get roughly the same error (though it does reference my DagsterType):
@dagster.dagster_type_loader(dagster.Permissive())
def _load_pipe(_context, value):
return value
_PipeIn = dagster.PythonObjectDagsterType(python_type=Pipe, name="_PipeIn", loader=_load_pipe)
@op(
ins={
"pipe_to_test_id_list": In(dagster_type=dagster.Dict[_PipeIn, dagster.List[str]]),
alex
04/28/2022, 8:30 PMIt works fine in a full test runhow are you passing the value there? you may need to do
<http://Pipe.my|Pipe.my>_pipe.value
since run_config is the same input powered by yaml. It expects “scalar” inputs not any complex python object typesMark Fickett
04/28/2022, 8:40 PM{<http://Pipe.my|Pipe.my>_pipe: ['id1', 'id2']}
from an upstream op, and that works fine.
In a unit test, I was trying to do my_subgraph.execute_in_process(run_config={'inputs': {'pipe_to_test_id_list': {<http://Pipe.my|Pipe.my>_pipe: ['id1', 'id2']}}})
. I get the same error whether I do that with <http://Pipe.my|Pipe.my>_pipe
or <http://Pipe.my|Pipe.my>_pipe.value
in the run_config argument, it says "add a dagster_type_loader for the type 'Dict[Pipe,[String]]'".Mark Fickett
04/28/2022, 8:41 PMalex
04/28/2022, 8:46 PMdict[pipe, list[str]]
as a single typealex
04/28/2022, 8:46 PMMark Fickett
04/29/2022, 12:53 AMMark Fickett
04/29/2022, 2:37 AM@op
to produce the input value and a @graph
to wrap the subgraph under test, in my unit test. But if there's a way to get something more streamlined working that'd be nice!alex
04/29/2022, 2:00 PM{'ops': {'consume_value': ['inputs': 'pipe_to_test_id_list': ...]}}