Hi flyte community! I have a question about the re...
# ask-the-community
x
Hi flyte community! I have a question about the resolver path. I noticed that if I use
pyflyte register
to register the workflow, the resolver path would be
app.<…>.default_task_resolver
, but if programmatically register workflow using
register_workflow()
, the resolver path would be
module.<…>.default_task_resolver
(
module
being the root of the workflow code). Is there a way to change the resolver path back to
app
if I use
register_workflow
?
y
can you elaborate a bit more? what is this default_task_resolver?
can you maybe copy paste in a
tree
structure and some sample repro code?
x
Sorry for the late reply I was distracted yesterday. To be more specific, if I register programmatically using
register_workflow
, and the resolver path would be
run_my_workflow.pip_pypi__flytekit.flytekit.core.python_auto_container.default_task_resolver
. And
run_my_workflow
is the parent directory bazel target name of the script (same as the script name in this case) that calls
register_workflow
And if I register my workflow using CLI
pyflyte register
, the resolver path in the task would look like
app.pip_pypi__flytekit.flytekit.core.python_auto_container.default_task_resolver
So I wonder if I can set the root of the resolver path to
app
when calling
register_workflow
I will come up with a repro in a bit. Thanks for the help in advance!
y
also are you using conda or pip?
i’m not too familiar with conda
x
pip, but actually, it’s bazel-pip
I think I figured out how to override the default resolver, just need to override the
location
in the
DefaultTaskResolver
Here is my solution:
Copy code
TASK_RESOLVER_LOCATION = "app.pip_pypi__flytekit.flytekit.core.python_auto_container.default_task_resolver"
class CustomTaskResolver(DefaultTaskResolver):
    def __init__(self, *args, resolver_location = TASK_RESOLVER_LOCATION, **kwargs):
        super().__init__(*args, **kwargs)
        self.resolver_location = resolver_location

    @property
    def location(self) -> str:
        return self.resolver_location
    

@task(task_resolver=CustomTaskResolver())
def my_task(a: int, b: int) -> int:
    return a + b


@task(task_resolver=CustomTaskResolver())
def my_other_task(m: int, n: int) -> int:
    return 2 * (m - n)
153 Views