Giang Hoang Le
12/10/2019, 11:03 PMJeremiah
12/10/2019, 11:05 PMTask
class and subclass it with normal Python inheritance.@task
decorator and most examples that call tasks like functions show a “functional API” but the “imperative API” embraces the full class-based set up (https://docs.prefect.io/core/getting_started/first-steps.html#imperative-api).Giang Hoang Le
12/10/2019, 11:08 PMJeremiah
12/10/2019, 11:34 PM@staticmethod and @task
then I’m sure it would work. If they are classmethods
or “normal” methods then the first argument might create an issue@task
Giang Hoang Le
12/10/2019, 11:36 PMJeremiah
12/10/2019, 11:38 PMTask
objects, call them, and return them, something like:class Source:
def transform(self, x):
# some logic that depends on Source
task = MyTransformTaskClass()
return task(x)
Giang Hoang Le
12/10/2019, 11:40 PMJeremiah
12/10/2019, 11:40 PMTask
itself is a full class so it will be difficult for it to exist exclusively as a method of another class. However, @staticmethod
+ @task
is one way to get there (but, because its a staticmethod, you won’t be able to access the parent Source)
Source
to parameterize your “factory methods” that generate and return tasks dynamically depending on how Source
was initializedGiang Hoang Le
12/11/2019, 12:34 AM