Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Dynamic tasks fail if function name is too long #1306

Closed
kimoktm opened this issue Aug 3, 2021 · 5 comments
Closed

[BUG] Dynamic tasks fail if function name is too long #1306

kimoktm opened this issue Aug 3, 2021 · 5 comments
Assignees
Labels
bug Something isn't working flytekit FlyteKit Python related issue

Comments

@kimoktm
Copy link

kimoktm commented Aug 3, 2021

Describe the bug
Dynamic tasks workflow fails, raising malformed dynamic workflow error when the dynamic task function name is 52 characters or longer.

Raised error:

[User] malformed dynamic workflow, caused by: Collected Errors: 3
	Error 0: Code: NodeReferenceNotFound, Node Id: f1waozpy, Description: Referenced node [f1waozpy] not found.
	Error 1: Code: NodeReferenceNotFound, Node Id: fequ45eq, Description: Referenced node [fequ45eq] not found.
	Error 2: Code: NodeReferenceNotFound, Node Id: fzzt6uqq, Description: Referenced node [fzzt6uqq] not found.

Expected behavior
The dynamic workflow should work even if function names are longer than 52 characters

Additional context
To Reproduce
Here is a quick snippet to reproduce the issue:

@flytekit.task
def count_length(a: Dict[str, str]) -> FlyteFile:
    ctx = flytekit.current_context()
    working_dir = ctx.working_directory
    fname = os.path.join(working_dir, a["name"])
    fname = fname + ".json"
    ctx.logging.warning(f"Working dir is: {working_dir} Filename is: {fname}")
    with open(fname, "w") as fh:
        fh.write(f"{len(a['role'])}\n")

    return fname


@flytekit.workflow
def wf_demo(wf_in1: Dict[str, str]) -> FlyteFile:
    return count_length(a=wf_in1)


wf_default = flytekit.LaunchPlan.get_or_create(wf_demo)


@flytekit.dynamic
def abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz(data: str) -> List[FlyteFile]:
    ctx = flytekit.current_context()
    working_dir = ctx.working_directory
    file_path = os.path.join(working_dir, "file")

    with open(file_path, "w") as data_file:
        data_file.write(data.replace(".", "\n"))

    result_files: List[FlyteFile] = []
    with open(file_path) as f:
        reader = DictReader(f, delimiter=",")
        for row in reader:
            result_file = wf_default(wf_in1=row)
            result_files.append(result_file)
    return result_files


if __name__ == "__main__":
    data = "name,role.alice,sender.bob,receiver.eve,eavesdropper"
    out = abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz(data=data)
    print(out)

Renaming the dynamic task from abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz to abc or anything shorter than 52 characters will lead to a successful execution.

Screenshots
Screenshot 2021-08-03 at 12 33 52

@kimoktm kimoktm added bug Something isn't working untriaged This issues has not yet been looked at by the Maintainers labels Aug 3, 2021
@welcome
Copy link

welcome bot commented Aug 3, 2021

Thank you for opening your first issue here! 🛠

@kumare3
Copy link
Contributor

kumare3 commented Aug 4, 2021

@kimoktm thank you for the issue, we will definitely look into this soon, but as a work-around if you name the task something smaller does it work?
also cc @katrogan / @EngHabu

@kumare3 kumare3 removed the untriaged This issues has not yet been looked at by the Maintainers label Aug 5, 2021
@kumare3 kumare3 added this to the 0.17.0 milestone Aug 5, 2021
@kimoktm
Copy link
Author

kimoktm commented Aug 9, 2021

@kimoktm thank you for the issue, we will definitely look into this soon, but as a work-around if you name the task something smaller does it work?
also cc @katrogan / @EngHabu

Thanks for looking into it @kumare3!
Yes, renaming the task a shorter name works fine, so I'm not currently blocked

@wild-endeavor wild-endeavor added the flytekit FlyteKit Python related issue label Aug 19, 2021
@EngHabu EngHabu modified the milestones: 0.17.0, 0.18.0 Sep 1, 2021
@pingsutw
Copy link
Member

pingsutw commented Sep 2, 2021

I found that this bug also occurs in "@task"

Traceback (most recent call last):
  File "/opt/venv/bin/pyflyte-execute", line 8, in <module>
    sys.exit(execute_task_cmd())
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/bin/entrypoint.py", line 486, in execute_task_cmd
    _execute_task(
  File "/opt/venv/lib/python3.8/site-packages/flytekit/common/exceptions/scopes.py", line 160, in system_entry_point
    return wrapped(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/bin/entrypoint.py", line 391, in _execute_task
    _task_def = resolver_obj.load_task(loader_args=resolver_args)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/core/python_auto_container.py", line 185, in load_task
    task_def = getattr(task_module, task_name)
AttributeError: module 'myapp.workflows.example' has no attribute 'say_hellooooooooooooooooooo'Traceback (most recent call last):
  File "/opt/venv/bin/pyflyte-execute", line 8, in <module>
    sys.exit(execute_task_cmd())
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/bin/entrypoint.py", line 486, in execute_task_cmd
    _execute_task(
  File "/opt/venv/lib/python3.8/site-packages/flytekit/common/exceptions/scopes.py", line 160, in system_entry_point
    return wrapped(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/bin/entrypoint.py", line 391, in _execute_task
    _task_def = resolver_obj.load_task(loader_args=resolver_args)
  File "/opt/venv/lib/python3.8/site-packages/flytekit/core/python_auto_container.py", line 185, in load_task
    task_def = getattr(task_module, task_name)
AttributeError: module 'myapp.workflows.example' has no attribute 'say_hellooooooooooooooooooo'

Example:

import typing

from flytekit import task, workflow

@task
def say_hellooooooooooooooooooo(name: str) -> str:
    return f"hello world, {name}"

@workflow
def my_wf(name: str) -> str:
    return say_hellooooooooooooooooooo(name=name)

if __name__ == "__main__":
    print(f"Running my_wf(name='adam') {my_wf(name='adam')}")

@eapolinario eapolinario self-assigned this Sep 7, 2021
@eapolinario eapolinario removed this from the 0.18.0 milestone Oct 6, 2021
@kumare3
Copy link
Contributor

kumare3 commented Oct 14, 2021

@eapolinario my recent fix in progress might fix this issue as well. flyteorg/flytekit#705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flytekit FlyteKit Python related issue
Projects
None yet
Development

No branches or pull requests

6 participants