King Chung Huang
07/25/2019, 7:58 PMcomposite_solid
that uses another solid and sets a config value in it. In this code snippet, the prefix_value
solid prefixes the input value with the prefix
from the config. Then, the prefix_id
composite solid uses prefix_value
but sets the prefix to _id_
.
@solid(
config={
'prefix': Field(str, default_value='_')
}
)
def prefix_value(context, v):
return f'{context.solid_config["prefix"]}{v}'
@composite_solid(
config_fn=lambda _, cfg: {
'prefix_value': {'config': {'prefix': '_id_'}},
},
config={},
)
def prefix_id(id):
return prefix_value(id)
I'm getting dagster.check.CheckError: Invariant failed. Description: Cannot specify empty config for ConfigMapping
. But, I'm not sure how to solve it. Is this a correct way for a solid to use another solid with a custom config?nate
07/25/2019, 8:44 PMconfig
dictionary as you have it. so the quick solution is to just put some key in the config dictionary:
@composite_solid(
config_fn=lambda _, cfg: {
'prefix_value': {'config': {'prefix': '_id_'}},
},
config={'a_key': Field(String)},
)
King Chung Huang
07/25/2019, 10:16 PMtest_prefix cannot not be executed with the provided config. Please fix the following errors: Exception occurred during execution of user config mapping function <lambda> defined by solid prefix_id from definition prefix_id at path root:solids:prefix_id: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/dagster/core/types/evaluator/evaluation.py", line 252, in _evaluate_composite_solid_config frozendict(context.config_value.get('config')), TypeError: 'NoneType' object is not iterable
I haven't been able to figure out what it's trying to iterate on that's None.@composite_solid(
config_fn=lambda _, cfg: {
'prefix_value': {'config': {'prefix': '_id_'}},
},
config={
'foo': Field(str, is_optional=True, default_value='')
}
)
def prefix_id(id):
return prefix_value(id)
@pipeline
def test_prefix():
# v = prefix_value()
v = prefix_id()
print_value(v)
nate
07/25/2019, 10:20 PM# pylint: disable=no-value-for-parameter
from dagster import composite_solid, solid, pipeline, Field, execute_pipeline
@solid(config={'prefix': Field(str, is_optional=True, default_value='not defined')})
def prefix_value(context, some_id):
return f'{context.solid_config["prefix"]}{some_id}'
@composite_solid(
config_fn=lambda _, cfg: {'prefix_value': {'config': {'prefix': 'some override'}}},
config={'foo': Field(str)},
)
def prefix_id(some_id):
return prefix_value(some_id)
@pipeline
def test_prefix():
prefix_id()
if __name__ == "__main__":
result = execute_pipeline(
test_prefix,
{
'loggers': {'console': {'config': {'log_level': 'DEBUG'}}},
'solids': {
'prefix_id': {
'config': {'foo': 'not used'},
'inputs': {'some_id': {'value': '12345'}},
}
},
},
)
this version works for meKing Chung Huang
07/25/2019, 10:36 PMfrom dagster import (
Field,
composite_solid,
pipeline,
solid,
)
@solid(
config={
'prefix': Field(str, is_optional=True, default_value='_')
}
)
def prefix_value(context, v):
return f'{context.solid_config["prefix"]}{v}'
@composite_solid(
config_fn=lambda _, cfg: {
'prefix_value': {'config': {'prefix': '_id_'}},
},
config={
'foo': Field(str, is_optional=True, default_value='')
}
)
def prefix_id(id):
return prefix_value(id)
@solid
def print_value(context, v):
<http://context.log.info|context.log.info>(str(v))
@pipeline
def test_prefix():
# v = prefix_value()
v = prefix_id()
print_value(v)
nate
07/25/2019, 10:59 PMKing Chung Huang
07/25/2019, 11:17 PMmax
07/25/2019, 11:53 PMpreset_defs
arg); the second is that you can execute a pipeline using composed environment dicts/yamls, which lets you put less-frequently changed config values in a single shared fileKing Chung Huang
07/26/2019, 4:13 PMpreset_defs
.