Stephen Bailey
06/10/2022, 5:16 PM@whatnot_job
decorator that merges in default config into job definitions. Has anyone done this before? I am having some difficulty getting the args to pass correctly. What I want is something like this -- anyone
def whatnot_job(func, **kwargs):
# merge default tags with passed in tags
default_tags = {"foo": "bar"}
kwargs["tags"] = kwargs.get("tags", {}).update(default_tags)
# create a job by passing in updated kwargs to @job decorator
@job(**kwargs)
def my_job():
return func
return my_job
anyone have ideas on how to do this?
also, not sure if #dagster-feedback is the right place for these "best practices" type of questions?Stephen Bailey
06/10/2022, 5:17 PMStephen Bailey
06/10/2022, 5:20 PMMark Fickett
06/10/2022, 8:23 PM@op
wrapper: https://dagster.slack.com/archives/C01U954MEER/p1650473204641889 , may have some similarities in how you'd implement it.Stephen Bailey
06/10/2022, 8:36 PMjohann
06/10/2022, 8:44 PMdef whatnot_job(*args, **kwargs):
default_tags = {"foo": "bar"}
kwargs["tags"] = {**kwargs.get("tags", {}), **default_tags}
def inner(func):
return (job(*args, **kwargs))(func)
return inner
@whatnot_job()
def johann_whatnot_job():
pass
(which I have only cursorily tested)johann
06/10/2022, 8:46 PMDagster Bot
06/10/2022, 8:46 PMStephen Bailey
06/12/2022, 4:40 PM