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

[sdk] ExitHandler doesn't compile with task Inputs #10187

Closed
TobiasGoerke opened this issue Oct 31, 2023 · 20 comments · Fixed by #11005
Closed

[sdk] ExitHandler doesn't compile with task Inputs #10187

TobiasGoerke opened this issue Oct 31, 2023 · 20 comments · Fixed by #11005

Comments

@TobiasGoerke
Copy link
Contributor

TobiasGoerke commented Oct 31, 2023

Environment

  • KFP version:
    2.0.3 (manifests v1.8 release)
  • KFP SDK version:
kfp                      2.4.0
kfp-kubernetes           1.0.0
kfp-pipeline-spec        0.2.2
kfp-server-api           2.0.3

Issue is possibly related to #9386.

Steps to reproduce

Execute a pipeline that contains an ExitHandler, whose exit_task takes in an input.

Simple example:

from kfp import dsl
from kfp.compiler import Compiler

@dsl.component
def test_step(input: str) -> str:
    return "test"

@dsl.pipeline
def test_pipeline():
    pre_task = test_step(input="pre")
    # Replacing input with a static import works.
    # Using dsl.Inputs/dsl.Outputs causes the same issue. 
    exit_task = test_step(input=pre_task.output)
    with dsl.ExitHandler(exit_task=exit_task):
        test_step(input="test")


Compiler().compile(test_pipeline, "test_pipeline.yaml")

Expected result

No error on compilation.

Instead:

C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\dsl\component_decorator.py:119: FutureWarning: Python 3.7 has reached end-of-life. The default base_image used by the @dsl.component
decorator will switch from 'python:3.7' to 'python:3.8' on April 23, 2024. To ensure your existing components work with versions of the KFP SDK released after that date, you should provide an explicit base_image argument and ensure your component works as intended on Python 3.8.
  return component_factory.create_component_from_func(
Traceback (most recent call last):
  File "c:\Users\User\Documents\git\rokuto\test.py", line 10, in <module>
    @dsl.pipeline
     ^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\dsl\pipeline_context.py", line 65, in pipeline
    return component_factory.create_graph_component_from_func(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\dsl\component_factory.py", line 669, in create_graph_component_from_func
    return graph_component.GraphComponent(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\dsl\graph_component.py", line 68, in __init__
    pipeline_spec, platform_spec = builder.create_pipeline_spec(
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\compiler\pipeline_spec_builder.py", line 1854, in create_pipeline_spec
    inputs = compiler_utils.get_inputs_for_all_groups(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\compiler\compiler_utils.py", line 266, in get_inputs_for_all_groups
    _get_uncommon_ancestors(
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\kfp\compiler\compiler_utils.py", line 662, in _get_uncommon_ancestors
    raise ValueError(task2.name + ' does not exist.')
ValueError: test-step-2 does not exist.```


---

<!-- Don't delete message below to encourage users to support your issue! -->
Impacted by this bug? Give it a 👍. 
@TobiasGoerke
Copy link
Contributor Author

Is this a duplicate of #9459, @connor-mccarthy?

@TobiasGoerke TobiasGoerke changed the title [sdk] ExitHandler doesn't compile with Inputs [sdk] ExitHandler doesn't compile with task Inputs Oct 31, 2023
@zijianjoy
Copy link
Collaborator

/assign @connor-mccarthy

@connor-mccarthy
Copy link
Member

connor-mccarthy commented Nov 2, 2023

@TobiasGoerke, I don't think this is. This looks like an SDK bug, while #9459 is a FR for the KFP open source backend.

@subasathees
Copy link

Team, Any update on this, default hello-world pipeline is not working on kubeflow v1.8 (pipeline v2.0.3). kindly share the fix for the same.
Notebook Error:
image

@kabartay
Copy link

Got same issue from basic example.

@connor-mccarthy
Copy link
Member

@subasathees, this is a deprecation warning. Consider migrating your components to dsl.component(base_image='python:3.8') to prepare for the change in default value.

@kabartay
Copy link

kabartay commented Dec 14, 2023

@subasathees, this is a deprecation warning. Consider migrating your components to dsl.component(base_image='python:3.8') to prepare for the change in default value.

Thanks for reply. I saw somewhere people discussed it's 3.7 issue and be disappeared once move to 3.8 (2024 I think). But what is strange is that I have 3.11 based custom build image.

@connor-mccarthy
Copy link
Member

@kabartay, is it possible you're using Python 3.7 in your compilation environment, despite using > Python 3.7 for the runtime environment?

@martina-zxy
Copy link

I bumped into the same issue today on Python 3.10, found a workaround by wrapping the tasks (pre_task and exit_task in the example) in a dsl.pipeline and pass it as exit_task to ExitHandler.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the lifecycle/stale The issue / pull request is stale, any activities remove this label. label Mar 14, 2024
Copy link

github-actions bot commented Apr 5, 2024

This issue has been automatically closed because it has not had recent activity. Please comment "/reopen" to reopen it.

@github-actions github-actions bot closed this as completed Apr 5, 2024
@AnnKatrinBecker
Copy link

/reopen

I bumped into the same issue today on Python 3.10, found a workaround by wrapping the tasks (pre_task and exit_task in the example) in a dsl.pipeline and pass it as exit_task to ExitHandler.

The workaround helps, but the original issue does not seem to be resolved.

Copy link

@AnnKatrinBecker: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

I bumped into the same issue today on Python 3.10, found a workaround by wrapping the tasks (pre_task and exit_task in the example) in a dsl.pipeline and pass it as exit_task to ExitHandler.

The workaround helps, but the original issue does not seem to be resolved.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@HumairAK
Copy link
Collaborator

/reopen

@google-oss-prow google-oss-prow bot reopened this May 14, 2024
Copy link

@HumairAK: Reopened this issue.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@github-actions github-actions bot removed the lifecycle/stale The issue / pull request is stale, any activities remove this label. label May 15, 2024
@rimolive
Copy link
Member

rimolive commented Jun 5, 2024

I bumped into the same issue today on Python 3.10, found a workaround by wrapping the tasks (pre_task and exit_task in the example) in a dsl.pipeline and pass it as exit_task to ExitHandler.

Can you help us by providing a code example of that workaround? It will help others to do the same while we work on a fix.

@roytman
Copy link
Contributor

roytman commented Jun 19, 2024

Hi, this issue prevents us from creating a Ray cluster with a unique name at KFP runtime, so we cannot concurrently execute the same KFP pipeline

@hbelmiro
Copy link
Contributor

hbelmiro commented Jul 8, 2024

/assign @hbelmiro

@hbelmiro
Copy link
Contributor

Exit tasks cannot depend on any other tasks. We can see this validation in the code. But that error is not shown. I've sent a PR to fix that.

The problem is in this line:

    exit_task = test_step(input=pre_task.output)

It compiles if we change that line to not depend on pre_task:

    exit_task = test_step(input="some string")

@roytman
Copy link
Contributor

roytman commented Jan 15, 2025

If a dependent task is not part of the ExitHandler, why can't it be supported? We need to provide a runtime-generated value to our ExitHandler function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Closed