MCPcopy Create free account
hub / github.com/SingleRust/SingleRust / load_resource

Function load_resource

src/connectors/omnipath.rs:14–28  ·  view source on GitHub ↗
(name: &str, license: &str, tax_id: Option<&str>)

Source from the content-addressed store, hash-verified

12const LICENSE_TYPES: [&str; 3] = ["academic", "commercial", "nonprofit"];
13
14pub fn load_resource(name: &str, license: &str, tax_id: Option<&str>) -> anyhow::Result<DataFrame> {
15 if !LICENSE_TYPES.contains(&license) {
16 return Err(anyhow!(
17 "This license is not an allowed type, available are: academic, commercial, nonprofit."
18 ));
19 }
20
21 let path = OMNIPATH_BASE_URL.to_owned() + format!("{}&license={}", name, license).as_str();
22
23 let results = Runtime::new().unwrap().block_on(download_resource(&path))?;
24 let res_bytes = results.to_bytes();
25 let df = dataframe_from_csv_bytes(res_bytes, b'\t', true, None)?;
26 let df = process_omnipath_dataframe(df, tax_id)?;
27 Ok(df)
28}
29
30fn process_omnipath_dataframe(
31 mut df: DataFrame,

Callers 1

Calls 3

download_resourceFunction · 0.85
dataframe_from_csv_bytesFunction · 0.85

Tested by

no test coverage detected