Skip to content
Open
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
59 changes: 59 additions & 0 deletions .github/workflows/hygiene.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: Copyright 2026 Arm Limited and affiliates.
#
# SPDX-License-Identifier: Apache-2.0

name: Hygiene

on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:

#* Stop stale workflows when pull requests are updated: https://stackoverflow.com/a/70972844
#* Does not apply to the main branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}

# Declare default permissions as read only.
permissions: read-all

jobs:
hygiene:
runs-on: ah-ubuntu_24_04-c7g_2x-50
steps:
- name: Checkout Tool-Solutions
uses: actions/checkout@v6.0.2

- name: Set up Python
uses: actions/setup-python@v6.0.0
with:
python-version: "3.12"

- name: Install hygiene tooling
run: |
python -m pip install --user --no-cache-dir pre-commit==4.5.1 reuse==6.2.0
echo "$HOME/.local/bin" >> "$GITHUB_PATH"

- name: Run whole-repo whitespace check
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why can't we just run the whole set in one pre-commit command?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because of the reuse annotate hooks; they should only apply to changed files. Otherwise copyright headers of files that haven't actually been touched will be updated. By itself this shouldn't be a problem since we're not committing files in the CI but it will still cause the hygiene CI to fail (erroneously)

run: pre-commit run trailing-whitespace --all-files

- name: Run safe whole-repo pre-commit checks
run: |
set -euo pipefail
pre-commit run end-of-file-fixer --all-files
pre-commit run mixed-line-ending --all-files
pre-commit run check-merge-conflict --all-files
pre-commit run check-case-conflict --all-files
pre-commit run check-symlinks --all-files
pre-commit run check-json --all-files
pre-commit run check-yaml --all-files
pre-commit run check-added-large-files --all-files
pre-commit run check-executables-have-shebangs --all-files
pre-commit run check-shebang-scripts-are-executable --all-files
pre-commit run ruff-check --all-files

- name: Run whole-repo REUSE lint
run: reuse lint
45 changes: 42 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and affiliates.
# SPDX-FileCopyrightText: Copyright 2025, 2026 Arm Limited and affiliates.
#
# SPDX-License-Identifier: Apache-2.0

Expand All @@ -7,7 +7,8 @@ fail_fast: false
repos:
- repo: local
hooks:
# Python/YAML/shell: use hash comments (no --multi-line)
# Python/YAML/shell: use hash comments (no --multi-line). This hook
# mutates copyright metadata. Do not run this hook with --all-files.
- id: reuse-annotate-current-year-python-yaml-shell-files
name: REUSE Annotate (Python add current year, merge)
language: python
Expand All @@ -27,7 +28,8 @@ repos:
files: '(\.gitignore|\.dockerignore|requirements\.txt|bash_profile|Dockerfile|\.(py|yml|yaml|sh|bash))$'
stages: [ pre-commit ]

# JSON/Markdown/welcome.txt: use sidecar .license files
# JSON/Markdown/welcome.txt: use sidecar .license files. This hook
# mutates copyright metadata. Do not run this hook with --all-files.
- id: reuse-annotate-current-year-json-and-md
name: REUSE Annotate (JSON/Markdown/welcome.txt sidecar fallback add current year, merge)
language: python
Expand All @@ -49,6 +51,8 @@ repos:
- repo: https://github.com/fsfe/reuse-tool
rev: v6.2.0
hooks:
# File-level REUSE validation for changed files. CI also runs `reuse lint`
# across the whole repo because validation is non-mutating.
- id: reuse-lint-file
stages: [ pre-commit ]
name: "REUSE Compliant Copyright and License"
Expand All @@ -58,3 +62,38 @@ repos:
hooks:
- id: trailing-whitespace
stages: [ pre-commit ]
- id: end-of-file-fixer
stages: [ pre-commit ]
- id: mixed-line-ending
stages: [ pre-commit ]
# Cheap changed-file guard for accidentally committed conflict markers.
# GitHub detects active merge conflicts, but this also catches conflict
# markers committed into files.
- id: check-merge-conflict
stages: [ pre-commit ]
# Avoid adding paths that collide on case-insensitive filesystems.
- id: check-case-conflict
stages: [ pre-commit ]
# Catch symlinks that point to missing targets. This is normally a no-op
# for this repo, but keeps broken links from entering via future changes.
- id: check-symlinks
stages: [ pre-commit ]
- id: check-json
stages: [ pre-commit ]
- id: check-yaml
stages: [ pre-commit ]
# Only checks newly added files, even when invoked with --all-files.
- id: check-added-large-files
args: [ --maxkb=1024 ]
stages: [ pre-commit ]
- id: check-executables-have-shebangs
stages: [ pre-commit ]
# Keep script shebangs and executable bits consistent for runnable files.
- id: check-shebang-scripts-are-executable
stages: [ pre-commit ]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.15
hooks:
- id: ruff-check
stages: [ pre-commit ]
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Provide:

- A short summary of what changed (hashes/tags/wheels).
- The edits made to `./versions.sh` (and `./get-source.sh` if changed).
- Commands run and key results/errors.
- Commands run and key results/errors.
2 changes: 1 addition & 1 deletion ML-Frameworks/pytorch-aarch64/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ where `YY` is the year, and `MM` the month of the increment.
### Added

### Changed

### Removed

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion ML-Frameworks/pytorch-aarch64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ WORKDIR /home/$DOCKER_USER
ENV PATH="/home/$DOCKER_USER/.local/bin:${PATH}"

# Install uv for quicker package installations (installed to ~/.local/bin with --user)
RUN python -m pip install --user uv==0.9.29
ENV UV_NO_CACHE=1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand not wanting to cache in the docker build phase to avoid releasing extra blobs, but I think it may be inconvenient for the user to find that uv doesn't cache (given that it is such a useful feature of uv!). Can we instead set this on each run command (or unset at the end of the build)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I'm setting the environment variable during the workshop stage. It should be wiped when we call the second FROM, i.e. when we create the user's workspace. Is there something I'm missing?

RUN python -m pip install --no-cache-dir --user uv==0.9.29

# Create virtual environment with uv
RUN uv venv /home/$DOCKER_USER/.venv
Expand Down
Empty file modified ML-Frameworks/pytorch-aarch64/examples/classify_image.py
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion ML-Frameworks/pytorch-aarch64/examples/executor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import runpy
import time
import sys
from urllib.parse import urlparse
import warnings
import zipfile
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion ML-Frameworks/pytorch-aarch64/examples/quantized_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ def forward(self, x):
model(data)
runtimes.append(time.time() - t0)

print('Quantized: %.4fms, FP32: %.4fms, Speedup: %.4f' % (np.min(runtimes)*1e3, np.min(fp32_runtimes)*1e3, np.min(fp32_runtimes)/np.min(runtimes)))
print('Quantized: %.4fms, FP32: %.4fms, Speedup: %.4f' % (np.min(runtimes)*1e3, np.min(fp32_runtimes)*1e3, np.min(fp32_runtimes)/np.min(runtimes)))
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ def eval_quantized_output(quantized_model, tokenizer, input_tensor, max_min_toke


def main(args):
name_string = f"{args.model}"
quantized_model_, tokenizer_, config_ = get_quantized_model(args)
quantized_model_, tokenizer_, _ = get_quantized_model(args)
input_tensor = tokenizer_.encode(args.prompt, return_tensors="pt")
eval_quantized_output(
quantized_model_, tokenizer_, input_tensor, args.max_new_tokens
Expand Down
3 changes: 2 additions & 1 deletion ML-Frameworks/pytorch-aarch64/examples/utils/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def _postprocess_image_for_openimages_detection(

# resizing the box values from the 800x800 image to the original
# resolution.
resize = lambda x, orig: int((x / 800) * orig)
def resize(x, orig):
return int((x / 800) * orig)
left = resize(box[0], width)
top = resize(box[1], height)
right = resize(box[2], width)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def parse_arguments():
else:
try:
os.path.isfile(args["image"])
except:
except Exception as _:
assert False, "Image not found"

return args
4 changes: 2 additions & 2 deletions ML-Frameworks/tensorflow-aarch64/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and affiliates.
# SPDX-FileCopyrightText: Copyright 2025, 2026 Arm Limited and affiliates.
#
# SPDX-License-Identifier: Apache-2.0

tensorflow/
results/
*.whl
*.whl
3 changes: 2 additions & 1 deletion ML-Frameworks/tensorflow-aarch64/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ WORKDIR /home/$DOCKER_USER
ENV PATH="/home/$DOCKER_USER/.local/bin:${PATH}"

# Install uv for quicker package installations (installed to ~/.local/bin with --user)
RUN python -m pip install --user uv==0.9.29
ENV UV_NO_CACHE=1
RUN python -m pip install --no-cache-dir --user uv==0.9.29

# Create virtual environment with uv
RUN uv venv /home/$DOCKER_USER/.venv
Expand Down
Empty file modified ML-Frameworks/tensorflow-aarch64/examples/classify_image.py
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import zipfile

import numpy as np
import yaml
from tqdm import tqdm

import tensorflow as tf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def parse_arguments():
else:
try:
os.path.isfile(args["image"])
except:
except Exception as _:
assert False, "Image not found"

return args
Loading