Skip to content

Commit

Permalink
Merge pull request #40 from ETSInitiative/fix-workflows
Browse files Browse the repository at this point in the history
fix workflows
  • Loading branch information
casperdcl authored Oct 30, 2024
2 parents fd6b833 + 2f28c34 commit 417ee0f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 130 deletions.
16 changes: 0 additions & 16 deletions .github/actions/configure-environment/action.yml

This file was deleted.

99 changes: 52 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
name: CI

on:
push:
branches: [main]
tags: ['**']
paths-ignore:
- '**/*.md'
pull_request:
branches: [main]

defaults:
run:
# See https://github.com/marketplace/actions/setup-miniconda#important
shell: bash -el {0}

- '**/*.md'
pull_request: {branches: [main]}
defaults: {run: {shell: 'bash -el {0}'}} # https://github.com/marketplace/actions/setup-miniconda#important
env:
YARDL_VERSION: 0.6.2
jobs:
validate:
strategy:
matrix:
cppVersion: [17]

environment: pypi
permissions: {id-token: write}
name: Validate Python and C++${{ matrix.cppVersion }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure environment
uses: ./.github/actions/configure-environment

- name: Install yardl
run: |
YARDL_DIR=${{github.workspace}}/yardl
mkdir ${YARDL_DIR}
cd ${YARDL_DIR}
echo "${{github.workspace}}/yardl" >> $GITHUB_PATH
YARDL_VERSION=0.3.2
wget --quiet "https://github.com/microsoft/yardl/releases/download/v${YARDL_VERSION}/yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
- name: Build model
run: |
cd model
yardl generate
- name: Python
run: |
cd python
python petsird_generator.py | python petsird_analysis.py
- name: Cpp
run: |
cd cpp && mkdir -p build && cd build
cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX"
ninja
./petsird_generator test.h5
./petsird_analysis test.h5
- uses: actions/checkout@v4
with: {submodules: recursive}
- name: strip environment.yml
run: |
cat environment.yml | grep -v "#.*\<\local\>" > temp-ci-environment.yml
- uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: yardl
environment-file: temp-ci-environment.yml
- name: Install yardl
run: |
rm temp-ci-environment.yml
gh release download -R microsoft/yardl -p '*linux_x86_64.tar.gz' v$YARDL_VERSION
mkdir yardl
tar -xzf "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz" -C yardl
rm "yardl_${YARDL_VERSION}_linux_x86_64.tar.gz"
echo "$PWD/yardl" >> "$GITHUB_PATH"
env:
GH_TOKEN: ${{ github.token }}
- name: Build model
run: |
cd model
yardl generate
- name: Python
run: |
cd python
python petsird_generator.py | python petsird_analysis.py
- name: cpp
run: |
mkdir cpp/build
cd cpp/build
cmake -G Ninja -S .. -DHDF5_ROOT="$CONDA_PREFIX"
ninja
./petsird_generator test.h5
./petsird_analysis test.h5
- uses: casperdcl/deploy-pypi@v2
with:
build: -s python -o dist
upload: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
- if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: casperdcl/deploy-pypi@v2
with:
url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_TOKEN }}
48 changes: 0 additions & 48 deletions .github/workflows/test_pypi.yml

This file was deleted.

12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
.vscode

cpp/generated/
cpp/build/

python/petsird/
**/__pycache__/
/cpp/generated/
/cpp/build/
/python/petsird/
__pycache__/

# Common editor backups
/.vscode/
~$*
*~
*.bak
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
The purpose of this repo is to have a simple working example of a data model for PET imaging (list mode data). This is **not complete**, and aspects do not follow the actual proposal of PETSIRD yet.

## Background

The [Emission Tomography Standardization Initiative (ETSI)](https://etsinitiative.org/)
is working towards establishing a standard for PET Raw Data, called PETSIRD ("PET ETSI Raw Data").

Expand All @@ -17,9 +18,11 @@ in a [VS Code devcontainer](https://code.visualstudio.com/docs/devcontainers/con
This codespace/container will contain all necessary tools, including `yardl` itself, as well as the current repository.
2. Browse the [`model`](./model/README.md) directory.
3. Use `yardl` to generate C++ and Python code for the model:
```sh
cd model
yardl generate
```

```sh
cd model
yardl generate
```

4. Have a look at (and try!) the examples in the [`cpp`](cpp/README.md) and/or
[`python`](python/README.md) directories.
10 changes: 5 additions & 5 deletions cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ This directory contains some C++ example code to read/write PETSIRD data. You ne
The C++ code shows writing to and reading from an HDF5 file

1. Compile the code:

```sh
cd /whereever/cpp
mkdir -p build && cd build`
cmake -G Ninja -S .. -DHDF5_ROOT=$CONDA_PREFIX
ninja`
mkdir -p build
cmake -G Ninja -S . -B build -DHDF5_ROOT=$CONDA_PREFIX
ninja
```

If you did not use `conda` to install HDF5, do not add the `-DHDF5_ROOT=$CONDA_PREFIX` part of the `cmake` line.

2. Run the generator: `./petsird_generator test.h5`
3. Run the analyzer: `./petsird_analysis test.h5`
4. You can inspect the HDF5 file by running `h5dump test.h5`

7 changes: 4 additions & 3 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ reading it from standard in. This can be used as follows:
1. `python petsird_generator.py | python petsird_analysis.py`

There is also a very basic utility to plot the scanner geometry. For instance
```
python petsird_generator.py > test.bin
python petsird_plot_scanner.py < test.bin`

```sh
python petsird_generator.py > test.bin
python petsird_plot_scanner.py < test.bin
```

0 comments on commit 417ee0f

Please sign in to comment.