Skip to content

Commit

Permalink
Cleanup load_from_metafile overload
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Dec 24, 2024
1 parent 9cfa462 commit 22fdcc9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions anise/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ regex = { version = "1.10.5", optional = true }

[dev-dependencies]
rust-spice = "0.7.6"
parquet = "53.0.0"
arrow = "53.0.0"
parquet = "54.0.0"
arrow = "54.0.0"
criterion = "0.5"
iai = "0.1"
pretty_env_logger = { workspace = true }
Expand Down
25 changes: 12 additions & 13 deletions anise/src/almanac/metaload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,23 @@ pub enum MetaAlmanacError {
}

impl Almanac {
/// Load from the provided MetaFile.
fn _load_from_metafile(&self, mut metafile: MetaFile, autodelete: bool) -> AlmanacResult<Self> {
/// Load from the provided MetaFile, downloading it if necessary.
/// Set autodelete to true to automatically delete lock files. Lock files are important in multi-threaded loads.
pub fn load_from_metafile(
&self,
mut metafile: MetaFile,
autodelete: bool,
) -> AlmanacResult<Self> {
metafile._process(autodelete).context(MetaSnafu {
fno: 0_usize,
file: metafile.clone(),
})?;
self.load(&metafile.uri)
}

/// Load from the provided MetaFile, downloading it if necessary.
/// Set autodelete to true to automatically delete lock files. Lock files are important in multi-threaded loads.
#[cfg(not(feature = "python"))]
pub fn load_from_metafile(&self, metafile: MetaFile, autodelete: bool) -> AlmanacResult<Self> {
self._load_from_metafile(metafile, autodelete)
}
}

#[cfg(feature = "python")]
#[cfg_attr(feature = "python", pymethods)]
#[pymethods]
impl Almanac {
/// Load from the provided MetaFile, downloading it if necessary.
/// Set autodelete to true to automatically delete lock files. Lock files are important in multi-threaded loads.
Expand All @@ -81,13 +79,14 @@ impl Almanac {
/// :type metafile: Metafile
/// :type autodelete: bool
/// :rtype: Almanac
fn load_from_metafile(
#[pyo3(name = "load_from_metafile")]
fn py_load_from_metafile(
&mut self,
py: Python,
metafile: MetaFile,
autodelete: bool,
) -> AlmanacResult<Self> {
py.allow_threads(|| self._load_from_metafile(metafile, autodelete))
py.allow_threads(|| self.load_from_metafile(metafile, autodelete))
}
}

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

0 comments on commit 22fdcc9

Please sign in to comment.