Steve Pletcher
03/18/2021, 3:28 PMStringSource
fields that draw from an environment variable. reproduction code in the thread.@dataclass
class Thing:
foo: str
@resource({
'foo': Field(StringSource),
})
def thing(init_context):
return Thing(init_context.resource_config['foo'])
@configured(thing)
def configured_thing(_config):
return {
'foo': {'env': 'FOO_VAR'}
}
resource_context = InitResourceContext(resource_config={}, resource_def=configured_thing)
configured_thing.resource_fn(resource_context)
"""
Traceback (most recent call last):
File "test.py", line 29, in <module>
configured_thing.resource_fn(resource_context)
File "test.py", line 18, in thing
return Thing(init_context.resource_config['foo'])
KeyError: 'foo'
"""
StringSource
only works for solids/resources that take a single parameter?chris
03/18/2021, 3:33 PMInitResourceContext
is initialized. In general, we consider InitResourceContext
to be an internal API, but the build_resources
API that Alex mentioned earlier will handle this caseSteve Pletcher
03/18/2021, 3:35 PMchris
03/18/2021, 3:35 PMSteve Pletcher
03/18/2021, 3:35 PMbuild_resources
apichris
03/18/2021, 3:36 PMschrockn
03/18/2021, 3:44 PMos.environ.get('FOO_VAR')
directly in the configured
functionSteve Pletcher
03/18/2021, 3:45 PMbuild_resources
itself wasn't available in 0.10.9