Giang Hoang Le
12/10/2019, 11:03 PMJeremiah
Task
class and subclass it with normal Python inheritance.Jeremiah
@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 PMGiang Hoang Le
12/10/2019, 11:08 PMGiang Hoang Le
12/10/2019, 11:32 PMJeremiah
@staticmethod and @task
then I’m sure it would work. If they are classmethods
or “normal” methods then the first argument might create an issueJeremiah
@task
Giang Hoang Le
12/10/2019, 11:36 PMGiang Hoang Le
12/10/2019, 11:37 PMJeremiah
Task
objects, call them, and return them, something like:Jeremiah
class Source:
def transform(self, x):
# some logic that depends on Source
task = MyTransformTaskClass()
return task(x)
Jeremiah
Giang Hoang Le
12/10/2019, 11:40 PMJeremiah
Task
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)
Jeremiah
Source
to parameterize your “factory methods” that generate and return tasks dynamically depending on how Source
was initializedJeremiah
Jeremiah
Giang Hoang Le
12/11/2019, 12:34 AM