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

Fix special compilation cases for kfp samples #91

Merged
merged 8 commits into from
Apr 20, 2020
Merged

Fix special compilation cases for kfp samples #91

merged 8 commits into from
Apr 20, 2020

Conversation

drewbutlerbb4
Copy link
Member

Fixes the testing of kfp samples for pipelines that require special compilation instructions.

Specifically these include;
compose.py
basic_no_decorator.py

@kubeflow-bot
Copy link

This change is Reviewable

Copy link
Member

@Tomcli Tomcli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sdk/python/tests/test_util.py Outdated Show resolved Hide resolved
sdk/python/tests/test_util.py Outdated Show resolved Hide resolved
sdk/python/tests/test_kfp_samples.sh Outdated Show resolved Hide resolved
Generalize for any nested pipeline or pipeline without a decorator as long as there is a config file with the necessary information to compile the pipelines
also fix test_kfp_samples_report.txt
@drewbutlerbb4
Copy link
Member Author

@Tomcli I believe I have addressed your comments. I can't test on either of the linked pipelines because they have functionality that kfp-tekton can't currently compile (exithandler and input artifacts). I will make another pipeline and test on that shortly.

Copy link
Member

@Tomcli Tomcli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @drewbutlerbb4, this is great. For the other 2 pipelines in the samples folder, we can add them in when exitOp and input artifacts are ready.

sdk/python/kfp_tekton/compiler/compiler.py Outdated Show resolved Hide resolved
@Tomcli
Copy link
Member

Tomcli commented Apr 14, 2020

/lgtm

@Tomcli
Copy link
Member

Tomcli commented Apr 14, 2020

/assign @animeshsingh

if dsl-compile-tekton --py "${f}" --output "${TEKTON_COMPILED_YAML_DIR}/${f##*/}.yaml" >> "${COMPILER_OUTPUTS_FILE}" 2>&1;
then
echo "SUCCESS: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
IS_SPECIAL=$(grep -E ${f##*/} <<< ${PIPELINES})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the test_kfp_samples.sh script, why do we not just generate PipelineRun for all testdata scripts and only change one line:

  if dsl-compile-tekton --py "${f}" --output "${TEKTON_COMPILED_YAML_DIR}/${f##*/}.yaml" >> "${COMPILER_OUTPUTS_FILE}" 2>&1;

to

  if dsl-compile-tekton --generate-pipelinerun --py "${f}" --output "${TEKTON_COMPILED_YAML_DIR}/${f##*/}.yaml" >> "${COMPILER_OUTPUTS_FILE}" 2>&1;

There is no need or benefit to have a mix here, since we will catch the NotImplementedErrors either way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I do not understand, but wouldn't this still fail to compile basic_no_decorator.py and compose.py?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Andrew, yes, I wrote that comment before understanding the full purpose of your test_util.py. But let me explain the my bigger point below

@@ -0,0 +1,102 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we not move these tests into our standard compiler test suite?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the two functions test_workflow_without_decorator and test_nested_workflow into the actual compiler unit test and have the test_util.py call them and capture the output YAML into a file, like dsl-compile does

@ckadner
Copy link
Member

ckadner commented Apr 15, 2020

Hi Andrew,

I think the code you wrote in test_util.py is good but it should really be part of our unit test suite for the compiler. In fact the KFP testdata scripts are meant to be used in the compiler unit tests where all the negative cases and special parameters are handled.

The test_kfp_samples.sh script was really just intended to show us which features still need to be implemented on the compiler and give us a kind of score card. It was not the intention to do all we can to make all tests succeed just to make sure we know what was not yet working.

We are at a time in the project where we should add all KFP unit tests in our unit test suite and use that to measure our progress.

On another tangent I have been using the test_kfp_samples.sh script locally to run the compiler over all DSL samples in the KFP repository to get a better sense of which features are actually used by KFP consumers and then use some bash scripting to dissect the compiler console output to computer a list of all errors. See this comment and below on issue #18. I wanted to make that public but it now is kind of conflicting with your change, so I admit some bias on my part :-)

@drewbutlerbb4
Copy link
Member Author

Thanks for the explanation Christian I now understand your point of view better. I agree that this could be placed in the compiler tests along with some new example pipelines and that could help improve our testing.

However I am not entirely sure it shouldn't be included in the test_kfp_samples.sh as well. Based on discussions from our meetings, I believe the output of this script (as well as your new improvements) is being used as a metric to judge the progress of this project by people not working day-to-day on the kfp-tekton? Wouldn't it then be confusing to these people to see pipelines failing when they shouldn't be?

I would like to get @Tomcli opinion on your comments because, admittedly I'm not entirely sure this was the intention when I was assigned this work. That being said I'll defer to @ckadner and @Tomcli on this one.

@Tomcli
Copy link
Member

Tomcli commented Apr 15, 2020

@ckadner I agree we can also use test_util.py as part of our unit test suite for the compiler, but we should also leverage it in test_kfp_samples.sh for the metrics because nested pipelines and no decorator pipelines need special ways to compile them. If you compile them using the regular dsl-compile or dsl-compile-tekton, you will see the below 2 errors

   1 ValueError: There are multiple pipelines: ['save_most_frequent_word', 'download_save_most_frequent_word']. Please specify --function.
   1 ValueError: A function with @dsl.pipeline decorator is required in the py file.

Therefore, I asked Andrew to take those special compile cases and generalize it. This way we can update the list of nested pipelines and no decorator pipelines in the config.yaml and compile them with the required parameters.

Copy link
Member

@ckadner ckadner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, lets do both: integrate the special test handling in the report script and add 2 unit test cases :-)

else
echo "FAILURE: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
python3 -m test_util ${f} ${CONFIG_FILE} | grep -E 'SUCCESS:|FAILURE:'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should move up so we can capture the entire output of the compile run in the ${COMPILER_OUTPUTS_FILE}, not just the SUCCESS or FAILURE. The python3 command should return an exit value of 0 for success and 1 for failure

Maybe we could use a ternary stile approach:

    if ([ -z "${IS_SPECIAL}" ] \
        && dsl-compile-tekton --py "${f}" --output "${TEKTON_COMPILED_YAML_DIR}/${f##*/}.yaml" \
        || python3 -m test_util ${f} ${CONFIG_FILE} ) >> "${COMPILER_OUTPUTS_FILE}" 2>&1 ;
    then
      echo "SUCCESS: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
    else
      echo "FAILURE: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
    fi

...or better.. wrap the compile part into a bash function and inside that function check for IS_SPECIAL:

function compile_dsl {
  if [ -z "${IS_SPECIAL}" ]; then
    dsl-compile-tekton --py "$1" --output "$2"
  else
    python3 -m test_util $1 ${CONFIG_FILE} # need to produce YAML file output
  fi
} 

# ...

    if compile_dsl "${f}" "${TEKTON_COMPILED_YAML_DIR}/${f##*/}.yaml" >> "${COMPILER_OUTPUTS_FILE}" 2>&1 ;
    then
      echo "SUCCESS: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
    else
      echo "FAILURE: ${f##*/}" | tee -a "${COMPILER_OUTPUTS_FILE}"
    fi

@@ -0,0 +1,102 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move the two functions test_workflow_without_decorator and test_nested_workflow into the actual compiler unit test and have the test_util.py call them and capture the output YAML into a file, like dsl-compile does

@ckadner
Copy link
Member

ckadner commented Apr 16, 2020

@drewbutlerbb4 -- I realize I am requesting substantial changes to your PR, some of which are quite aspirational and could be scoped out into a separate PR. Since I am working on another PR in the test_kfp_samples.sh script anyway, I could incorporate those changes there and we can merge your PR as is. What do you think?

So, 3 stages:

  1. we merge your PR as is
  2. I create a PR that makes the tesk_kfp_samples.sh work with exit codes and compiler output (along with the actual changes I need for the report)
  3. you or I create a PR that refactors your test_util.py in a way that the actual test cases move into our compiler unit test suite and the the test_util.py becomes only a thin shim that runs the test methods and makes sure we get the right exit code and the compiled output YAML with the similar parameters as dsl-compile does

@drewbutlerbb4
Copy link
Member Author

Sure that works for me

Copy link
Member

@ckadner ckadner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to merge this PR and incorporate further changes in subsequent PRs

Thanks @drewbutlerbb4

/lgtm
/assign @animeshsingh

@ckadner ckadner removed their assignment Apr 16, 2020
@animeshsingh
Copy link
Collaborator

/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: animeshsingh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 6aa7ed3 into kubeflow:master Apr 20, 2020
HumairAK referenced this pull request in red-hat-data-services/data-science-pipelines-tekton May 16, 2023
gmfrasca pushed a commit to gmfrasca/data-science-pipelines-tekton that referenced this pull request Aug 25, 2023
…ecrets

feat(backend): Source ObjStore Creds from Env in Tekton Template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants