Vinnie
12/07/2022, 9:01 AMasset_reconciliation_sensor
with SLAs, but this makes the lack of configuration options in assets and multi-assets even more relevant than it was before. While we can set the configs on the job level, it’s impossible to configure the assets themselves. Maybe I’m still stuck in dagster anti-patterns, but I’d like to keep my code as static as possible and configure assets with YAML files.ops:
fetch_pubchem_compound_by_name:
config:
compounds:
- FeCl3
- Vitamin B7
...
compound_return_parameters:
- label: Molecular Weight
alias: molecular_weight
...
In this case it’s possible I’ll need to get different compounds or return different parts of the pubchem response, and I’d prefer not touching the underlying asset code when that’s necessary.
In case this really is an anti-pattern, I’d love to see what other solutions people have been using with SDAsDaniel Mosesson
12/07/2022, 8:57 PMsandy
12/08/2022, 3:52 PMVinnie
12/08/2022, 4:07 PM.configured
method attached to AssetsDefinitions. This would definitely solve my use case, although for how I’ve developed thus far, I haven’t needed to keep different configurations of the same asset at the same time, so even just having a config
flag on the decorators or .from_graph
method (analog to @job(config={}
) would already be enough.
For more context, all the assets I’ve written thus far take some form of mandatory configuration. From fairly basic like the example with the compounds, to more complex in case they rely on the same underlying API and need to hit different endpoints and process the data in different ways. My pattern has always been to put them in `job`s and configure the `job`s, which has been good enough for everything thus far, but wouldn’t allow me to adopt FreshnessPolicies
or the asset_reconciliation_sensor
. So this is definitely not a major issue, but a “nice to have”sandy
12/08/2022, 11:58 PMconfigured
to AssetsDefinition
, though it's a bit stalled. If you need it in the meantime, you could just copy the core of the implementation into your own function: https://github.com/dagster-io/dagster/pull/10497/files#diff-8361871844cf00752df2558e86b2673b185530c5b56c3e152267b78ef0ce5369R878. E.g. make a configured_asset
function that accepts an AssetsDefinition
and a config dictionary and creates a new AssetsDefinition
using the code I linked.Vinnie
12/09/2022, 8:29 AMdagster._core.errors.DagsterInvalidDefinitionError: Only graphs utilizing config mapping can be pre-configured. The graph "my_graph" does not have a config mapping, and thus has nothing to be configured.
even though the underlying `op`s that compose the GraphDefinition
do require a config. This would mean I’d need to recreate the config mapping within the @graph
definition, effectively something like (working example):
@op(config_schema={"my_str": str})
def my_op(context):
return context.op_config["my_str"]
@graph(config={"my_op": {"config": {"my_str": "str"}}})
def my_graph():
return my_op()
some_asset = AssetsDefinition.from_graph(
my_graph.configured(
{"my_op": {"config": {"my_str": "hello"}}},
name="some_asset",
),
)
I also saw that the config
parameter within @graph
is undocumented, only showing up in the docs for GraphDefinition
Ultimately this is probably a super niche case, but wanted to raise it just to be sure. I’ll stick to my current methods by now which already work just fine for our purposes 🙂Ajita Khanal
04/20/2023, 7:54 PMsandy
04/20/2023, 10:14 PMAjita Khanal
04/20/2023, 10:46 PMsandy
04/20/2023, 11:18 PMconfigured
for this
instead, you can set default values: https://docs.dagster.io/concepts/configuration/advanced-config-types#defaults-and-optional-config-fieldsAjita Khanal
04/20/2023, 11:28 PMsandy
04/20/2023, 11:48 PM