Skip to content
Merged
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
16 changes: 8 additions & 8 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lint the code using the defined pre-commits
# Lint the code using the configured prek hooks
name: LintCode
on: [push]

Expand All @@ -10,17 +10,17 @@ jobs:
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v8.1.0

- uses: actions/setup-python@v5
- uses: actions/setup-python@v6.2.0
with:
python-version: '3.12'
python-version: '3.11'

- name: install linting packages
run: uv tool install pre-commit
run: uv tool install prek

- name: run all precommits
run: uv tool run pre-commit run --all
- name: run all prek hooks
run: uv tool run prek run --all-files
33 changes: 28 additions & 5 deletions .github/workflows/runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ concurrency:
cancel-in-progress: true

jobs:
# Runs the tests on combinations of the supported python/os matrix.
# Runs the full optional-dependency integration suite on the supported
# Python/OS matrix.
test_code:

timeout-minutes: 25
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', "3.12"]
python-version: ["3.11", "3.12"]

# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')
Expand All @@ -36,10 +37,10 @@ jobs:
env_file: "environment.yml"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v8.1.0

- name: run pytest
run: uv run --all-extras --python ${{ matrix.python-version }} pytest -s --cov src --cov-append --cov-report=xml
Expand All @@ -49,14 +50,36 @@ jobs:
run: uv run --all-extras --python ${{ matrix.python-version }} pytest src --doctest-modules

# Upload coverage files
- uses: codecov/codecov-action@v5
- uses: codecov/codecov-action@v6.0.0
with:
fail_ci_if_error: false
files: ./coverage.xml
flags: unittests
name: PR_tests
token: ${{ secrets.CODECOV_TOKEN }}

# Optional native dependencies lag new Python releases, so keep the broader
# Python matrix to a package import smoke test.
test_core_python:

timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13", "3.14"]

# only run if CI isn't turned off
if: github.event_name == 'push' || !contains(github.event.pull_request.labels.*.name, 'no_ci')

steps:
- uses: actions/checkout@v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@v8.1.0

- name: import package
run: uv run --python ${{ matrix.python-version }} python -c "import unidas; assert isinstance(unidas.__version__, str)"


# This is a very useful step for debugging, it allows you to ssh into the CI
# machine (https://github.com/marketplace/actions/debugging-with-tmate).
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/upload_pypi.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Upload to PyPI when new code lands in main.
name: PublishPackage
# Upload to PyPI when a GitHub release is published.
name: ReleasePackage
on:
push:
branches:
- main
release:
types: [published]

jobs:
upload:
release:
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: write
# This must be enabled for trusted publishing.
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6.0.2

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v8.1.0

- name: build and publish
- name: Build and publish
shell: bash -l {0}
run: |
uv build
Expand Down
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ out = daspy_function(patch)
assert isinstance(out, dc.Patch)
```

You can also use `adpater` to wrap un-wrapped functions.
You can also use `adapter` to wrap un-wrapped functions.

```python
import dascore as dc
Expand All @@ -61,7 +61,7 @@ sec_out = unidas.convert(blast, to='daspy.Section')
```

## Installation
Simply install unidas with pip or mamba:
Unidas requires Python 3.11 or newer. Simply install unidas with pip or mamba:

```bash
pip install unidas
Expand All @@ -73,6 +73,22 @@ mamba install unidas

By design, unidas has no hard dependencies other than numpy, but an `ImportError` will be raised if the libraries needed to perform a requested conversion are not installed.

To install the supported DAS libraries with unidas:

```bash
pip install "unidas[extras]"
```

Some optional libraries lag new Python releases. The aggregate `unidas[extras]`
install currently targets Python 3.11 and 3.12; on Python 3.13 and newer,
install optional DAS libraries directly once they publish compatible wheels.

For development and testing:

```bash
pip install "unidas[dev]"
```

Unidas is single file (src/unidas.py) so it can also be vendored (copied directly into your project). If you do this, please consider sharing any improvements so the entire community can benefit.

## Guidance for package developers
Expand Down Expand Up @@ -105,7 +121,7 @@ def fancy_machine_learning_function(sec):
To add support for a new data structure/library, you need to do two things:

1. Create a subclass of `Converter` which has (at least) a conversion method to unidas' BaseDAS.
2. Add a conversion method to UnidasBasDASConverter to convert from unidas' BaseDAS back to your data structure.
2. Add a conversion method to UnidasBaseDASConverter to convert from unidas' BaseDAS back to your data structure.
3. Write a test in test/test_unidas.py (this is important for maintainability).

Feel free to open a discussion if you need help.
Expand All @@ -116,3 +132,11 @@ Feel free to open a discussion if you need help.
- [DASPy](https://github.com/HMZ-03/DASPy)
- [Lightguide](https://github.com/pyrocko/lightguide)
- [Xdas](https://github.com/xdas-dev/xdas)

## Compatibility notes

DASPy sections require `time` and `distance` coordinates, evenly sampled coordinates, and an absolute datetime time coordinate. DASCore or XDAS objects with relative, numeric, or uneven time/distance coordinates may still convert to other formats, but will raise a `ValueError` when converting to `daspy.Section`.

## Making releases

To publish a release, bump `__version__` in `src/unidas.py`, merge the change to `main`, create a version tag such as `v0.1.0`, then publish a GitHub Release from that tag. Publishing the GitHub Release triggers the PyPI upload workflow.
44 changes: 26 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@
# --- Build system configuration

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
requires = ["setuptools>=80"]
build-backend = "setuptools.build_meta"

[tool.hatch.build.targets.wheel]
packages = ["src/unidas.py"]
[tool.setuptools]
include-package-data = true
py-modules = ["unidas"]

[tool.setuptools.package-dir]
"" = "src"

[tool.setuptools.dynamic]
version = {attr = "unidas.__version__"}

# --- Project Metadata

[project]
name = "unidas"

version = "0.0.1" # Make sure to bump dascore.__version__ as well!
dynamic = ["version"]

authors = [
{ name="Derrick Chambers", email="chambers.ja.derrick@gmail.com" },
]

description = "A DAS compatibility library"
readme = "README.md"
requires-python = ">=3.10"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering",
]

Expand All @@ -32,21 +38,23 @@ keywords = ["geophysics", "distributed-acoustic-sensing"]
# --- Dependencies

dependencies = [
"numpy"
"numpy>=1.26; python_version < '3.13'",
"numpy>=2; python_version >= '3.13'",
]

[project.optional-dependencies]

extras = [
"dascore",
"daspy-toolbox",
"lightguide",
"xdas",
"numpy<2" # This is due to pyrocko. Remove when it has a new release.
"dascore; python_version < '3.13'",
"daspy-toolbox; python_version < '3.13'",
"lightguide; platform_system != 'Windows' and python_version < '3.13'",
"xdas; python_version < '3.13'",
# This is due to pyrocko. Remove when it has a new release.
"numpy<2; python_version < '3.13'",
]

test = [
"pre-commit",
"prek",
"pytest",
"ruff",
"pooch",
Expand All @@ -58,9 +66,9 @@ dev = ["unidas[test]", "unidas[extras]"]
# --- URLs for project

[project.urls]
"Bug Tracker" = "https://github.com/unidas-dev/unidas"
"Documentation" = "https://github.com/unidas-dev/unidas"
"Homepage" = "https://github.com/unidas-dev/unidas"
"Bug Tracker" = "https://github.com/dasdae/unidas/issues"
"Documentation" = "https://github.com/dasdae/unidas"
"Homepage" = "https://github.com/dasdae/unidas"

# --- External tool configuration

Expand Down
Loading
Loading