Skip to content

Commit

Permalink
Merge branch 'master' into mpiarray-jrs-bak
Browse files Browse the repository at this point in the history
  • Loading branch information
jrs65 committed May 30, 2022
2 parents 771aada + 75987f1 commit 80f19d5
Show file tree
Hide file tree
Showing 23 changed files with 2,697 additions and 1,041 deletions.
25 changes: 18 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install apt dependencies
run: |
sudo apt-get update && sudo apt-get install -y libopenmpi-dev openmpi-bin
sudo apt-get update
sudo apt-get install -y libopenmpi-dev openmpi-bin libhdf5-serial-dev
- name: Install pip dependencies
run: |
pip install pylint==2.7.0 pylint-ignore flake8 pytest black mpi4py pyinstrument psutil
pip install pylint==2.7.0 pylint-ignore flake8 pytest black mpi4py pyinstrument psutil pytest-lazy-fixture
pip install -r requirements.txt
python setup.py develop
pip install .[compression]
- name: Run flake8
run: flake8 --show-source --ignore=E501,E741,E203,W503,E266 caput
Expand All @@ -47,17 +49,21 @@ jobs:

- name: Install apt dependencies
run: |
sudo apt-get update && sudo apt-get install -y libopenmpi-dev openmpi-bin
sudo apt-get update
sudo apt-get install -y libopenmpi-dev openmpi-bin libhdf5-serial-dev
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install pip dependencies
run: |
pip install h5py
pip install -r requirements.txt
pip install mpi4py pytest psutil
pip install zarr==2.8.1
pip install mpi4py numcodecs==0.7.3 bitshuffle
pip install pytest pytest-lazy-fixture
python setup.py develop
- name: Run serial tests
Expand All @@ -78,10 +84,15 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python 3.9
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-serial-dev
- name: Install pip dependencies
run: |
pip install -r requirements.txt
Expand Down
56 changes: 56 additions & 0 deletions caput/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,62 @@ def _prop(config):
return prop


def file_format(default=None):
"""A property type that accepts only "zarr", or "hdf5".
Returns the selected `caput.fileformat.FileFormat` subclass or `caput.fileformats.HDF5` if `value == default`.
Parameters
----------
default : optional
The optional default value.
Returns
-------
prop : Property
A property instance setup to validate a file format.
Raises
------
ValueError
If the default value is not `"hdf5"` or `"zarr"`.
Examples
--------
Should be used like::
class Project:
mode = file_format(default='zarr')
"""
options = ("hdf5", "zarr")

def _prop(val):
from . import fileformats

if val is None:
return None

if not isinstance(val, str):
CaputConfigError(
f"Input {repr(val)} is of type {type(val).__name__} (expected str or None)."
)

val = val.lower()
if val == "hdf5":
return fileformats.HDF5
if val == "zarr":
return fileformats.Zarr
raise CaputConfigError(f"Input {repr(val)} needs to be one of {options})")

if default is not None and (
(not isinstance(default, str)) or (default.lower() not in options)
):
raise CaputConfigError(f"Default value {repr(default)} must be in {options}")

return Property(proptype=_prop, default=default)


class _line_dict(dict):
"""A private dict subclass that also stores line numbers for debugging."""

Expand Down
Loading

0 comments on commit 80f19d5

Please sign in to comment.