Skip to content

Commit e83d3c3

Browse files
Merge pull request mala-project#616 from mala-project/develop
v1.3.0 - Into the multi-GPU-niverse
2 parents 40784b2 + 03f6b96 commit e83d3c3

133 files changed

Lines changed: 14439 additions & 6918 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Cleanup caches
2+
on:
3+
pull_request_target:
4+
types:
5+
- closed
6+
push:
7+
# Trigger on pushes to master or develop and for git tag pushes
8+
branches:
9+
- master
10+
- develop
11+
tags:
12+
- v*
13+
14+
jobs:
15+
cleanup:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Cleanup caches
19+
run: |
20+
gh extension install actions/gh-actions-cache
21+
22+
echo "Fetching list of cache key"
23+
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )
24+
25+
## Setting this to not fail the workflow while deleting cache keys.
26+
set +e
27+
echo "Deleting caches..."
28+
for cacheKey in $cacheKeysForPR
29+
do
30+
echo $cacheKey
31+
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
32+
done
33+
echo "Done"
34+
env:
35+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
REPO: ${{ github.repository }}
37+
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/cleanup.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Delete Untagged Container Versions
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
delete-untagged-containers:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: mala_conda_cpu
11+
uses: actions/delete-package-versions@v5
12+
with:
13+
package-name: 'mala_conda_cpu'
14+
package-type: 'container'
15+
delete-only-untagged-versions: 'true'

.github/workflows/cpu-tests.yml

Lines changed: 80 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: CPU tests
22

33
on:
4+
workflow_dispatch:
45
pull_request:
5-
# Trigger on pull requests to master or develop
6+
# Trigger on pull requests to master or develop that are
7+
# marked as "ready for review" (non-draft PRs)
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
- ready_for_review
613
branches:
714
- master
815
- develop
@@ -21,11 +28,15 @@ env:
2128

2229
jobs:
2330
build-docker-image-cpu:
31+
# do not trigger on draft PRs
32+
if: ${{ ! github.event.pull_request.draft }}
2433
# Build and push temporary Docker image to GitHub's container registry
2534
runs-on: ubuntu-22.04
2635
steps:
2736
- name: Check out repository
28-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: '1'
2940

3041
- name: Set environment variables
3142
run: |
@@ -37,7 +48,7 @@ jobs:
3748
echo "IMAGE_REPO=$IMAGE_REPO"
3849
3950
- name: Restore cache
40-
uses: actions/cache@v3
51+
uses: actions/cache@v4
4152
id: cache-docker
4253
with:
4354
path: ${{ env.DOCKER_CACHE_PATH }}
@@ -53,7 +64,7 @@ jobs:
5364
fi
5465
5566
- name: Pull latest image from container registry
56-
run: docker pull $IMAGE_REPO/$IMAGE_NAME || true
67+
run: docker pull $IMAGE_REPO/$IMAGE_NAME --quiet || true
5768

5869
- name: Build temporary Docker image
5970
run: |
@@ -65,7 +76,7 @@ jobs:
6576
CACHE=$IMAGE_REPO/$IMAGE_NAME:latest
6677
fi
6778
68-
docker build . --file Dockerfile --tag $IMAGE_NAME:local --cache-from=$CACHE --build-arg DEVICE=cpu
79+
DOCKER_BUILDKIT=0 docker build . --file Dockerfile --tag $IMAGE_NAME:local --cache-from=$CACHE --build-arg DEVICE=cpu
6980
7081
# Show images
7182
docker images --filter=reference=$IMAGE_NAME --filter=reference=$IMAGE_REPO/$IMAGE_NAME
@@ -114,20 +125,20 @@ jobs:
114125
steps:
115126
- name: "Prepare environment: Restore cache"
116127
if: env.DOCKER_TAG != 'latest'
117-
uses: actions/cache@v3
128+
uses: actions/cache@v4
118129
id: cache-docker
119130
with:
120131
path: ${{ env.DOCKER_CACHE_PATH }}
121132
key: ${{ github.run_id }}
122133

123134
- name: "Prepare environment: Load Docker image from cache"
124135
if: env.DOCKER_TAG != 'latest'
125-
run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz
136+
run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz --quiet
126137

127138
- name: "Prepare environment: Pull latest image from container registry"
128139
if: env.DOCKER_TAG == 'latest'
129140
run: |
130-
docker pull $IMAGE_REPO/$IMAGE_NAME:latest
141+
docker pull $IMAGE_REPO/$IMAGE_NAME:latest --quiet
131142
docker image tag $IMAGE_REPO/$IMAGE_NAME:latest $IMAGE_NAME:latest
132143
133144
- name: "Prepare environment: Run Docker container"
@@ -145,39 +156,81 @@ jobs:
145156
[[ $(docker inspect --format '{{json .State.Running}}' mala-cpu) == 'true' ]]
146157
147158
- name: Check out repository (mala)
148-
uses: actions/checkout@v3
159+
uses: actions/checkout@v4
160+
with:
161+
fetch-depth: '1'
149162

150163
- name: Install mala package
151164
# Exec all commands inside the mala-cpu container
152165
shell: 'bash -c "docker exec -i mala-cpu bash < {0}"'
153166
run: |
154-
# epxort Docker image Conda environment for a later comparison
155-
conda env export -n mala-cpu > env_1.yml
167+
# export Docker image Conda environment for a later comparison
168+
conda env export -n mala-cpu > env_before.yml
156169
157170
# install mala package
158-
pip --no-cache-dir install -e .[opt,test]
171+
pip --no-cache-dir install -e .[opt,test] --no-build-isolation
172+
159173
160174
- name: Check if Conda environment meets the specified requirements
161175
shell: 'bash -c "docker exec -i mala-cpu bash < {0}"'
162176
run: |
163177
# export Conda environment _with_ mala package installed in it (and extra dependencies)
164-
conda env export -n mala-cpu > env_2.yml
178+
conda env export -n mala-cpu > env_after.yml
179+
180+
# This command is necessary because conda includes even editable
181+
# packages in an export, at least in the versions we recently used.
182+
# That of course leads to the diff failing, since MALA can never
183+
# be there before it has been installed.
184+
sed -i '/materials-learning-algorithms/d' ./env_after.yml
165185
166186
# if comparison fails, `install/mala_cpu_[base]_environment.yml` needs to be aligned with
167187
# `requirements.txt` and/or extra dependencies are missing in the Docker Conda environment
168-
diff env_1.yml env_2.yml
169188
170-
- name: Check out repository (data)
171-
uses: actions/checkout@v3
172-
with:
173-
repository: mala-project/test-data
174-
path: mala_data
175-
ref: v1.7.0
176-
lfs: true
189+
if diff --brief env_before.yml env_after.yml
190+
then
191+
echo "Files env_before.yml and env_after.yml do not differ."
192+
else
193+
diff --side-by-side env_before.yml env_after.yml
194+
fi
195+
196+
- name: Download test data repository from RODARE
197+
shell: 'bash -c "docker exec -i mala-cpu python < {0}"'
198+
run: |
199+
import requests, shutil, zipfile
200+
201+
# This DOI represents all versions, and will always resolve to the latest one
202+
DOI = "https://doi.org/10.14278/rodare.2900"
203+
204+
# Resolve DOI and get record ID and the associated API URL
205+
response = requests.get(DOI)
206+
*_, record_id = response.url.split("/")
207+
api_url = f"https://rodare.hzdr.de/api/records/{record_id}"
208+
209+
# Download record from API and get the first file
210+
response = requests.get(api_url)
211+
record = response.json()
212+
size = record["files"][0]["size"]
213+
download_link = record["files"][0]["links"]["self"]
214+
215+
print(size, "bytes", "--", download_link)
216+
217+
# TODO: implement some sort of auto retry for failed HTTP requests
218+
response = requests.get(download_link)
219+
220+
# Saving downloaded content to a file
221+
with open("test-data.zip", mode="wb") as file:
222+
file.write(response.content)
223+
224+
# Get top level directory name
225+
dir_name = zipfile.ZipFile("test-data.zip").namelist()[0]
226+
shutil.unpack_archive("test-data.zip", ".")
227+
228+
print(f"Rename {dir_name} to mala_data")
229+
shutil.move(dir_name, "mala_data")
177230
178231
- name: Test mala
179232
shell: 'bash -c "docker exec -i mala-cpu bash < {0}"'
180-
run: MALA_DATA_REPO=$(pwd)/mala_data pytest -m "not examples" --disable-warnings
233+
run: MALA_DATA_REPO=$(pwd)/mala_data pytest --cov=mala --cov-fail-under=60 -m "not examples" --disable-warnings
181234

182235
retag-docker-image-cpu:
183236
needs: [cpu-tests, build-docker-image-cpu]
@@ -193,34 +246,29 @@ jobs:
193246
((contains(github.ref_name, 'develop') || contains(github.ref_name, 'master')) && needs.build-docker-image-cpu.outputs.docker-tag != 'latest')
194247
|| startsWith(github.ref, 'refs/tags/')
195248
steps:
196-
- name: Check out repository
197-
uses: actions/checkout@v3
198-
199249
- name: "Prepare environment: Restore cache"
200250
if: env.DOCKER_TAG != 'latest'
201-
uses: actions/cache@v3
251+
uses: actions/cache@v4
202252
id: cache-docker
203253
with:
204254
path: ${{ env.DOCKER_CACHE_PATH }}
205255
key: ${{ github.run_id }}
206256

207257
- name: "Prepare environment: Load Docker image from cache"
208258
if: env.DOCKER_TAG != 'latest'
209-
run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz
259+
run: docker load -i $DOCKER_CACHE_PATH/docker-image.tar.gz --quiet
210260

211261
- name: "Prepare environment: Pull latest image from container registry"
212262
if: env.DOCKER_TAG == 'latest'
213-
run: docker pull $IMAGE_REPO/$IMAGE_NAME:latest
263+
run: docker pull $IMAGE_REPO/$IMAGE_NAME:latest --quiet
214264

215265
- name: Tag Docker image
216266
run: |
217267
# Execute on change of Docker image
218268
if [[ "$DOCKER_TAG" != 'latest' ]]; then
219-
GIT_SHA=${GITHUB_REF_NAME}-$(git rev-parse --short "$GITHUB_SHA")
220-
echo "GIT_SHA=$GIT_SHA"
221269
222270
docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:latest
223-
docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:$GIT_SHA
271+
docker tag $IMAGE_NAME:$GITHUB_RUN_ID $IMAGE_REPO/$IMAGE_NAME:${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}
224272
fi
225273
226274
# Execute on push of git tag
@@ -236,5 +284,4 @@ jobs:
236284
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
237285

238286
- name: Push Docker image
239-
run: docker push $IMAGE_REPO/$IMAGE_NAME --all-tags
240-
287+
run: docker push $IMAGE_REPO/$IMAGE_NAME --all-tags | grep -v -E 'Waiting|Layer already|Preparing|Pushed'

.github/workflows/gh-pages.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: docs
1+
name: Documenation
22

33
on:
44
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
510
branches:
611
- master
712
- develop
@@ -11,15 +16,17 @@ on:
1116

1217
jobs:
1318
test-docstrings:
14-
runs-on: ubuntu-22.04
19+
# do not trigger on draft PRs
20+
if: ${{ ! github.event.pull_request.draft }}
21+
runs-on: ubuntu-24.04
1522
steps:
1623
- name: Check out repository
17-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
1825

1926
- name: Setup Python
20-
uses: actions/setup-python@v4
27+
uses: actions/setup-python@v5
2128
with:
22-
python-version: '3.8'
29+
python-version: '3.10.4'
2330

2431
- name: Upgrade pip
2532
run: python3 -m pip install --upgrade pip
@@ -29,21 +36,21 @@ jobs:
2936

3037
- name: Check docstrings
3138
# Ignoring the cached_properties because pydocstyle (sometimes?) treats them as functions.
32-
run: pydocstyle --convention=numpy --ignore-decorators=[cached_property,property] mala
39+
run: pydocstyle --convention=numpy mala
3340

3441
build-and-deploy-pages:
3542
needs: test-docstrings
36-
runs-on: ubuntu-22.04
43+
runs-on: ubuntu-24.04
3744
steps:
3845
- name: Check out repository
39-
uses: actions/checkout@v3
46+
uses: actions/checkout@v4
4047
with:
4148
fetch-depth: 0 # 0 fetches complete history and tags
4249

4350
- name: Setup Python
44-
uses: actions/setup-python@v4
51+
uses: actions/setup-python@v5
4552
with:
46-
python-version: '3.8'
53+
python-version: '3.10.4'
4754

4855
- name: Upgrade pip
4956
run: python3 -m pip install --upgrade pip
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
name: mirror
1+
name: Mirror to CASUS
22

33
on: [push, delete]
44

55
jobs:
66
mirror-to-CASUS:
77
runs-on: ubuntu-22.04
88
steps:
9-
- uses: actions/checkout@v3
10-
with:
11-
fetch-depth: 0
12-
- name: mirror-repository
13-
uses: spyoungtech/mirror-action@v0.6.0
14-
with:
15-
REMOTE: 'ssh://git@github.com/casus/mala.git'
16-
GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_KEY }}
17-
GIT_SSH_NO_VERIFY_HOST: "true"
18-
DEBUG: "true"
9+
- name: Check out repository
10+
uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- name: mirror-repository
14+
uses: spyoungtech/mirror-action@v0.6.0
15+
with:
16+
REMOTE: 'ssh://git@github.com/casus/mala.git'
17+
GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_KEY }}
18+
GIT_SSH_NO_VERIFY_HOST: "true"
19+
DEBUG: "true"

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ cython_debug/
158158
# JupyterNotebooks
159159
.ipynb_checkpoints
160160
*/.ipynb_checkpoints/*
161+
*.ipynb
162+
163+
# Lightning
164+
lightning_logs/
165+
166+
# wandb
167+
wandb/
161168

162169
# SQLite
163170
*.db

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# https://black.readthedocs.io/en/stable/integrations/source_version_control.html
2+
3+
repos:
4+
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
5+
- repo: https://github.com/psf/black-pre-commit-mirror
6+
rev: 24.4.0
7+
hooks:
8+
- id: black

0 commit comments

Comments
 (0)