Skip to content

pre-download model weights in CI docs build #5625

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

Merged
merged 4 commits into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions .circleci/config.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 24 additions & 9 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,26 @@ commands:
- store_test_results:
path: test-results

download_model_weights:
parameters:
extract_roots:
type: string
default: "torchvision/models"
background:
type: boolean
default: true
steps:
- apt_install:
args: parallel wget
descr: Install download utilitites
- run:
name: Download model weights
background: << parameters.background >>
command: |
mkdir -p ~/.cache/torch/hub/checkpoints
python scripts/collect_model_urls.py << parameters.extract_roots >> \
| parallel -j0 'wget --no-verbose -O ~/.cache/torch/hub/checkpoints/`basename {}` {}\?source=ci'

binary_common: &binary_common
parameters:
# Edit these defaults to do a release
Expand Down Expand Up @@ -340,14 +360,8 @@ jobs:
resource_class: xlarge
steps:
- checkout
- run:
name: Download model weights
background: true
command: |
sudo apt update -qy && sudo apt install -qy parallel wget
mkdir -p ~/.cache/torch/hub/checkpoints
python scripts/collect_model_urls.py torchvision/prototype/models \
| parallel -j0 'wget --no-verbose -O ~/.cache/torch/hub/checkpoints/`basename {}` {}\?source=ci'
- download_model_weights:
extract_roots: torchvision/prototype/models
- install_torchvision
- install_prototype_dependencies
- pip_install:
Expand Down Expand Up @@ -1011,12 +1025,13 @@ jobs:
build_docs:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
- image: circleci/python:3.7
resource_class: 2xlarge+
steps:
- attach_workspace:
at: ~/workspace
- checkout
- download_model_weights
- run:
name: Setup
command: .circleci/unittest/linux/scripts/setup_env.sh
Expand Down
18 changes: 8 additions & 10 deletions scripts/collect_model_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
import re
import sys

MODEL_URL_PATTERN = re.compile(r"https://download[.]pytorch[.]org/models/.*?[.]pth")
MODEL_URL_PATTERN = re.compile(r"https://download[.]pytorch[.]org/models/.+?[.]pth")


def main(root):
def main(*roots):
model_urls = set()
for path in pathlib.Path(root).glob("**/*"):
if path.name.startswith("_") or not path.suffix == ".py":
continue

with open(path, "r") as file:
for line in file:
model_urls.update(MODEL_URL_PATTERN.findall(line))
for root in roots:
for path in pathlib.Path(root).rglob("*.py"):
with open(path, "r") as file:
for line in file:
model_urls.update(MODEL_URL_PATTERN.findall(line))

print("\n".join(sorted(model_urls)))


if __name__ == "__main__":
main(sys.argv[1])
main(*sys.argv[1:])