Skip to content

Conversation

@zhouzhuojie
Copy link
Contributor

@zhouzhuojie zhouzhuojie commented Apr 30, 2021

Changes

This PR migrates pytorch_python_doc_build from circleci to github actions.

Noticeable changes

  • Refactor docker cp into a single docker run with volume mount, because the in circleci volume is not accessible from its remote docker engine
  • pytorch_python_doc_push job will have a race condition with circleci, which will be migrated in separate PRs

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 30, 2021

💊 CI failures summary and remediations

As of commit 4c5fe73 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 2 times, most recently from bf4a5f6 to 7d33d8d Compare May 3, 2021 02:59
@codecov
Copy link

codecov bot commented May 3, 2021

Codecov Report

Merging #57371 (4c5fe73) into master (d212bf1) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #57371   +/-   ##
=======================================
  Coverage   76.83%   76.83%           
=======================================
  Files        1986     1986           
  Lines      197988   197988           
=======================================
+ Hits       152115   152131   +16     
+ Misses      45873    45857   -16     

@zhouzhuojie zhouzhuojie changed the title Migrate pytorch_python_doc_build to github action DO NOT MERGE - Migrate pytorch_python_doc_build to github action May 3, 2021
@zhouzhuojie zhouzhuojie marked this pull request as ready for review May 3, 2021 16:39
@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch from 7d33d8d to be3ffae Compare May 3, 2021 18:11
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here's a job if condition that doc_push only runs on master

@zhouzhuojie
Copy link
Contributor Author

@seemethere updated, and moved to the same workflow as the previous python CI workflow so that they can share the artifacts. May need your approval again for the new workflows

@zhouzhuojie
Copy link
Contributor Author

Oh, there's a template to generate this, hold on, will move the code there

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 2 times, most recently from 10f1da9 to 36caf82 Compare May 3, 2021 18:42
@zhouzhuojie
Copy link
Contributor Author

Oh, there's a template to generate this, hold on, will move the code there

Migrated to linux_ci_workflow.yml.in, and decouples doc build from tightly coupled with pytorch-linux-xenial-py3.6-gcc5.4, and instead just make it as a template rendering option enable_doc_jobs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can also move cpp docs job to here in the future

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch from 36caf82 to a414c14 Compare May 4, 2021 18:04
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the secrets GITHUB_PYTORCHBOT_TOKEN needs to be set up first before merging

@samestep
Copy link
Contributor

samestep commented May 4, 2021

question: why is the docs build being added as a gated job inside the .github/templates/linux_ci_workflow.yml.in file, rather than as its own new template? I guess it's just because it depends on having the build already done?

(cc @seemethere)

@samestep
Copy link
Contributor

samestep commented May 4, 2021

also, I have enabled GitHub Actions to run on this PR; when you have the chance, could you fix the lints? https://github.com/pytorch/pytorch/runs/2504623867

see this section in CONTRIBUTING.md for tips on how to more easily run the lints locally; in this case, you could probably fix the trailing whitespace one by dedenting the {% if enable_doc_jobs %} line, and the trailing newlines one (currently hidden by the ShellCheck failure, but i'm guessing it would be failing) by maybe just adding a YAML comment to the end of the .github/templates/linux_ci_workflow.yml.in file

@samestep
Copy link
Contributor

samestep commented May 4, 2021

currently hidden by the ShellCheck failure, but i'm guessing it would be failing

@pytorch/pytorch-dev-infra I am currently working on #57572 which should resolve this ergonomics issue

@zhouzhuojie
Copy link
Contributor Author

question: why is the docs build being added as a gated job inside the .github/templates/linux_ci_workflow.yml.in file, rather than as its own new template? I guess it's just because it depends on having the build already done?

(cc @seemethere)

Originally, I was implementing it in its own workflow, later I was debugging it and I agreed with @seemethere's comment that we can put the docs build together with linux_ci_workflow.yml.in, maybe they can share more steps together.

But, the only dependencies that the doc build job requires is a calculate-docker-image to figure out the target docker image, other build artifacts like the built docs repo can be encapsulated into the dedicated docs related workflow.

I can refactor this and make it cleaner.

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 3 times, most recently from 9be290e to 7a2ba0c Compare May 5, 2021 00:55
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO, this may also need to include the cases for

- refs/heads/master
- refs/tags/vx.y.z
- refs/tags/vx.y.z-rc

Copy link
Contributor

Choose a reason for hiding this comment

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

please add a todo comment

# TODO: add tags doc push for regex: `v[0-9]+(\.[0-9]+)*-rc[0-9]+`

also currently doc push is only enabled on nightly instead of master, should we change this to nightly?

@samestep
Copy link
Contributor

samestep commented May 5, 2021

Originally, I was implementing it in its own workflow, later I was debugging it and I agreed with @seemethere's comment that we can put the docs build together with linux_ci_workflow.yml.in, maybe they can share more steps together.

makes sense; thanks!

But, the only dependencies that the doc build job requires is a calculate-docker-image to figure out the target docker image, other build artifacts like the built docs repo can be encapsulated into the dedicated docs related workflow.

either way sounds good to me :)

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch from 7a2ba0c to 2fed6f4 Compare May 5, 2021 15:53
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be dependent on the build stage since building the docs requires a binary, you can reference the test stage to see how to download the artifacts from the build stage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, yes sure, I may need to figure out how to iterate this faster

every change requires approvals - so each iteration requires a few hours of wait - anything special I can do to test the flow e2e on my own before requiring your review time?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this is unfortunately a pain point that we haven't yet solved; one hacky solution we could take in the short-term is have you make a tiny cosmetic diff and Jedi-land it so that GitHub no longer thinks you're a "first-time contributor", after which (I hope) you wouldn't need approval to run CI on this PR; @seemethere what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

as for running locally, I don't think we have a good solution for that yet either (but I could be wrong)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tested a few times, and yes, indeed it requires the artifacts generated from the build step, I updated and may need a new approval for the workflows.

Noticeable changes are

  • refactor docker cp into a single docker run
  • download artifacts from build step and mount as a volume
  • change from sh to bash to run in docker as it requires pushd which is a bash-only command
  • refactor circleci tag into GITHUB_REF - as gha only supports git ref

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To pass the "first-time contributor" PR #57779

Copy link
Member

Choose a reason for hiding this comment

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

Can you see if you can simplify this docker logic here?

It'd be a good question to ask what it actually is trying to do and recreate the most minimally viable script from that.

For example, are the docker cp commands actually necessary here? Is the export id=$(docker run....) actually necessary or can we do it in a more simplistic docker run command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, did that, the only reason docker cp is necessary in circleci is that their docker engine is wired remotely - https://circleci.com/docs/2.0/building-docker-images/#mounting-folders. While github action docker is running locally and volume mount is doable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

generated from .github/scripts/regenerate_cancel_redundant_workflow.py

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 2 times, most recently from fb801b7 to df3cfd3 Compare May 6, 2021 22:26
@samestep
Copy link
Contributor

samestep commented May 6, 2021

now that #57779 is merged, hopefully it should automatically run GHA workflows for you without someone else having to approve them... if not then I'll be sad haha

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 4 times, most recently from d702293 to 82af939 Compare May 10, 2021 17:03
@zhouzhuojie zhouzhuojie changed the title DO NOT MERGE - Migrate pytorch_python_doc_build to github action Migrate pytorch_python_doc_build to github action May 10, 2021
Copy link
Member

Choose a reason for hiding this comment

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

I think we probably don't need to do this here, the reason we were doing the whole docker commit && docker push was to preserve artifacts from one stage to another

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for feature parity from circleci jobs. I think it can be useful if people rely on this debug image for quick iteration on their docs. Should we still remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just checked that the ecr user in gha doesn't have push permission, will remove this then

@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch 2 times, most recently from 718d399 to fcccfef Compare May 12, 2021 17:30
@zhouzhuojie zhouzhuojie force-pushed the zz/migrate-py-doc-build-gha branch from fcccfef to 4c5fe73 Compare May 13, 2021 16:45
@facebook-github-bot
Copy link
Contributor

@zhouzhuojie has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@zhouzhuojie merged this pull request in 7756cb6.

@zhouzhuojie zhouzhuojie deleted the zz/migrate-py-doc-build-gha branch May 13, 2021 22:46
krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
Summary:
# Changes

This PR migrates `pytorch_python_doc_build` from circleci to github actions.

Noticeable changes
- Refactor `docker cp` into a single `docker run` with volume mount, because the in circleci volume is not accessible from its remote docker engine
- `pytorch_python_doc_push` job will have a race condition with circleci, which will be migrated in separate PRs

Pull Request resolved: pytorch#57371

Reviewed By: samestep

Differential Revision: D28416289

Pulled By: zhouzhuojie

fbshipit-source-id: 04caccccf3d7eb7e2225846a406a53ccda356d44
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