https://dagster.io/ logo
#dagster-support
Title
# dagster-support
i

Ian Young

08/06/2022, 7:07 PM
I have a n00b question regarding ops and functions. The docs suggest splitting your code up into
@ops
over regular python functions and I understand the reasoning. However is it still possible to interweave regular python functions with
@ops
when it comes to small helper functions?
b

Ben Gatewood

08/07/2022, 6:17 AM
Yes absolutely. I've got a bunch of little helpers in a lot of my jobs
i

Ian Young

08/07/2022, 7:14 AM
@Ben Gatewood Thanks. How do you determine what should be an
@op
and what is a regular python function? Is there a general rule?
b

Ben Gatewood

08/07/2022, 7:17 AM
For me an op represents some significant part of the pipeline or an artefact thereof. I split things like formatters/convertors out into helpers
i

Ian Young

08/07/2022, 7:20 AM
That helps. So it doesn’t just have to be the assets that get materialized and it doesn’t have to be all
@ops
but just a sensible balance in between where it makes sense?
b

Ben Gatewood

08/07/2022, 7:22 AM
Yeah pretty much in my view. For instance, retrieving a bunch of raw inputs from an API makes sense to be an op to me whereas the little function that generates the appropriate query params for the API based on a list of dates or similar doesn't need to be
👍 1
i

Ian Young

08/07/2022, 7:24 AM
And can you pass in-memory assets between
@ops
the same as functions? Like a list obtained from an API which isn’t yet materialized?
b

Ben Gatewood

08/07/2022, 7:25 AM
You can pass basically anything as the output of one op into a another one
i

Ian Young

08/07/2022, 7:34 AM
Awesome, thanks. Do you have any tips for converting existing python scripts to Dagster? I presume it’s better to create a project structure using
dagster project scaffold
and then build up your assets, ops, and functions? It seems like software-defined assets is the favoured approach?
b

Ben Gatewood

08/07/2022, 8:21 AM
I started before the CLI was available so I built up my first ones from scratch and new ones are cloned from a template based on the earlier ones. There's a docs page on situations that are well suited to SDAs and others that are not so much.....
i

Ian Young

08/07/2022, 8:26 AM
Yeah it takes a bit of a mental shift defining assets composed of jobs and ops but it makes a lot of sense. “*If assets are known*” seems to be the golden rule coming through there. 🙂
Which method are you using to deploy Dagster?
b

Ben Gatewood

08/08/2022, 12:17 AM
We run in k8s with separate user code repos based (mostly) on official helm charts
👍 1
d

daniel

08/08/2022, 2:08 PM
Ian one thing I want to make sure is clear is that ops can absolutely call out to other python functions, but everything inside your dagster job does need to happen inside an op. If you put code inside a Dagster job that isn't inside an op, that code will execute when the job is defined, not when you launch a run.
i

Ian Young

08/08/2022, 2:10 PM
@daniel That’s good to know. So as long as I’m pulling in those functions to my ops then all is good?
d

daniel

08/08/2022, 2:11 PM
That's right - I just wanted to make sure you weren't interleaving ops and non-ops within the DAG itself
i

Ian Young

08/08/2022, 2:12 PM
I’m completely new to Dagster and still building my understanding so it may well have been something I tried at some point. 😄 Thanks for the heads-up.