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

Loop ranges should handle from = to, and generate one iteration. #941

Merged
merged 4 commits into from
May 18, 2022

Conversation

ScrapCodes
Copy link
Contributor

@ScrapCodes ScrapCodes commented May 16, 2022

Which issue is resolved by this Pull Request:
Resolves #935

Description of your changes:
Where start = 0 and end = 0, generate one iteration.
Environment tested:

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

Checklist:

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ScrapCodes

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

@@ -892,6 +892,11 @@ func computeIterations(run *v1alpha1.Run, tls *pipelineloopv1alpha1.PipelineLoop
}
}
}
if from == to && to == 0 && step != 0 {
Copy link
Member

@Tomcli Tomcli May 16, 2022

Choose a reason for hiding this comment

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

I think the use case is when from == to, then the iteration is equals to 1. to doesn't have to be 0.

Another edge case could be that to - from < step if step > 0 and to - from > step if step < 0, then the iteration is also 1.

@google-oss-prow google-oss-prow bot added size/M and removed size/S labels May 16, 2022
@ScrapCodes ScrapCodes changed the title Loop ranges should handle start = 0 and end = 0, should generate one… Loop ranges should handle from = to, and generate one iteration. May 16, 2022
@Tomcli
Copy link
Member

Tomcli commented May 17, 2022

thanks @ScrapCodes , overall it looks good to me. just one small question for the unit test above.

@Tomcli
Copy link
Member

Tomcli commented May 18, 2022

thanks @ScrapCodes
/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label May 18, 2022
@google-oss-prow google-oss-prow bot merged commit 27db2e3 into kubeflow:master May 18, 2022
wzhanw pushed a commit to wzhanw/kfp-tekton that referenced this pull request May 20, 2022
…eflow#941)

* Loop ranges should handle start = 0 and end  = 0, should generate one iteration.

* When from = to, then generate one iteration. emulating how enumerate works.

* Fixed edge cases.

* if from and to are unset, we should not pick defaults either.
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.

Loop.range generates inconsistent number of iterations when start=end
2 participants