Skip to content

Commit

Permalink
add test case for apache/arrow-rs#5310
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlKCarlK committed Jan 19, 2024
1 parent 682da1d commit 543c26d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
1 change: 0 additions & 1 deletion bed_reader/tests/test_open_bed_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,4 +1096,3 @@ def test_http_two():
# test_c_reader_bed(shared_datadir)
# test_read1(shared_datadir)
pytest.main([__file__])
# cmk let python users control concurrancy and memory usage (like cloud_options? like num_threads?)
8 changes: 8 additions & 0 deletions src/supplemental_documents/cloud_urls_etc.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Cloud URLs and ObjectPath Examples

cmk update with this about how splitting url in two:
let option_store = HttpBuilder::new()
.with_url("https://www.ebi.ac.uk/")
.build()?;
let store_path =
StorePath::parse("biostudies/files/S-BSST936/example/synthetic_small_v1_chr-10.bed")?;
let object_path = ObjectPath::new(Arc::new(option_store), store_path);

To specify a file in the cloud, you must specify either

* a URL string plus options, or
Expand Down
43 changes: 43 additions & 0 deletions tests/tests_api_cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::collections::HashSet;
use std::panic::catch_unwind;
use std::sync::Arc;
use std::time::Duration;

use bed_reader::allclose;
use bed_reader::assert_eq_nan;
Expand All @@ -27,8 +28,10 @@ use bed_reader::{sample_url, sample_urls};
use ndarray as nd;
use ndarray::s;
use object_store::aws::AmazonS3Builder;
use object_store::http::HttpBuilder;
use object_store::local::LocalFileSystem;
use object_store::path::Path as StorePath;
use object_store::ClientOptions;
use object_store::ObjectStore;
use thousands::Separable;
use tokio::runtime;
Expand Down Expand Up @@ -2464,3 +2467,43 @@ async fn http_two() -> Result<(), Box<BedErrorPlus>> {
assert!(val.dim() == (10, 10) || val.dim() == (10, 11));
Ok(())
}

#[tokio::test]
async fn http_object_path() -> Result<(), Box<BedErrorPlus>> {
// small
// let url =
// "https://www.ebi.ac.uk/biostudies/files/S-BSST936/example/synthetic_small_v1_chr-10.bed";
let client_options = ClientOptions::new().with_timeout(Duration::from_secs(1000));
let option_store = HttpBuilder::new()
.with_url("https://www.ebi.ac.uk/")
.with_client_options(client_options)
.build()?;
let store_path =
StorePath::parse("biostudies/files/S-BSST936/example/synthetic_small_v1_chr-10.bed")?;
let object_path = ObjectPath::new(Arc::new(option_store), store_path);

// Open the bed file with a URL and any needed cloud options, then use as before.
let mut bed_cloud = BedCloud::builder_from_object_path(&object_path)
.skip_early_check()
.build()
.await?;
println!("{:?}", bed_cloud.iid().await?.slice(s![..5]));
println!("{:?}", bed_cloud.sid().await?.slice(s![..5]));
Ok(())
}

#[tokio::test]
async fn http_long_url() -> Result<(), Box<BedErrorPlus>> {
// small
// Open the bed file with a URL and any needed cloud options, then use as before.
let mut bed_cloud = BedCloud::builder(
"https://www.ebi.ac.uk/biostudies/files/S-BSST936/example/synthetic_small_v1_chr-10.bed",
[("timeout", "1000")], // cmk must figure this out
)?
.skip_early_check()
.build()
.await?;
println!("{:?}", bed_cloud.iid().await?.slice(s![..5]));
println!("{:?}", bed_cloud.sid().await?.slice(s![..5]));
Ok(())
}

0 comments on commit 543c26d

Please sign in to comment.