Launching a function with a reload code #33739
Unanswered
creditskif
asked this question in
Q&A
Replies: 1 comment
-
|
Hi @creditskif ! If the database query is happening at module import time or while defining the asset, it can run multiple times. Seeing it run 3 times during one asset execution can be expected depending on your deployment/processes. The recommended pattern is to avoid doing database work during code loading. Instead:
For example, avoid this: rows = load_rows_from_db() # runs during code load/reload
@asset
def my_asset():
...Prefer this: @asset
def my_asset(db):
rows = db.load_rows()
...If you can share a small snippet of where the table is being queried, folks can suggest the best Dagster pattern for your specific case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Good afternoon, everyone! The idea is this, we have implemented a table in the database that stores asset data. How to force Dagster to unload data from a table only once, during "reload code"? Now this function is run 3 times when executing 1 asset
Beta Was this translation helpful? Give feedback.
All reactions