Skip to content

Commit

Permalink
build: update exon
Browse files Browse the repository at this point in the history
  • Loading branch information
tshauck committed Aug 18, 2024
1 parent 3fc84b2 commit 9947306
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ name = "biobear"

[dependencies]
arrow = { version = "52.1.0", features = ["pyarrow"] }
datafusion = "40"
exon = { version = "0.30.0", features = ["default"] }
datafusion = "41"
exon = { version = "0.31.0", features = ["default"] }
pyo3 = "0.21.2"
tokio = { version = "1", features = ["rt"] }
noodles = { version = "0.79", features = ["core"] }
Expand Down
6 changes: 5 additions & 1 deletion src/bam_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ impl BamIndexedReader {
config = config.with_batch_size(batch_size);
}

let ctx = ExonSession::with_config_exon(config);
let ctx = ExonSession::with_config_exon(config).map_err(|e| {
PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!(
"Error creating ExonSession: {e}"
))
})?;

let df = self._runtime.block_on(async {
ctx.sql(&format!(
Expand Down
2 changes: 1 addition & 1 deletion src/bcf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl BCFIndexedReader {
config = config.with_batch_size(batch_size);
}

let ctx = ExonSession::with_config_exon(config);
let ctx = ExonSession::with_config_exon(config).map_err(BioBearError::from)?;

let region = Region::from_str(region).map_err(|e| {
io::Error::new(io::ErrorKind::Other, format!("Error parsing region: {e}"))
Expand Down
2 changes: 1 addition & 1 deletion src/exon_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl ExonReader {
config = config.with_batch_size(batch_size);
}

let ctx = ExonSession::with_config_exon(config);
let ctx = ExonSession::with_config_exon(config).map_err(BioBearError::from)?;

let df = rt.block_on(async {
ctx.session
Expand Down
18 changes: 6 additions & 12 deletions src/session_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,13 @@ pub struct BioBearSessionContext {
ctx: ExonSession,
}

impl Default for BioBearSessionContext {
fn default() -> Self {
Self {
ctx: ExonSession::new_exon(),
}
}
}

#[pymethods]
impl BioBearSessionContext {
#[new]
fn new() -> PyResult<Self> {
Ok(Self::default())
fn try_new() -> PyResult<Self> {
let ctx = ExonSession::new_exon().unwrap();

Ok(Self { ctx })
}

/// Read one or more VCF files from the given path.
Expand Down Expand Up @@ -346,10 +340,10 @@ impl BioBearSessionContext {

#[pyfunction]
pub fn connect() -> PyResult<BioBearSessionContext> {
Ok(BioBearSessionContext::default())
BioBearSessionContext::try_new()
}

#[pyfunction]
pub fn new_session() -> PyResult<BioBearSessionContext> {
Ok(BioBearSessionContext::default())
BioBearSessionContext::try_new()
}
2 changes: 1 addition & 1 deletion src/vcf_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl VCFIndexedReader {
config = config.with_batch_size(batch_size);
}

let ctx = ExonSession::with_config_exon(config);
let ctx = ExonSession::with_config_exon(config).map_err(BioBearError::from)?;

let region = Region::from_str(region).map_err(|e| {
io::Error::new(
Expand Down

0 comments on commit 9947306

Please sign in to comment.