For example I have a solid named initiate_load , it is yielding a dictionary and an integer , something like :
@solid(
output_defs=[
OutputDefinition(name='l_dict', is_required=False),
OutputDefinition(name='l_int', is_required=False)
],
)
def initiate_load(context):
....
....
yield Output(l_dict, output_name='l_dict')
yield Output(l_int, output_name='l_int')
I have a composite_solid also ,let's say call_other_solid_composite
and I am passing l_dict
and l_int
to this composite_solid
and I am using the l_dict
to get the values mapped to its keys. Something like.
@composite_solid
def call_other_solid_composite(p_dict,p_int):
l_val1 = p_dict['val1']
...
...
Then I am getting a Error as :TypeError: 'InputMappingNode' object is not subscriptable
.
I searched everywhere but can't find a solution . The documentation is also of no help . I have use case that I need to parse those values .
Any help will be appreciated.
Similar to methods decorated with @pipeline, you should not think of methods decorated with @composite_solid as regular python methods. Dagster will wrap them and make it something completely different. That's why the p_dict
parameter cannot be used inside the method as a regular method parameter.
To achieve what you want, you have a couple of options:
p_dict
parameter directly in another solid and inside this solid you will be able to do l_val1 = p_dict['val1']
initiate_load
method, you can yield p_dict['val1']
as an output as well. This allows you to use both the dict and the 'val1' value as inputs in other solids (also in your composite)p_dict['val1']
, this allows you to use this value as an input for other solids inside the composite.Hope this helps. For reference, the documentation about the composite solids can be found here.
A small remark on the snippets you provided. Dagster has a very neat typing system, it is best practice to use this as much as possible.