https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Abel Mendonça

02/13/2024, 1:54 PM
Hi guys. Why does annotating a function with @job automatically runs the function before the dagster instance runs?
z

Zach

02/13/2024, 2:15 PM
Dagster calls the function decorated by
@job
so it can construct the graph of ops described in the function, so it can display the graph. If you're calling vanilla python functions in the
@job
function as well then those will get executed. You should only be calling
@ops
from within a
@job
definition
a

Abel Mendonça

02/13/2024, 2:16 PM
i'm not using asset job, i'm using job directly on top of my function
how can i debug this?
i just have a basic config
importing my assets (funtions)
z

Zach

02/13/2024, 2:24 PM
I would isolate your job into a smaller set of code that you try to load into Dagster
Oh wait I may have said something that's slightly incorrect
Please show your job code - Dagster does execute the function wrapped by
@job
, but you should only be calling ops there not vanilla python functions
a

Abel Mendonça

02/13/2024, 2:28 PM
it's running
z

Zach

02/13/2024, 2:28 PM
Dagster has to call the function at load time to construct the graph / determine the dependencies between ops (otherwise it wouldn't be able to display what ops are in a job). So if you're trying to execute vanilla python functions in a job definition it'll execute those. So you should only be calling ops in the
@job
definition
a

Abel Mendonça

02/13/2024, 2:29 PM
ok
this makes sence. i saw something similar in the docs
i didn't develop the script inside dagster
now i'm integrating it. so far the asset materialization and asset defined jobs do work
maybe i'm going with that
2 Views