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

Improve caches #242

Merged
merged 2 commits into from
Apr 20, 2024
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
64 changes: 31 additions & 33 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,39 @@ name: Lint

# Controls when the workflow will run
on:
pull_request:
branches: ['*']
types:
- opened
- synchronize
- closed
push:
branches: [main]
pull_request:
branches: ["*"]
types:
- opened
- synchronize
- closed
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- uses: pre-commit/action@v3.0.0
env:
RUFF_OUTPUT_FORMAT: github
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: pre-commit/action@v3.0.0
env:
RUFF_OUTPUT_FORMAT: github

pyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- run: sh scripts/install.sh
- run: pyright libs/
- run: pyright tests/
- run: pyright scripts/
pyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: sh scripts/install.sh
- run: pyright libs/
- run: pyright tests/
- run: pyright scripts/
4 changes: 2 additions & 2 deletions .github/workflows/release-spandrel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: sh scripts/install.sh
- name: Build packages
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions/configure-pages@v3
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.11"
- run: sh scripts/install.sh
- name: Build the website
run: pydoctor --project-url=https://github.com/$GITHUB_REPOSITORY --html-viewsource-base=https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_SHA
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-spandrel_extra_arches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.11"
- name: Install dependencies
run: sh scripts/install.sh
- name: Build packages
Expand Down
112 changes: 58 additions & 54 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,67 @@ name: Test

# Controls when the workflow will run
on:
pull_request:
branches: ['*']
types:
- opened
- synchronize
- closed
paths:
- 'libs/**'
- '!libs/**/*.md'
- 'tests/**'
- '.github/workflows/**'
- 'pyproject.toml'
push:
branches: [main]
pull_request:
branches: ["*"]
types:
- opened
- synchronize
- closed
paths:
- "libs/**"
- "!libs/**/*.md"
- "tests/**"
- ".github/workflows/**"
- "pyproject.toml"
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: sh scripts/install.sh
- name: Cache models
id: cache-models
uses: actions/cache@v3
with:
path: tests/models
key: update-2023-11-29
- run: pytest tests
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: sh scripts/install.sh
- name: Cache models
id: cache-models
uses: actions/cache@v3
with:
path: tests/models
key: update-2023-11-29
- run: pytest tests
- name: Remove models downloaded from GitHub
run: |
touch tests/_github_files.txt
echo "Files removed from cache:"
cat tests/_github_files.txt
xargs rm < tests/_github_files.txt

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: sh scripts/install.sh
- run: pydoctor

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: sh scripts/install.sh
- run: sh scripts/build.sh
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: sh scripts/install.sh
- run: pydoctor

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: sh scripts/install.sh
- run: sh scripts/build.sh
15 changes: 11 additions & 4 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@

MAIN_REGISTRY.add(*EXTRA_REGISTRY)

MODEL_DIR = Path("./tests/models/")
ZIP_DIR = Path("./tests/zips/")
IMAGE_DIR = Path("./tests/images/")
TEST_DIR = Path("./tests/").resolve()
MODEL_DIR = TEST_DIR / "models"
ZIP_DIR = TEST_DIR / "zips"
IMAGE_DIR = TEST_DIR / "images"
GITHUB_FILE_LOG = TEST_DIR / "_github_files.txt"

IS_CI = os.environ.get("CI") == "true"

Expand Down Expand Up @@ -93,12 +95,17 @@ def convert_google_drive_link(url: str) -> str:


def download_file(url: str, filename: Path | str) -> None:
filename = Path(filename)
filename = Path(filename).resolve()
filename.parent.mkdir(exist_ok=True)
url = convert_google_drive_link(url)
logger.info("Downloading %s to %s", url, filename)
torch.hub.download_url_to_file(url, str(filename), progress=not IS_CI)

# remember github files for later
if IS_CI and url.startswith("https://github.com/") and filename.parent == MODEL_DIR:
with open(GITHUB_FILE_LOG, "a") as f:
f.write(f"{filename.resolve()}\n")


def extract_file_from_zip(
zip_path: Path | str,
Expand Down
Loading