Donny Winston
05/09/2023, 9:58 PMDefinitions
invocation? I remember with graphs, it was to_job
, and I could pass run config.sean
05/09/2023, 10:01 PMDefinitions
and access them through an assets job. The default job created by define_asset_job
will contain all assets in the `Definitions`:
defs = Definitions(
assets=[some_asset],
jobs=[define_asset_job("all_assets")]
)
defs.get_job_def("all_assets")
Donny Winston
05/09/2023, 10:04 PMconfig
param that is a subtype of dagster.Config
. the example from https://docs.dagster.io/concepts/assets/software-defined-assets#asset-configuration is
from dagster import Config, asset
@asset
def my_upstream_asset() -> int:
return 5
class MyDownstreamAssetConfig(Config):
api_endpoint: str
@asset
def my_downstream_asset(config: MyDownstreamAssetConfig, my_upstream_asset: int) -> int:
data = requests.get(f"{config.api_endpoint}/data").json()
return data["value"] + my_upstream_asset
Donny Winston
05/09/2023, 10:05 PMDefinitions(
assets=[my_downstream_asset.configured({"api_endpoint": "foo"})],
?Donny Winston
05/09/2023, 10:07 PMsean
05/09/2023, 10:12 PMclass MyAssetConfig(Config):
api_endpoint: str
@asset
def my_asset(config: MyAssetConfig) -> str:
print(config.api_endpoint)
return config.api_endpoint
defs = Definitions(
assets=[my_asset],
jobs=[define_asset_job("all_assets")],
)
defs.get_job_def("all_assets").execute_in_process(
run_config=RunConfig({"my_asset": MyAssetConfig(api_endpoint="<http://localhost:8080>")})
)
Donny Winston
05/09/2023, 10:13 PMexecute_in_process
(or materialize
) when loading the module. I want to be able to do this e.g. in dagit, but have pre-supplied config.Donny Winston
05/09/2023, 10:15 PMMissing required config entry "ops" at the root
in my Dagit launchpad, which makes sense, because required config is missing for an asset materialization.sean
05/09/2023, 10:16 PMsean
05/09/2023, 10:17 PMconfig
param on define_asset_job
, but I’m not sure it’s possible to do this for the hidden base asset job that is used by default when clicking Materialize in dagitsean
05/09/2023, 10:19 PMdefs = Definitions(
assets=[my_asset],
jobs=[
define_asset_job("all_assets", config=RunConfig({"my_asset": MyAssetConfig(api_endpoint="foo")})
],
)
Donny Winston
05/09/2023, 10:19 PMsean
05/09/2023, 10:23 PMsean
05/09/2023, 10:24 PMmy_asset
when looking at the all_assets
job (but not when looking at default
asset group), it will use the specified config for all_assets_job
Donny Winston
05/09/2023, 10:25 PMmy_asset
materializations will appear in its history regardless of being initiated via a "job" hopefully. thanks.sean
05/09/2023, 10:25 PMmy_asset materializations will appear in its history regardless of being initiated via a “job”most definitely