Chaitya
03/08/2023, 9:25 PM@classmethod
are thwarted by dagster's argument inference from the function signature.Zach P
03/08/2023, 9:40 PMChaitya
03/08/2023, 9:45 PMclass AbstractNode(ABC):
@op()
@classmethod
def run(cls, context):
# user code here in derived classes
raise NotImplementedError
@classmethod
def some_utility():
...
class MyNode(AbstractNode):
@op()
@classmethod
def run(cls, context):
return some_complex_logic(cls.some_utility(context.op_config["my_param"]))
Chaitya
03/08/2023, 9:46 PMrun
ops are definedZach P
03/08/2023, 10:01 PMIn [16]: class AbstractAssetMixin(AssetsDefinition, ABC):
...: def __init__(self, *args, **kwargs):
...: x = True
...:
In [17]: class MyTeamMixin(AbstractAssetMixin):
...: def must_implement(self):
...: return "hello world"
...:
In [18]: x = MyTeamMixin()
In [19]: isinstance(x, AssetsDefinition)
Out[19]: True
I havent tested it anymore than this, so it may not actually work.chris
03/08/2023, 10:21 PMclass AbstractNode(ABC):
@classmethod
def run(cls, context):
# user code here in derived classes
raise NotImplementedError
@classmethod
def some_utility():
...
@classmethod
def generate_op(cls) -> OpDefinition:
@op
def the_op():
util = cls.some_utility()
cls.run(util)
return the_op
Chaitya
03/08/2023, 10:30 PMChaitya
03/08/2023, 11:07 PMchris
03/08/2023, 11:33 PM