https://dagster.io/ logo
#dagster-feedback
Title
# dagster-feedback
s

Stephen Bailey

06/10/2022, 5:16 PM
I want to make an
@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
Copy code
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?
It's similar to what @Binoy Shah mentions here. Not sure if you got something built for the @heavyjob? https://dagster.slack.com/archives/C014N0PK37E/p1654550563253299
i think the Factory pattern would always generate the same op/job pattern?
m

Mark Fickett

06/10/2022, 8:23 PM
I recently made an
@op
wrapper: https://dagster.slack.com/archives/C01U954MEER/p1650473204641889 , may have some similarities in how you'd implement it.
🔥 2
s

Stephen Bailey

06/10/2022, 8:36 PM
amazing @Mark Fickett , this is exactly what i want
j

johann

06/10/2022, 8:44 PM
Mark beat me to the punch, but I had
Copy code
def 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)
🎉 1
@Dagster Bot docs Custom job and op decorators
🎉 2
d

Dagster Bot

06/10/2022, 8:46 PM
s

Stephen Bailey

06/12/2022, 4:40 PM
@johann this is perfect 🎉
2 Views