Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python interface ! #151

Merged
merged 36 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e37bdf8
Set up skeleton for anise python
ChristopherRabotin Dec 27, 2023
3b70a17
[python] Add hifitime
ChristopherRabotin Dec 27, 2023
124cc80
[python] Add hifitime export tests
ChristopherRabotin Dec 27, 2023
b578632
[python] Add Frame, Ellipsoid, and Orbit
ChristopherRabotin Dec 28, 2023
648be81
Add Frame constants to Python
ChristopherRabotin Dec 29, 2023
24d1171
Can load files from Python
ChristopherRabotin Dec 29, 2023
d87a0b2
Export state transformation to Python
ChristopherRabotin Dec 29, 2023
3c688dd
[python] Export for translate_from_to
ChristopherRabotin Dec 29, 2023
4232f17
[rust] [python] Fix signature of try_from_altlatlong to try_from_latl…
ChristopherRabotin Dec 29, 2023
e38457a
Move Python workflow to correct folder
ChristopherRabotin Dec 29, 2023
f2262c1
Rename Aberration "None" to "NotSet"
ChristopherRabotin Dec 29, 2023
0e03afc
Exclude anise-py from Rust tests
ChristopherRabotin Dec 29, 2023
4750fc8
Exclude anise-py from all but one CI
ChristopherRabotin Dec 29, 2023
f31905f
Trying to fix the build
ChristopherRabotin Dec 29, 2023
0324240
[python] Add openssl install to Linux build
ChristopherRabotin Dec 29, 2023
43f425f
[python] Fix placement of apt
ChristopherRabotin Dec 29, 2023
3735500
Remoe sccache
ChristopherRabotin Dec 29, 2023
5e3fe87
[python] [CI] Add libatomic needed for hifitime build
ChristopherRabotin Dec 29, 2023
e0a501b
Add pickling of Frame and Ellipsoid
ChristopherRabotin Dec 29, 2023
e0158d1
Remove anyse-py from cli build
ChristopherRabotin Dec 29, 2023
62ac862
[python] [CI] Try to remove sccache from macos build
ChristopherRabotin Dec 29, 2023
4dc6bb8
Add extension-module to pyo3 dependency
ChristopherRabotin Dec 29, 2023
2a688b6
[python] [CI] Add cargo configs for macos
ChristopherRabotin Dec 29, 2023
079d6f6
[python] [CI] Fix dist path
ChristopherRabotin Dec 29, 2023
dbd8c5e
Adding more verbosity
ChristopherRabotin Dec 29, 2023
5a96b87
[rust] Fix bug if file exists but less than 1024 bytes long
ChristopherRabotin Dec 29, 2023
319d799
[python] [CI] Hunting the likely git lfs issue
ChristopherRabotin Dec 29, 2023
4093ac6
Add auto downloader to ANISE via MetaAlmanac
ChristopherRabotin Dec 30, 2023
1cbf2f5
Implements the meta almanac
ChristopherRabotin Dec 30, 2023
2a560a1
Add LFS to Python tests
ChristopherRabotin Dec 30, 2023
19fc724
[python] [CI] Trying to figure out arch issues
ChristopherRabotin Dec 30, 2023
7e5b6ab
[python] [CI] Change pytest depending on arch
ChristopherRabotin Dec 30, 2023
4ea3490
[rust] Fix erroneously removed MetaAlmanac::new() when no python built
ChristopherRabotin Dec 30, 2023
0862142
[python] [CI] Fix path in Dhall
ChristopherRabotin Dec 30, 2023
f94d3f3
[python] [CI] Encourage MetaAlmanac to pass on Github CI
ChristopherRabotin Dec 30, 2023
09e4c98
[python] [CI] Remove x86 from pytest
ChristopherRabotin Dec 30, 2023
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
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
Loading