steep-nest-3156
09/24/2024, 12:05 PM@task
class ConfigurableFunction:
def __init__(self, x:int):
self._x = x
def __call__(self, y:int) -> int:
return self._x * y
And then usage
f10 = ConfigurableFunction(10)
f25 = ConfigurableFunction(25)
@workflow
def wf():
a = 10
b = f10(a)
c = f25(b)
return c
freezing-airport-6809
steep-nest-3156
09/24/2024, 12:25 PMbroad-monitor-993
09/24/2024, 1:44 PMbroad-monitor-993
09/24/2024, 1:58 PMloader_args
: method that outputs a list of strings, which provides metadata on which module, contains the task and what the attribute name is in the top-level scope of the module
load_task
: takes the output from loader_args
, imports the module, and plucks the f10
and f25
variables from the module, which is assumed to be initialized instances of ConfigurableFunction
broad-monitor-993
09/24/2024, 1:58 PMtask_cls
or something and iterating from there, similar to the PythonFunctionTask class.steep-nest-3156
09/24/2024, 2:06 PMbroad-monitor-993
09/24/2024, 2:17 PMbroad-monitor-993
09/24/2024, 2:19 PMsteep-nest-3156
09/24/2024, 2:33 PMflykit.core.python_auto_container.default_task_resolver
is importable in the pod?
How can I achieve the same with custom task resolver?broad-monitor-993
09/24/2024, 2:46 PMentrypoint.py
: https://github.com/flyteorg/flytekit/blob/15dee9579a000696539b63745d0d036647987c0e/flytekit/bin/entrypoint.py#L392-L396
So as long as the task and its resolver are defined and loadable in your container via pyflyte run
or pyflyte register
it should work.
Best way to iterate on this is using the flyte sandbox.
I’d start by just subclassing PythonFunctionTask
and supplying your own task resolver (just a copy of the default task resolver) into it to get a sense of how it works. Then start modifying the resolver and the PythonFunctionTask
subclass to work with classes instead of functions.broad-monitor-993
09/24/2024, 2:47 PMsteep-nest-3156
09/24/2024, 3:03 PM