Skip to content

Added Huber loss function class #3124

Added Huber loss function class

Added Huber loss function class #3124

Workflow file for this run

name: build
on:
workflow_dispatch:
release: {types: [published]}
push:
branches: [master]
tags: ['**']
paths-ignore:
- 'CHANGELOG.md'
- 'CITATION.cff'
- 'LICENSE'
- 'scripts/**'
- 'NOTICE.txt'
- 'README.md'
pull_request:
branches: [master]
paths-ignore:
- 'CHANGELOG.md'
- 'CITATION.cff'
- 'LICENSE'
- 'scripts/**'
- 'NOTICE.txt'
- 'README.md'
jobs:
test-cuda:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: [self-hosted, python, cuda]
strategy:
matrix:
python-version: [3.12]
numpy-version: [2]
steps:
- uses: actions/checkout@v6
with: {fetch-depth: 0, submodules: recursive}
- id: reqs
name: set requirements
run: |
envname="${GITHUB_REPOSITORY##*/}-${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}"
echo "envname=$envname" >> $GITHUB_OUTPUT
sed -ri -e 's/^(name: ).*/\1$envname/' -e '/ python /d' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' scripts/cil_development.yml
- uses: conda-incubator/setup-miniconda@v4
with:
python-version: ${{ matrix.python-version }}
use-mamba: true
mamba-version: "*"
channels: conda-forge
activate-environment: ${{ steps.reqs.outputs.envname }}
environment-file: scripts/cil_development.yml
run-post: false
- id: build
name: build
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
pip install .
- name: test
run: |
conda activate "${{ steps.reqs.outputs.envname }}"
TESTS_FORCE_GPU=1 CIL_DATA_DIR=/opt/runner/hostedtoolcache/cil python -m unittest discover -v -k tigre -k TIGRE -k astra -k ASTRA -k Astra -k gpu -k GPU ./Wrappers/Python/test
- if: always()
name: Post Run conda-incubator/setup-miniconda@v3
shell: bash
run: |
sed -i '/${{ steps.reqs.outputs.envname }}/d' ~/.profile
source ~/.profile
conda env remove -n "${{ steps.reqs.outputs.envname }}"
test-matrix:
runs-on: ubuntu-slim
outputs:
python-version: ${{ steps.matrix.outputs.python-version }}
numpy-version: ${{ steps.matrix.outputs.numpy-version }}
os: ${{ steps.matrix.outputs.os }}
include: ${{ steps.matrix.outputs.include }}
conda-include: ${{ steps.matrix.outputs.conda-include }}
steps:
- id: matrix
run: |
if ${{ startsWith(github.ref, 'refs/tags') || github.event_name == 'workflow_dispatch' }}; then
echo "python-version=[3.11, 3.12]" >> $GITHUB_OUTPUT
echo "numpy-version=[1.26, '2.0', 2.1, 2.2, 2.3, 2.4]" >> $GITHUB_OUTPUT
echo "os=['ubuntu', 'windows']" >> $GITHUB_OUTPUT
include_max=true
else
echo "python-version=['3.10']" >> $GITHUB_OUTPUT
echo "numpy-version=[2]" >> $GITHUB_OUTPUT
if ${{ github.ref == 'refs/heads/master' }}; then
echo "os=['ubuntu', 'windows']" >> $GITHUB_OUTPUT
include_max=true
else
echo "os=['ubuntu']" >> $GITHUB_OUTPUT
include_max=false
fi
fi
if $include_max; then
echo "include=[{'os': 'ubuntu', 'python-version': 3.13, 'numpy-version': 2}, {'os': 'windows', 'python-version': 3.13, 'numpy-version': 2}]" >> $GITHUB_OUTPUT
echo "conda-include=[{'os': 'ubuntu', 'python-version': 3.13}, {'os': 'windows', 'python-version': 3.13}]" >> $GITHUB_OUTPUT
else
echo "include=[]" >> $GITHUB_OUTPUT
echo "conda-include=[]" >> $GITHUB_OUTPUT
fi
test:
defaults: {run: {shell: 'bash -el {0}'}}
runs-on: ${{ matrix.os }}-${{ matrix.os == 'ubuntu' && '24.04' || '2022' }}
needs: test-matrix
strategy:
matrix:
os: ${{ fromJson(needs.test-matrix.outputs.os) }}
python-version: ${{ fromJson(needs.test-matrix.outputs.python-version) }}
numpy-version: ${{ fromJson(needs.test-matrix.outputs.numpy-version) }}
include: ${{ fromJson(needs.test-matrix.outputs.include) }}
steps:
- uses: actions/checkout@v6
with: {fetch-depth: 0, submodules: recursive}
- name: set requirements
run: sed -ri -e 's/(.* python) .*/\1=${{ matrix.python-version }}/' -e 's/(.* numpy) .*/\1=${{ matrix.numpy-version }}/' -e 's/cuda*/cpu*/' -e '/tigre/d' scripts/cil_development.yml
- uses: conda-incubator/setup-miniconda@v4
with:
miniforge-version: latest
use-mamba: true
mamba-version: "*"
channels: conda-forge
activate-environment: cil_dev
environment-file: scripts/cil_development.yml
- run: pip install .
- name: test
run: python -m unittest discover -v ./Wrappers/Python/test
conda-build-test:
runs-on: ${{ matrix.os }}-${{ matrix.os == 'ubuntu' && '24.04' || '2022' }}
needs: test-matrix
strategy:
matrix:
os: ${{ fromJson(needs.test-matrix.outputs.os) }}
python-version: ${{ fromJson(needs.test-matrix.outputs.python-version) }}
include: ${{ fromJson(needs.test-matrix.outputs.conda-include) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- if: matrix.os == 'windows'
uses: ilammy/msvc-dev-cmd@v1
- uses: prefix-dev/rattler-build-action@v0.2.37
with:
recipe-path: recipe.yaml
rattler-build-version: v0.65.0 # https://github.com/prefix-dev/rattler-build/pull/2484
build-args: --experimental -c astra-toolbox -c conda-forge -c httomo -c ccpi --variant python=${{ matrix.python-version }}
artifact-name: conda-py${{ matrix.python-version }}-${{ matrix.os }}
conda-upload:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
defaults: {run: {working-directory: output}}
runs-on: ubuntu-slim
needs: conda-build-test
steps:
- uses: actions/checkout@v6
- uses: prefix-dev/rattler-build-action@v0.2.37
with: {setup-only: true}
- uses: actions/download-artifact@v8
with: {pattern: conda-py*-*, path: output, merge-multiple: true}
- name: conda upload -c ccpi
run: >
rattler-build upload anaconda */*.conda -f
-o ccpi -a ${{ secrets.CCPI_CONDA_TOKEN }}
-c ${{ startsWith(github.ref, 'refs/tags') && 'main' || 'dev' }}
- if: startsWith(github.ref, 'refs/tags')
name: conda upload -c tomography.stfc.ac.uk/conda
run: |
echo '${{ secrets.STFC_SSH_KEY }}' > ./key
chmod 600 ./key
rsync -e 'ssh -o StrictHostKeyChecking=no -i ./key' -R */*.conda '${{ secrets.STFC_SSH_HOST }}:${{ secrets.STFC_SSH_CONDA_DIR }}'
ssh -o StrictHostKeyChecking=no -i ./key ${{ secrets.STFC_SSH_HOST }} \
'bash -lic "conda index --bz2 --zst --run-exports --channeldata --rss -n ccpi ${{ secrets.STFC_SSH_CONDA_DIR }}"'
docs:
defaults: {run: {shell: 'bash -el {0}', working-directory: docs}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: conda-incubator/setup-miniconda@v4
with:
miniforge-version: latest
use-mamba: true
python-version: 3.12
mamba-version: "*"
channels: conda-forge
conda-remove-defaults: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
cache-version: 0
- name: install dependencies
run: |
mamba install -c conda-forge -yq conda-merge
sed -ri -e 's/(.* python) .*/\1=3.12/' -e 's/cuda*/cpu*/' -e '/tigre/d' ../scripts/cil_development.yml
conda-merge ../scripts/cil_development.yml docs_environment.yml > environment.yml
mamba env update -n test --file environment.yml
conda list
- run: pip install ..
- name: checkout docs
uses: actions/checkout@v6
with:
path: docs/build
ref: gh-pages
- id: pages
uses: actions/configure-pages@v6
- name: update web pages (jekyll)
run: make JEKYLLOPTS="--baseurl ${{ steps.pages.outputs.base_path }}" web-deps web
env: {JEKYLL_ENV: production}
- name: update docs pages (sphinx)
run: |
docs_dir="${{ github.ref_name }}"
docs_dir="${docs_dir//\//_}"
if test "$docs_dir" = master; then docs_dir=nightly; fi
make BUILDSUBDIR="$docs_dir" dirhtml
- uses: actions/upload-artifact@v7
with:
name: DocumentationHTML
path: docs/build
- name: Push changes
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
uses: casperdcl/push-dir@v1
with:
message: Update documentation
branch: gh-pages
dir: docs/build
nojekyll: true
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: jlumbroso/free-disk-space@v1.3.1
with:
docker-images: false
large-packages: false
- uses: docker/setup-buildx-action@v4
- uses: docker/metadata-action@v6
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.licenses=Apache-2.0 AND BSD-3-Clause AND GPL-3.0
- uses: docker/login-action@v4
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v7
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
load: true
tags: tomographicimaging/cil:test
- name: test
run: >
docker run --rm -v .:/CIL tomographicimaging/cil:test /bin/bash -c
'python -m unittest discover -v /CIL/Wrappers/Python/test'
- uses: docker/build-push-action@v7
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pass:
needs: [test-cuda, test, conda-build-test, docs, docker]
runs-on: ubuntu-slim
steps: [{run: echo success}]