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

cml pr: is racy, generates a PR for different submissions #1126

Open
Tracked by #196
skshetry opened this issue Aug 15, 2022 · 5 comments
Open
Tracked by #196

cml pr: is racy, generates a PR for different submissions #1126

skshetry opened this issue Aug 15, 2022 · 5 comments
Assignees
Labels
cml-pr Subcommand documentation Markdown files

Comments

@skshetry
Copy link
Member

skshetry commented Aug 15, 2022

Sorry for the title. I don't have a good way to express what went wrong here.

This happened twice in ldb-hackathon for me where it generated a PR, where the contents were quite different from the result that I was expecting. In fact, the same contents were already generated before my workflow even ran. I am not quite sure here why cml is creating a PR with content that is already in the repo (even if the git pull is done before cml pr to try to keep the repo in sync).

  1. 13:53 GMT: This PR #94 was published.
  2. 13:55 GMT: Triggered workflow.
  3. 13:57 GMT: Started "evaluate" job/train step.
  4. 16:47:50 GMT: Finished training
  5. 16:47:58 GMT: Created a PR #106 with identical contents to #94.
Run cml pr --rebase 'submissions/*.json'
  cml pr --rebase 'submissions/*.json'
  shell: sh -e {0}
  env:
    AWS_DEFAULT_REGION: us-east-1
    AWS_REGION: us-east-1
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_SESSION_TOKEN: ***
    REPO_TOKEN: ***
{"level":"warn","message":"Failed to enable auto-merge: Enable the feature in your repository settings: https://github.com/iterative/ldb-hackathon/settings#merge_types_auto_merge. Trying to merge immediately..."}
https://github.com/iterative/ldb-hackathon/pull/106(https://github.com/iterative/ldb-hackathon/runs/7807546288?check_suite_focus=true#step:15:6)

Also I am a bit surprised to see cml pr using same branch name for submissions, which may likely be the issue here.
The commits are same and is from earlier time.

@DavidGOrtega DavidGOrtega added the cml-pr Subcommand label Aug 15, 2022
@dacbd
Copy link
Contributor

dacbd commented Aug 15, 2022

cml pr by default bases the branch name off of the forking commit. so if multiple cml pr . invocations occur with the same parent the subsequent runs will fail.

This is/was part of the original design of cml pr for our particular use case with the hackathon it does feel like a bug. There is a --branch option that would have prevented this for example cml pr --branch "cml-$(date +%s)" --rebase "submissions/*.json"

@skshetry
Copy link
Member Author

skshetry commented Aug 15, 2022

@dacbd, thank you for the reply. I am have one more question, why does it create a new PR with the same commit instead of overwriting with a new commit (or, getting push-rejected)? Is this also part of the design decision?

I would have at least expected it to overwrite the old commit, or add on top of it.

@dacbd
Copy link
Contributor

dacbd commented Aug 15, 2022

That logic is programmed in; if that branch exists it will try the print the URL for the PR you can see here:

cml/src/cml.js

Lines 518 to 532 in 7973d0e

const branchExists = (
await exec(
`git ls-remote $(git config --get remote.${remote}.url) ${source}`
)
).includes(source);
if (branchExists) {
const prs = await driver.prs();
const { url } =
prs.find(
(pr) => source.endsWith(pr.source) && target.endsWith(pr.target)
) || {};
if (url) return renderPr(url);
} else {

For the originally reasoning I'm not 100% sure. but I feel like it airs on the side of creating less PR spam if you are say debugging a training pipeline.

@0x2b3bfa0
Copy link
Member

Note for the future

@casperdcl
Copy link
Contributor

Would be great to have docs on this... and also potentially a new command (cml pr update or similar?)

See also SO#70123668

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cml-pr Subcommand documentation Markdown files
Projects
None yet
Development

No branches or pull requests

5 participants