diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml index 57bb82464..727b2f241 100644 --- a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: UKAEA-Edge-Code/hermes-3 + IMAGE_NAME: UKAEA-Edge-Code/hermes-3-vantage-deps DOCKERFILE: VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile permissions: diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml index 52d55332b..eefea0d49 100644 --- a/.github/workflows/docker_VANTAGE_tests.yml +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -12,9 +12,9 @@ jobs: docker_spack_install_tests: runs-on: ubuntu-latest # timeout to avoid running tests which do unexpected spack installation - timeout-minutes: 45 + timeout-minutes: 35 container: - image: ghcr.io/ukaea-edge-code/hermes-3:edge + image: ghcr.io/ukaea-edge-code/hermes-3-vantage-deps:edge credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -28,27 +28,17 @@ jobs: uses: actions/checkout@v6 with: submodules: recursive - - name: Check download - run: source /opt/spack/share/spack/setup-env.sh && - spack env activate . -v gcc && - spack concretize -f && - spack env view regenerate && - spack find && which python3 && - chmod +x 2D-production-download.py && - mkdir download-dir && cp 2D-production-download.py download-dir/ && - cd download-dir && ./2D-production-download.py && ls - # python3 2D-production-download.py && - name: Install - run: source /opt/spack/share/spack/setup-env.sh && - spack env activate . -v gcc && - spack concretize -f && - spack install -j 4 + run: | + source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + sed -i '/^[[:space:]]*providers:/i\ require: "target=x86_64_v3"' spack.yaml && + spack env activate . -v gcc && + spack concretize -f && + spack install -j 4 --only-concrete - name : Run tests - run: source /opt/spack/share/spack/setup-env.sh && - spack env activate . -v gcc && - chmod +x 2D-production-download.py && - cp 2D-production-download.py $(spack location -b hermes-3)/tests/integrated/2D-production/ && - spack cd -b hermes-3 && - ./tests/integrated/2D-production/./2D-production-download.py && - ls ./tests/integrated/2D-production/ && - ctest -j 1 --output-on-failure --timeout 300 -VV + run: | + source /opt/spack/share/spack/setup-env.sh && + spack env activate . -v gcc && + spack cd -b hermes-3 && + ctest -j 1 --output-on-failure --timeout 300 diff --git a/2D-production-download.py b/2D-production-download.py deleted file mode 100644 index 4725da8ae..000000000 --- a/2D-production-download.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 -import numpy as np -import shutil -import zipfile -import hashlib -import os -from pathlib import Path -import urllib.request - -verbose = True -rtol = 1e-6 -atol = 1e-8 - -## Setup -this_dir = Path(__file__).parent - -zipfile_path = this_dir / "test-2D-production.zip" -url = "https://zenodo.org/records/18696440/files/test-2D-production-2026-02-19.zip" -expected_hash = "4472d27031a6fcedd30e11360814a66c075f8c14442df745e4e9d80a0dbd87f3" -expected_filenames = [ - "BOUT.restart.0.nc", - "BOUT.restart.1.nc", - "BOUT.restart.2.nc", - "BOUT.restart.3.nc", - "BOUT.restart.4.nc", - "BOUT.restart.5.nc", - "BOUT.restart.6.nc", - "BOUT.restart.7.nc", - "BOUT.restart.8.nc", - "BOUT.restart.9.nc", - "grid_test2_allpump.nc", -] - -if verbose: - print("2D-Production test: begin file download") - -## Download files -tmp_path = zipfile_path.with_name(zipfile_path.name + ".tmp") - -with urllib.request.urlopen(url, timeout=60) as response: - if response.status != 200: - raise RuntimeError( - f"2D-Production test: download failed - HTTP {response.status}" - ) - - # Copy bits of the file from response to a temp file - # This ensures no partial files are left if the download fails - with open(tmp_path, "wb") as out_file: - shutil.copyfileobj(response, out_file) - - -if verbose: - print("2D-Production test: downloaded files") - -# Rename temp file with the correct name -tmp_path.replace(zipfile_path) - -with zipfile.ZipFile(zipfile_path, "r") as zf: - zip_contents = set(zf.namelist()) - try: - # Extract only expected grids - for filename in expected_filenames: - if filename in zip_contents: - zf.extract(filename, path=this_dir) - - except Exception as e: - print("2D-Production test: extracting test grids failed:", e) - -# Check hash -with open(zipfile_path, "rb") as f: - file_hash = hashlib.sha256(f.read()).hexdigest() -# print(file_hash) - -if file_hash != expected_hash: - raise RuntimeError( - "2D-Production test: downloaded zip file hash does not match expected value" - ) - -if verbose: - print("2D-Production test: downloaded and extracted files") \ No newline at end of file diff --git a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile index 55023761c..8ef889b80 100644 --- a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile +++ b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile @@ -24,7 +24,19 @@ WORKDIR /root/hermes-3 # Install hermes-3 dependencies via spack # Activate the hermes-3 environment, install dependencies -RUN < 0: + t_final = time() + print(f"2D-production test: Failed in {t_final - t0:.2f} seconds") print("2D-production test failures:") for f in failures: print(f"\n{f['region']} [{f['variable']}]:") @@ -227,5 +238,6 @@ else: else: if verbose: - print(f"2D-production test: Passed: {time() - t0}") + t_final = time() + print(f"2D-production test: Passed in {t_final - t0:.2f} seconds") exit(0) diff --git a/tests/integrated/2D-recycling/data/BOUT.inp b/tests/integrated/2D-recycling/data/BOUT.inp index e2014de38..3dd57e522 100644 --- a/tests/integrated/2D-recycling/data/BOUT.inp +++ b/tests/integrated/2D-recycling/data/BOUT.inp @@ -1,6 +1,6 @@ # -nout = 5 # Number of output timesteps +nout = 1 # Number of output timesteps timestep = 0.0001 MZ = 1 diff --git a/tests/integrated/2D-recycling/runtest b/tests/integrated/2D-recycling/runtest index 055eb6f09..25cbe44f4 100755 --- a/tests/integrated/2D-recycling/runtest +++ b/tests/integrated/2D-recycling/runtest @@ -77,6 +77,10 @@ if not debug: with open(tmp_path, "wb") as out_file: shutil.copyfileobj(response, out_file) + t_download = time() + if verbose: + print(f"2D-Recycling test: download took {t_download - t0:.2f} seconds") + # Rename temp file with the correct name tmp_path.replace(zipfile_path) @@ -101,8 +105,11 @@ if not debug: "2D-recycling test: downloaded zip file hash does not match expected value" ) + t_extract = time() if verbose: - print("2D-recycling test: downloaded and extracted files:", f" {time()-t0}") + print( + f"2D-Recycling test: zip extraction took {t_extract - t_download:.2f} seconds" + ) ## Run test if not Path("hermes-3").is_file(): @@ -121,8 +128,9 @@ if not debug: print(out) exit(1) + t_run = time() if verbose: - print("2D-recycling test: completed simulation:", f" {time()-t0}") + print(f"2D-Recycling test: simulation took {t_run - t_extract:.2f}") ########################################################################## # Load case and perform test @@ -147,6 +155,11 @@ ds = xhermes.open_hermesdataset( ds = ds.hermes.extract_2d_tokamak_geometry() ds = ds.load() + +t_load = time() +if verbose: + print(f"2D-Recycling test: loading results took {t_load - t_run:.2f} seconds") + if "t" in ds.sizes: ds = ds.isel(t=-1) m = ds.metadata @@ -447,3 +460,6 @@ for side in ["upper", "lower"]: atol=atol, err_msg=f"{side} target pump energy source mismatch", ) + +t_final = time() +print(f"2D-Recycling test: Passed in {t_final - t0:.2f} seconds")