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
7 changes: 4 additions & 3 deletions .github/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ build:

requirements:
host:
- python >=3.10
- python >=3.12
- pip
- setuptools >=65
- setuptools_scm >=6.2
run:
- python >=3.10
- python >=3.12
- astropy
- numpy
- pandas
Expand All @@ -30,7 +30,8 @@ requirements:
- traitlets
- pydot
- setuptools
- ctapipe>=0.23,<0.26
- ctapipe>=0.28
- eventio


test:
Expand Down
38 changes: 22 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Release CD
name: Release PyPI CD

on:
release:
types: [published]
pull_request:
paths:
- '.github/workflows/**'
workflow_dispatch:

jobs:
pypi-publish:
Expand All @@ -20,28 +24,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-22.04]
pyv: ['3.10']
pyv: ['3.12']
max-parallel: 5
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.pyv }}
run: |
conda install -y python=${{ matrix.pyv }}

- name: Add conda to system path
run: |
#$CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH

- name: Install dependencies

- name: Set up Miniconda and install dependencies
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.pyv }}
activate-environment: dl1dh
channels: conda-forge
packages: ctapipe

- name: Upgrade pip and build tools
run: |
conda env update --file environment.yml --name base
pip install --upgrade pip build

- name: Build package
run: |
python --version
pip install -U build
python -m build

- name: Publish package distributions to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
54 changes: 30 additions & 24 deletions .github/workflows/release_conda.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@
name: Release Conda
name: Release Conda CD

on:
release:
types: [published]
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/**'

jobs:
publish:
conda-publish:
name: Publish release to Conda
runs-on: ubuntu-22.04

steps:
- name: Checkout repository and fetch tags
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Miniconda and Conda Tools
fetch-depth: 0

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: '3.10'
channels: conda-forge
python-version: '3.12'
channels: conda-forge
auto-update-conda: true
mamba-version: "*"
activate-environment: false

- name: Install anaconda-client and conda-build
activate-environment: false

- name: Create Conda environment with all dependencies
shell: bash
run: |
mamba install anaconda-client conda-build -y

- name: Conda Build and Upload Package
conda create -y -n dl1dh -c conda-forge python=3.12 ctapipe conda-build anaconda-client
python --version

- name: Conda Build (and maybe Upload)
shell: bash
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
CONDA_RECIPE_DIR=".github/conda"
ANACONDA_CHANNEL="ctlearn-project"

# Get latest tag or default to dev
FULL_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0+dev")
VERSION="${FULL_TAG#v}"
VERSION="${VERSION#V}"

echo "Building package version: $VERSION"
export PACKAGE_VERSION=$VERSION

conda run conda build $CONDA_RECIPE_DIR

PACKAGE_PATH=$(conda run conda build $CONDA_RECIPE_DIR --output)

if [[ "$VERSION" != "0.0.0+dev" ]]; then

# Build the package
PACKAGE_PATH=$(conda run -n dl1dh conda build "$CONDA_RECIPE_DIR" --output)
conda run -n dl1dh conda build "$CONDA_RECIPE_DIR"

# Upload only if this is a release
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "Uploading $PACKAGE_PATH to $ANACONDA_CHANNEL channel..."
conda run anaconda upload \
conda run -n dl1dh anaconda upload \
"$PACKAGE_PATH" \
--force \
--user $ANACONDA_CHANNEL
--user "$ANACONDA_CHANNEL"
else
echo "Skipping upload: Version is $VERSION (development)."
echo "Skipping upload (event: ${{ github.event_name }})"
fi
30 changes: 22 additions & 8 deletions dl1_data_handler/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ class DLDataReader(Component):
help="Skip files that are not compatible to the reference instead of raising an error",
).tag(config=True)

enforce_subarray_equality = Bool(
default_value=True,
help=(
"Enforce strict equality of subarray descriptions between files. "
"If False, a looser check primarily on telescope IDs is performed "
"to ensure compatibility. Error will be raised if selected check failed "
"and skip_incompatible_files is False."
),
).tag(config=True)

allowed_tel_types = List(
default_value=None,
allow_none=True,
Expand Down Expand Up @@ -353,17 +363,21 @@ def __init__(
if selected_tel_ids is not None:
subarray = subarray.select_subarray(self.tel_ids)

# Check if it matches the reference
if not subarray.__eq__(self.subarray):
# Check if the subarray matches the reference
subarrays_match = (
subarray.__eq__(self.subarray)
if self.enforce_subarray_equality
else SubarrayDescription.check_matching_subarrays([self.subarray, subarray])
)
if not subarrays_match:
message = (
f"Subarray description of file '{filename}' does not match the reference subarray description."
)
if self.skip_incompatible_files:
self.log.warning(
f"Skipping '{filename}'. Subarray description does not match the reference subarray description."
)
self.log.warning(f"Skipping '{filename}'. {message}")
del self.files[filename]
else:
raise ValueError(
f"Subarray description of file '{filename}' does not match the reference subarray description."
)
raise ValueError(message)

# Set the telescope type and camera name as class attributes for mono mode for convenience
# FIXME Make image mapper not a dict because we only need one since we do not select multiple telescope types for image/wvf reading
Expand Down
Loading