Skip to content

Commit

Permalink
Merge pull request #151 from nyx-space/136-python-interface
Browse files Browse the repository at this point in the history
Add Python interface !
  • Loading branch information
ChristopherRabotin authored Dec 30, 2023
2 parents 4d414df + 09e4c98 commit 030d470
Show file tree
Hide file tree
Showing 54 changed files with 2,043 additions and 313 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ data/de421.anise filter=lfs diff=lfs merge=lfs -text
data/de430.anise filter=lfs diff=lfs merge=lfs -text
data/de438s.anise filter=lfs diff=lfs merge=lfs -text
data/de440.anise filter=lfs diff=lfs merge=lfs -text
data/*.pca filter=lfs diff=lfs merge=lfs -text
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Bench JPL Ephemerides
run: cargo bench --bench "*_jpl_ephemerides"
run: cargo bench --bench "*_jpl_ephemerides" --workspace --exclude anise-py

- name: Bench Spacecraft (Hermite type 13)
run: cargo bench --bench "*_spacecraft_ephemeris"
run: cargo bench --bench "*_spacecraft_ephemeris" --workspace --exclude anise-py

- name: Bench Binary planetary constants
run: cargo bench --bench "crit_bpc_rotation"
run: cargo bench --bench "crit_bpc_rotation" --workspace --exclude anise-py

- name: Save benchmark artifacts
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
execute_install_scripts: true

- name: Build Linux executable
run: cargo build --release --bin anise-gui
run: cargo build --release --bin anise-gui --workspace --exclude anise-py

- name: Save executable
uses: actions/upload-artifact@v3
Expand All @@ -54,7 +54,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Build Windows executable
run: cargo build --release --bin anise-gui
run: cargo build --release --bin anise-gui --workspace --exclude anise-py

- name: Save executable
uses: actions/upload-artifact@v3
Expand Down
207 changes: 207 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# This file is autogenerated by maturin v1.4.0
# To update, run
#
# maturin generate-ci github
#
name: Python

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
with:
lfs: true

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
manylinux: auto
working-directory: anise-py
before-script-linux: |
# Source: https://github.com/sfackler/rust-openssl/issues/2036#issuecomment-1724324145
# If we're running on rhel centos, install needed packages.
if command -v yum &> /dev/null; then
yum update -y && yum install -y perl-core openssl openssl-devel pkgconfig libatomic
# If we're running on i686 we need to symlink libatomic
# in order to build openssl with -latomic flag.
if [[ ! -d "/usr/lib64" ]]; then
ln -s /usr/lib/libatomic.so.1 /usr/lib/libatomic.so
fi
else
# If we're running on debian-based system.
apt update -y && apt-get install -y libssl-dev openssl pkg-config
fi
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: anise-py/dist

- name: pytest
if: ${{ startsWith(matrix.target, 'x86_64') }}
shell: bash
run: |
set -e
pip debug --verbose
pip install anise --find-links anise-py/dist --force-reinstall -vv
pip install pytest
pytest
- name: pytest
if: ${{ !startsWith(matrix.target, 'x86') && matrix.target != 'ppc64' }}
uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.target }}
distro: ubuntu22.04
githubToken: ${{ github.token }}
install: |
apt-get update
apt-get install -y --no-install-recommends python3 python3-pip
pip3 install -U pip pytest
run: |
set -e
pip debug --verbose
pip install anise --find-links anise-py/dist --force-reinstall -vv
pip install pytest
pytest
windows:
runs-on: windows-latest
strategy:
matrix:
target: [x64, x86]
steps:
- uses: actions/checkout@v3
with:
lfs: true

- uses: actions/setup-python@v4
with:
python-version: "3.11"
architecture: ${{ matrix.target }}

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: anise-py

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: anise-py/dist

- name: pytest
shell: bash
env:
RUST_BACKTRACE: 1
run: |
set -e
pip install anise --find-links anise-py/dist --force-reinstall
pip install pytest
pytest
macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
with:
lfs: true

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: anise-py

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: anise-py/dist

- name: pytest
if: ${{ !startsWith(matrix.target, 'aarch64') }}
shell: bash
env:
RUST_BACKTRACE: 1
run: |
set -e
pip install anise --find-links anise-py/dist --force-reinstall -vv
pip install pytest
pytest
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true

- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: anise-py

- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: anise-py/dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
steps:
- uses: actions/download-artifact@v3
with:
name: wheels

- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing *
33 changes: 17 additions & 16 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --exclude anise-gui
args: --workspace --exclude anise-gui --exclude anise-py

test:
name: Run tests
Expand All @@ -54,10 +54,10 @@ jobs:
run: sh dev-env-setup.sh && cd .. # Return to root

- name: Test debug
run: cargo test --workspace --exclude anise-gui
run: cargo test --workspace --exclude anise-gui --exclude anise-py

- name: Test release
run: cargo test --release --workspace --exclude anise-gui
run: cargo test --release --workspace --exclude anise-gui --exclude anise-py

lints:
name: Lints
Expand Down Expand Up @@ -108,22 +108,23 @@ jobs:

- name: CLI SPK
run: |
cargo run --bin anise-cli -- inspect data/gmat-hermite.bsp
cargo run --bin anise-cli -- inspect data/de440.bsp
cargo build --bin anise-cli --workspace --exclude anise-py
./target/debug/anise-cli inspect data/gmat-hermite.bsp
./target/debug/anise-cli inspect data/de440.bsp
- name: Rust-SPICE JPL DE validation
run: RUST_BACKTRACE=1 cargo test validate_jplde --features spkezr_validation --release --workspace --exclude anise-gui -- --nocapture --include-ignored --test-threads 1
run: RUST_BACKTRACE=1 cargo test validate_jplde --features spkezr_validation --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1

- name: Rust-SPICE hermite validation
run: RUST_BACKTRACE=1 cargo test validate_hermite_type13_ --features spkezr_validation --release --workspace --exclude anise-gui -- --nocapture --include-ignored --test-threads 1
run: RUST_BACKTRACE=1 cargo test validate_hermite_type13_ --features spkezr_validation --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1

- name: Rust-SPICE PCK validation
run: RUST_BACKTRACE=1 cargo test validate_iau_rotation_to_parent --release --workspace --exclude anise-gui -- --nocapture --ignored
run: RUST_BACKTRACE=1 cargo test validate_iau_rotation_to_parent --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --ignored

- name: Rust-SPICE BPC validation
run: |
RUST_BACKTRACE=1 cargo test validate_bpc_ --release --workspace --exclude anise-gui -- --nocapture --include-ignored --test-threads 1
RUST_BACKTRACE=1 cargo test de440s_translation_verif_venus2emb --release --workspace --exclude anise-gui -- --nocapture --include-ignored --test-threads 1
RUST_BACKTRACE=1 cargo test validate_bpc_ --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1
RUST_BACKTRACE=1 cargo test de440s_translation_verif_venus2emb --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1
# Now analyze the results and create pretty plots
- uses: actions/setup-python@v4
Expand Down Expand Up @@ -169,12 +170,12 @@ jobs:
- name: Generate coverage report
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov test --workspace --exclude anise-gui --no-report -- --test-threads=1
cargo llvm-cov test --workspace --exclude anise-gui --no-report --tests -- compile_fail
cargo llvm-cov test --workspace --exclude anise-gui --no-report validate_iau_rotation_to_parent -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --no-report validate_bpc_to_iau_rotations -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --no-report validate_jplde_de440s --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --no-report validate_hermite_type13_from_gmat --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report -- --test-threads=1
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report --tests -- compile_fail
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_iau_rotation_to_parent -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_bpc_to_iau_rotations -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_jplde_de440s --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --workspace --exclude anise-gui --exclude anise-py --no-report validate_hermite_type13_from_gmat --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov report --lcov > lcov.txt
env:
RUSTFLAGS: --cfg __ui_tests
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["anise", "anise-cli", "anise-gui"]
members = ["anise", "anise-cli", "anise-gui", "anise-py"]

[workspace.package]
version = "0.1.0"
Expand All @@ -26,7 +26,7 @@ exclude = [
]

[workspace.dependencies]
hifitime = "3.8.6"
hifitime = { version = "3.8.6", default-features = true }
memmap2 = "=0.9.3"
crc32fast = "=1.3.2"
der = { version = "0.7.8", features = ["derive", "alloc", "real"] }
Expand All @@ -42,6 +42,8 @@ snafu = { version = "0.7.5", features = ["backtrace"] }
lexical-core = "0.8.5"
heapless = "0.8.0"
rstest = "0.18.2"
pyo3 = { version = "0.20.0", features = ["multiple-pymethods"] }
pyo3-log = "0.9.0"

anise = { version = "0.1.0", path = "anise", default-features = false }

Expand Down
Loading

0 comments on commit 030d470

Please sign in to comment.