Vax Thurai
09/28/2021, 4:55 AMevent_date
)
dbt_run_models = dbt_cli_run.configured(
name="dbt_run_models",
config_or_config_fn={
"project-dir": PROJECT_DIR,
"profiles-dir": PROFILES_DIR,
"models": MODELS,
"target": TARGET,
"vars": '{event_date: ' + event_date +'}'
}
)
owen
09/28/2021, 4:32 PMconfig_or_config_fn=lambda event_date: {
"project-dir": PROJECT_DIR,
"profiles-dir": PROFILES_DIR,
"models": MODELS,
"target": TARGET,
"vars": '{event_date: ' + event_date +'}'
}
this will make a new configuration schema for your dbt solid that has just a single field for the event_date. then, in your schedule code (assuming the schedule knows what the event_date should be), you can return a run config that looks like :
{ "solids": {"dbt_run_models": {"config": event_date}}}
alternatively, you could sip the config_or_config_function bit entirely, keep the original dbt_cli_run configuration schema, and have your schedule return a config blob with all of the relevant info ("project-dir", "profiles-dir", etc.).Vax Thurai
09/28/2021, 4:38 PM@daily_schedule( # The decorated schedule function should accept a datetime
pipeline_name="csg_pipeline",
start_date=datetime(2021, 1, 1),
execution_time=time(0, 5),
execution_timezone="UTC",
mode=csg_preset.mode,
tags_fn_for_date=lambda _: csg_preset.tags
)
def csg_daily_schedule(date):
return {"solids": {"get_entity_configurations": {"config": {"date": date.strftime("%Y-%m-%d")}}}}
def csg_daily_schedule(date):
return {"solids": {
"get_entity_configurations": {
"config": {
"date": date.strftime("%Y-%m-%d")
}
},
"dbt_run_models": {
"config": {
"event_date": date.strftime("%Y-%m-%d")
}
}
}
}
owen
09/28/2021, 4:40 PMdef csg_daily_schedule(date):
return {"solids": {
"get_entity_configurations": {
"config": {
"date": date.strftime("%Y-%m-%d")
}
},
"dbt_run_models": {
"config": date.strftime("%Y-%m-%d")
}
}
}
Vax Thurai
09/28/2021, 4:41 PMdagster.core.errors.DagsterConfigMappingFunctionError: The config mapping function on a `configured` SolidDefinition has thrown an unexpected error during its execution.
File "/Library/Python/3.8/site-packages/dagster/grpc/impl.py", line 342, in get_external_execution_plan_snapshot
create_execution_plan(
File "/Library/Python/3.8/site-packages/dagster/core/execution/api.py", line 718, in create_execution_plan
resolved_run_config = ResolvedRunConfig.build(pipeline_def, run_config, mode=mode)
File "/Library/Python/3.8/site-packages/dagster/core/system_config/objects.py", line 220, in build
solid_config_dict = composite_descent(
File "/Library/Python/3.8/site-packages/dagster/core/system_config/composite_descent.py", line 79, in composite_descent
return {
File "/Library/Python/3.8/site-packages/dagster/core/system_config/composite_descent.py", line 79, in <dictcomp>
return {
File "/Library/Python/3.8/site-packages/dagster/core/system_config/composite_descent.py", line 113, in _composite_descent
config_mapped_solid_config = solid.definition.apply_config_mapping(
File "/Library/Python/3.8/site-packages/dagster/core/definitions/configurable.py", line 55, in apply_config_mapping
self.config_schema.resolve_config(config)
File "/Library/Python/3.8/site-packages/dagster/core/definitions/definition_config_schema.py", line 120, in resolve_config
self._invoke_user_config_fn(processed_config),
File "/Library/Python/3.8/site-packages/dagster/core/definitions/definition_config_schema.py", line 113, in _invoke_user_config_fn
return {"config": self._config_fn(processed_config.get("config", {}))}
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/Library/Python/3.8/site-packages/dagster/core/errors.py", line 192, in user_code_error_boundary
raise error_cls(
owen
09/28/2021, 6:16 PMVax Thurai
09/28/2021, 6:19 PMdbt_run_models = dbt_cli_run.configured(
name="dbt_run_models",
config_or_config_fn=lambda event_date: {
"project-dir": PROJECT_DIR,
"profiles-dir": PROFILES_DIR,
"models": MODELS,
"target": TARGET,
"vars": '{event_date: ' + event_date +'}'
}
)
PROJECT_DIR
, PROFILES_DIR
, MODELS
, TARGET
are assigned globally while event_date is passed through the schedulerowen
09/28/2021, 6:24 PMVax Thurai
09/28/2021, 6:29 PMowen
09/28/2021, 6:31 PMVax Thurai
09/28/2021, 6:32 PMowen
09/28/2021, 6:35 PMconfig_or_config_fn=lambda event_date: {
"project-dir": PROJECT_DIR,
"profiles-dir": PROFILES_DIR,
"models": MODELS,
"target": TARGET,
"vars": {"event_date" : event_date}
}
( I noticed that "vars" is meant to be a dictionary, not a string)Vax Thurai
09/28/2021, 6:40 PMowen
09/28/2021, 6:44 PMVax Thurai
09/28/2021, 6:45 PMowen
09/28/2021, 6:46 PM