#3492 [Core feature] Add the support for defining/declaring tasks in classes
Issue created by
XinEDprob
### Motivation: Why do you think this is important?
I wanted to build a Flyte pipeline for an existing project and I noticed that there are lots of classes in this project. If the Flyte can not support the code like the following:
from flytekit import workflow, task
class MyClass:
@task
def t1(self):
return 'hello world'
@workflow
def wf():
MyClass().t1()
there will be lots of work for us as we need to convert all the classes to functions so that these functions can be decorated as tasks. I believe this feature is important for the following reasons:
• Encourage people to build more Flyte pipelines for the existing projects
• The code will be more organized and concise
### Goal: What should the final outcome look like, ideally?
In the end, I hope Flyte can support something like the following
from flytekit import workflow, task
class MyClass:
@task
def t1(self):
return 'hello world'
@workflow
def wf():
MyClass().t1()
That is to define tasks within classes
### Describe alternatives you've considered
I don't think I have any alternative for this issue.
### Propose: Link/Inline OR Additional context
No response
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flyte