Unverified Commit 600a3f24 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

pre-download model weights in CI docs build (#5625)

* pre-download model weights in CI docs build

* move changes into template

* change docs image
parent 9edd22c8
...@@ -174,6 +174,26 @@ commands: ...@@ -174,6 +174,26 @@ commands:
- store_test_results: - store_test_results:
path: 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 binary_common: &binary_common
parameters: parameters:
# Edit these defaults to do a release # Edit these defaults to do a release
...@@ -340,14 +360,8 @@ jobs: ...@@ -340,14 +360,8 @@ jobs:
resource_class: xlarge resource_class: xlarge
steps: steps:
- checkout - checkout
- run: - download_model_weights:
name: Download model weights extract_roots: torchvision/prototype/models
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'
- install_torchvision - install_torchvision
- install_prototype_dependencies - install_prototype_dependencies
- pip_install: - pip_install:
...@@ -1011,12 +1025,13 @@ jobs: ...@@ -1011,12 +1025,13 @@ jobs:
build_docs: build_docs:
<<: *binary_common <<: *binary_common
docker: docker:
- image: "pytorch/manylinux-cuda100" - image: circleci/python:3.7
resource_class: 2xlarge+ resource_class: 2xlarge+
steps: steps:
- attach_workspace: - attach_workspace:
at: ~/workspace at: ~/workspace
- checkout - checkout
- download_model_weights
- run: - run:
name: Setup name: Setup
command: .circleci/unittest/linux/scripts/setup_env.sh command: .circleci/unittest/linux/scripts/setup_env.sh
......
...@@ -174,6 +174,26 @@ commands: ...@@ -174,6 +174,26 @@ commands:
- store_test_results: - store_test_results:
path: 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 binary_common: &binary_common
parameters: parameters:
# Edit these defaults to do a release # Edit these defaults to do a release
...@@ -340,14 +360,8 @@ jobs: ...@@ -340,14 +360,8 @@ jobs:
resource_class: xlarge resource_class: xlarge
steps: steps:
- checkout - checkout
- run: - download_model_weights:
name: Download model weights extract_roots: torchvision/prototype/models
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'
- install_torchvision - install_torchvision
- install_prototype_dependencies - install_prototype_dependencies
- pip_install: - pip_install:
...@@ -1011,12 +1025,13 @@ jobs: ...@@ -1011,12 +1025,13 @@ jobs:
build_docs: build_docs:
<<: *binary_common <<: *binary_common
docker: docker:
- image: "pytorch/manylinux-cuda100" - image: circleci/python:3.7
resource_class: 2xlarge+ resource_class: 2xlarge+
steps: steps:
- attach_workspace: - attach_workspace:
at: ~/workspace at: ~/workspace
- checkout - checkout
- download_model_weights
- run: - run:
name: Setup name: Setup
command: .circleci/unittest/linux/scripts/setup_env.sh command: .circleci/unittest/linux/scripts/setup_env.sh
......
...@@ -2,15 +2,13 @@ import pathlib ...@@ -2,15 +2,13 @@ import pathlib
import re import re
import sys 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() model_urls = set()
for path in pathlib.Path(root).glob("**/*"): for root in roots:
if path.name.startswith("_") or not path.suffix == ".py": for path in pathlib.Path(root).rglob("*.py"):
continue
with open(path, "r") as file: with open(path, "r") as file:
for line in file: for line in file:
model_urls.update(MODEL_URL_PATTERN.findall(line)) model_urls.update(MODEL_URL_PATTERN.findall(line))
...@@ -19,4 +17,4 @@ def main(root): ...@@ -19,4 +17,4 @@ def main(root):
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv[1]) main(*sys.argv[1:])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment