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

Add argo variable checking when compile to Tekton. #80

Merged
merged 7 commits into from
Apr 3, 2020

Conversation

Tomcli
Copy link
Member

@Tomcli Tomcli commented Apr 2, 2020

Which issue is resolved by this Pull Request:
Related #78

Description of your changes:
Currently this is the equivalent variable matching i found.
argo -> tekton
{{inputs.parameters.%s}} -> $(inputs.params.%s)
{{outputs.parameters.%s}} -> $(results.%s.path)

Since we don't have other equivalent matching for the rest of the argo variables, we will prompt a warning when those argo variables are used. KFP also don't recommend to use argo variables because it requires specific knowledge on Argo pipeline.

Out of all the kfp examples, only a very few of them are using Argo variables. e.g. https://github.com/kubeflow/pipelines/blob/master/samples/contrib/nvidia-resnet/pipeline/src/pipeline.py
In this case we will prompt the following warning:

Applying KFP-Tekton compiler patch
KFP-Tekton Compiler 0.0.1
WARNING:root:These Argo variables are not supported in Tekton Pipeline: {{workflow.name}}

The other places that use Argo variables are during artifact storing and pipeline placeholder. We could create our own tasks to avoid using Argo specific variables on these features as mentioned in #78.

Environment tested:

  • Python Version (use python --version): 3.6.4
  • Tekton Version (use tkn version): 0.11
  • Kubernetes Version (use kubectl version): 1.15
  • OS (e.g. from /etc/os-release):

@kubeflow-bot
Copy link

This change is Reviewable


unsupported_vars = re.findall(r"{{[^ \t\n:,;{}]+}}", workflow_dump)
if unsupported_vars:
logging.warning('These Argo variables are not supported in Tekton Pipeline: %s' % ", ".join(str(v) for v in set(unsupported_vars)))
Copy link
Member

Choose a reason for hiding this comment

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

I am assuming that if one of the Argo specific variables is not supported, then the resulting Tekton pipeline does not behave in the way the author of the Python DSL script intended it to behave. In which case I think should be a little stronger here and raise TypeError or raise ValueError or even raise AttributeError. No?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me see is there other places that rely on this. If not then I can change it to raise and exit.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed to raise error now.

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

ckadner commented Apr 3, 2020

Hi @Tomcli,
do you have a list of all the valriable expressions which cannot be translated to Tekton?

And if/when you do, are there issues tracking whether those might be in the works by the Tekton team?

@Tomcli
Copy link
Member Author

Tomcli commented Apr 3, 2020

The list is basically this whole page minus the two I implemented above.
https://github.com/argoproj/argo/blob/master/docs/variables.md

A lot of these variables might not even make sense in Tekton, and most kfp pipelines try to avoid using variables that only Argo could understand.

@Tomcli
Copy link
Member Author

Tomcli commented Apr 3, 2020

Some variables such as task name is already been requested in issue such as tektoncd/pipeline#2294. We can also open another issue on Tekton for this to track what variables can we support.

@Tomcli
Copy link
Member Author

Tomcli commented Apr 3, 2020

I opened a related issue at Tekton tektoncd/pipeline#2322

@ckadner ckadner mentioned this pull request Apr 3, 2020
27 tasks
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.

great, just a tiny update on the comment wording "prompt warning" vs "raise error"

# Use regex to replace all the Argo variables to Tekton variables.
# For variables that are unique to Argo, we prompt a warning to warn users on the non-supported variables.
# Use regex to replace all the Argo variables to Tekton variables. For variables that are unique to Argo,
# we prompt a warning to warn users on the non-supported variables. Here is the list of Argo variables.
Copy link
Member

Choose a reason for hiding this comment

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

"# we raise an Error to alert users about the unsupported" ... :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks christian.

@@ -209,7 +209,7 @@ def _create_pipeline_workflow(self, args, pipeline, op_transformers=None, pipeli

unsupported_vars = re.findall(r"{{[^ \t\n:,;{}]+}}", workflow_dump)
if unsupported_vars:
logging.warning('These Argo variables are not supported in Tekton Pipeline: %s' % ", ".join(str(v) for v in set(unsupported_vars)))
raise ValueError('These Argo variables are not supported in Tekton Pipeline: %s' % ", ".join(str(v) for v in set(unsupported_vars)))
Copy link
Member

Choose a reason for hiding this comment

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

👍

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.

Great. Thanks @Tomcli !

/lgtm
/assign @animeshsingh

@ckadner ckadner removed their assignment Apr 3, 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 3328818 into kubeflow:master Apr 3, 2020
@Tomcli Tomcli deleted the vars branch May 20, 2020 17:20
gmfrasca pushed a commit to gmfrasca/data-science-pipelines-tekton that referenced this pull request May 16, 2023
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.

5 participants