Skip to content

Commit

Permalink
Fix Lagrange test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Aug 23, 2024
1 parent f2431b3 commit d62bfb0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 20 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,12 @@ jobs:
- name: Test debug
env:
LAGRANGE_BSP: ${{ secrets.LAGRANGE_BSP }}
run: |
[ -n "$LAGRANGE_BSP" ] && cargo test --workspace --exclude anise-gui --exclude anise-py
run: cargo test --workspace --exclude anise-gui --exclude anise-py

- name: Test release
env:
LAGRANGE_BSP: ${{ secrets.LAGRANGE_BSP }}
run: |
[ -n "$LAGRANGE_BSP" ] && cargo test --release --workspace --exclude anise-gui --exclude anise-py
run: cargo test --release --workspace --exclude anise-gui --exclude anise-py

- name: Test rust_embed build
run: |
Expand Down Expand Up @@ -135,7 +133,7 @@ jobs:
- name: Rust-SPICE Lagrange validation
env:
LAGRANGE_BSP: ${{ secrets.LAGRANGE_BSP }}
run: RUST_BACKTRACE=1 [ -n "$LAGRANGE_BSP" ] && cargo test validate_lagrange_type9_with_varying_segment_sizes --features spkezr_validation --release --workspace --exclude anise-gui --exclude anise-py -- --nocapture --include-ignored --test-threads 1
run: RUST_BACKTRACE=1 cargo test validate_lagrange_type9_with_varying_segment_sizes --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 --exclude anise-py -- --nocapture --ignored
Expand Down Expand Up @@ -207,7 +205,7 @@ jobs:
cargo llvm-cov test --no-report validate_jplde_de440s_no_aberration --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report validate_jplde_de440s_aberration_lt --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report validate_hermite_type13_from_gmat --features spkezr_validation -- --nocapture --ignored
[ -n "$LAGRANGE_BSP" ] && cargo llvm-cov test --no-report validate_lagrange_type9_with_varying_segment_sizes --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report validate_lagrange_type9_with_varying_segment_sizes --features spkezr_validation -- --nocapture --ignored
cargo llvm-cov test --no-report ut_embed --features embed_ephem
cargo llvm-cov report --lcov > ../lcov.txt
Expand Down
2 changes: 1 addition & 1 deletion anise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ For convenience, Nyx Space provides a few important SPICE files on a public buck
+ [pck11.pca](http://public-data.nyxspace.com/anise/v0.4/pck11.pca): planetary constants ANISE (`pca`) kernel, built from the JPL gravitational data [gm_de431.tpc](http://public-data.nyxspace.com/anise/gm_de431.tpc) and JPL's plantary constants file [pck00011.tpc](http://public-data.nyxspace.com/anise/pck00011.tpc)
+ [moon_fk.epa](http://public-data.nyxspace.com/anise/v0.4/moon_fk.epa): Euler Parameter ANISE (`epa`) kernel, built from the JPL Moon Frame Kernel `moon_080317.txt`

You may load any of these using the `load()` shortcut that will determine the file type upon loading, e.g. `let almanac = Almanac::new("pck08.pca").unwrap();` or in Python `almanac = Almanac("pck08.pca")`. To automatically download remote assets, from the Nyx Cloud or elsewhere, use the MetaAlmanac: `almanac = MetaAlmanac("ci_config.dhall").process()` in Python.
You may load any of these using the `load()` shortcut that will determine the file type upon loading, e.g. `let almanac = Almanac::new("pck08.pca").unwrap();` or in Python `almanac = Almanac("pck08.pca")`. To automatically download remote assets, from the Nyx Cloud or elsewhere, use the MetaAlmanac: `almanac = MetaAlmanac("ci_config.dhall").process(true)` in Python.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion anise/src/almanac/metaload/metaalmanac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl MetaAlmanac {

/// Fetch all of the URIs and return a loaded Almanac
pub fn process(&mut self, py: Python, autodelete: Option<bool>) -> AlmanacResult<Almanac> {
py.allow_threads(|| self._process(autodelete.unwrap_or(false)))
py.allow_threads(|| self._process(autodelete.unwrap_or(true)))
}

fn __str__(&self) -> String {
Expand Down
28 changes: 18 additions & 10 deletions anise/src/almanac/metaload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub enum MetaAlmanacError {
#[cfg_attr(feature = "python", pymethods)]
impl Almanac {
/// Load from the provided MetaFile.
fn _load_from_metafile(&self, mut metafile: MetaFile) -> AlmanacResult<Self> {
metafile._process(true).context(MetaSnafu {
fn _load_from_metafile(&self, mut metafile: MetaFile, autodelete: bool) -> AlmanacResult<Self> {
metafile._process(autodelete).context(MetaSnafu {
fno: 0_usize,
file: metafile.clone(),
})?;
Expand All @@ -66,14 +66,19 @@ impl Almanac {

/// Load from the provided MetaFile, downloading it if necessary.
#[cfg(not(feature = "python"))]
pub fn load_from_metafile(&self, metafile: MetaFile) -> AlmanacResult<Self> {
self._load_from_metafile(metafile)
pub fn load_from_metafile(&self, metafile: MetaFile, autodelete: bool) -> AlmanacResult<Self> {
self._load_from_metafile(metafile, autodelete)
}

#[cfg(feature = "python")]
/// Load from the provided MetaFile, downloading it if necessary.
pub fn load_from_metafile(&mut self, py: Python, metafile: MetaFile) -> AlmanacResult<Self> {
py.allow_threads(|| self._load_from_metafile(metafile))
pub fn load_from_metafile(
&mut self,
py: Python,
metafile: MetaFile,
autodelete: bool,
) -> AlmanacResult<Self> {
py.allow_threads(|| self._load_from_metafile(metafile, autodelete))
}
}

Expand All @@ -99,10 +104,13 @@ mod meta_test {
assert!(meta._process(true).is_ok());
// Test that loading from an invalid URI reports an error
assert!(almanac
._load_from_metafile(MetaFile {
uri: "http://example.com/non/existing.pca".to_string(),
crc32: None
})
._load_from_metafile(
MetaFile {
uri: "http://example.com/non/existing.pca".to_string(),
crc32: None
},
true
)
.is_err());
}

Expand Down
2 changes: 1 addition & 1 deletion anise/tests/ephemerides/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn de440s_transform_verif_venus2emb() {
fn spice_verif_iau_moon() {
let _ = pretty_env_logger::try_init();

let almanac = MetaAlmanac::default().process().unwrap();
let almanac = MetaAlmanac::default().process(true).unwrap();

let epoch = Epoch::from_str("2024-09-22T08:45:22 UTC").unwrap();
// This state is identical in ANISE and SPICE, queried from a BSP.
Expand Down
9 changes: 8 additions & 1 deletion anise/tests/ephemerides/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,17 +624,24 @@ fn de440s_translation_verif_aberrations() {
#[cfg(feature = "metaload")]
#[test]
fn type9_lagrange_query() {
use std::env;

use anise::almanac::metaload::MetaFile;
use anise::constants::frames::EARTH_J2000;
use anise::prelude::Frame;

if let Err(_) = env::var("LAGRANGE_BSP") {
// Skip this test if the env var is not defined.
return;
}

let lagrange_meta = MetaFile {
uri: "http://public-data.nyxspace.com/anise/ci/env:LAGRANGE_BSP".to_string(),
crc32: None,
};

let almanac = Almanac::default()
.load_from_metafile(lagrange_meta)
.load_from_metafile(lagrange_meta, true)
.unwrap();

let obj_id = -10;
Expand Down
6 changes: 6 additions & 0 deletions anise/tests/ephemerides/validation/type09_lagrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@

use super::{compare::*, validate::Validation};
use anise::almanac::metaload::MetaFile;
use std::env;

#[ignore = "Requires Rust SPICE -- must be executed serially"]
#[test]
fn validate_lagrange_type9_with_varying_segment_sizes() {
if let Err(_) = env::var("LAGRANGE_BSP") {
// Skip this test if the env var is not defined.
return;
}

let mut lagrange_meta = MetaFile {
uri: "http://public-data.nyxspace.com/anise/ci/env:LAGRANGE_BSP".to_string(),
crc32: None,
Expand Down

0 comments on commit d62bfb0

Please sign in to comment.