https://dagster.io/ logo
Title
p

Peter Lim

02/03/2023, 8:55 PM
Hello and happy Friday! Question, is there currently a way to define assets dynamically? i.e can I write a function that parses through config files and defines assets? Thanks!
g

Gabe Schine

02/03/2023, 9:29 PM
I believe the answer is "yes": have your code build a list of
AssetsDefinition
objects, and give that to the
Definitions
object
j

jamie

02/03/2023, 10:23 PM
Hey @Peter Lim yeah that should totally work. this isn’t an example for assets, but here’s a code snippet showing how to do something similar with ops https://docs.dagster.io/concepts/ops-jobs-graphs/ops#op-factory
p

Peter Lim

02/03/2023, 10:27 PM
Thank you for your replies! I’ve been reading about the op factory above. How do you implement that? Do I need an op or a job to call the op factory function to dynamically create the ops?
j

jamie

02/03/2023, 10:48 PM
you would just call the function X number of times in your python file and store the returned ops/assets in a list. then you could add that list to your Definitions object to see them in dagit
p

Peter Lim

02/03/2023, 10:56 PM
Got it, thank you! The ops factory worked but I’ll try the asset one next.
^worked with assets as well. Thanks! :dagster-yay: