diff --git a/Cargo.toml b/Cargo.toml index aefd7e2..eccf958 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "sciflow" +name = "scidataflow" version = "0.1.0" edition = "2021" include = ["src/**/*", "tests/test_data/**/*"] [lib] -name = "sciflow" +name = "scidataflow" path = "src/lib.rs" [[bin]] diff --git a/src/lib/api/zenodo.rs b/src/lib/api/zenodo.rs index 8350865..e938493 100644 --- a/src/lib/api/zenodo.rs +++ b/src/lib/api/zenodo.rs @@ -113,7 +113,7 @@ impl TryInto for LocalMetadata { fn try_into(self) -> Result { let name = self.author_name.ok_or_else(|| anyhow!("Author name is required"))?; // TODO? Warn user of default description? - let description = self.description.unwrap_or("Upload by SciFlow.".to_string()); + let description = self.description.unwrap_or("Upload by SciDataFlow.".to_string()); Ok(ZenodoDepositionData { metadata: ZenodoMetadata { @@ -260,7 +260,7 @@ mod tests { use serde_json::json; use crate::logging_setup::setup; - //#[tokio::test] + #[tokio::test] async fn test_remote_init_success() { setup(); // Start a mock server diff --git a/src/lib/project.rs b/src/lib/project.rs index 6b3375f..1f93867 100644 --- a/src/lib/project.rs +++ b/src/lib/project.rs @@ -45,7 +45,7 @@ pub fn find_manifest(start_dir: Option<&PathBuf>, filename: &str) -> Option Result { let mut config_path: PathBuf = dirs::home_dir() .ok_or_else(|| anyhow!("Cannot load home directory!"))?; - config_path.push(".sciflow_config"); + config_path.push(".scidataflow_config"); Ok(config_path) } @@ -97,20 +97,20 @@ pub struct Project { impl Project { fn get_manifest() -> Result { - find_manifest(None, MANIFEST).ok_or(anyhow!("SciFlow not initialized.")) + find_manifest(None, MANIFEST).ok_or(anyhow!("SciDataFlow not initialized.")) } pub fn load_config() -> Result { let config_path = config_path()?; let mut file = File::open(&config_path) - .with_context(|| format!("No sciflow config found at \ - {:?}. Please set with scf config --user \ - [--email --affil ]", &config_path))?; - let mut contents = String::new(); - file.read_to_string(&mut contents)?; - - let config: Config = serde_yaml::from_str(&contents)?; - Ok(config) + .map_err(|_| anyhow!("No SciDataFlow config found at \ + {:?}. Please set with scf config --user \ + [--email --affil ]", &config_path))?; + let mut contents = String::new(); + file.read_to_string(&mut contents)?; + + let config: Config = serde_yaml::from_str(&contents)?; + Ok(config) } pub fn save_config(config: Config) -> Result<()> { @@ -122,10 +122,10 @@ impl Project { } pub fn new() -> Result { - let manifest = Project::get_manifest()?; + let manifest = Project::get_manifest().context("Failed to get the manifest")?; info!("manifest: {:?}", manifest); - let data = Project::load(&manifest)?; - let config = Project::load_config()?; + let data = Project::load(&manifest).context("Failed to load data from the manifest")?; + let config = Project::load_config().context("Failed to load the project configuration")?; let proj = Project { manifest, data, config }; Ok(proj) } diff --git a/src/lib/remote.rs b/src/lib/remote.rs index a85f10b..f42f2e5 100644 --- a/src/lib/remote.rs +++ b/src/lib/remote.rs @@ -19,7 +19,7 @@ use crate::lib::api::zenodo::ZenodoAPI; use crate::lib::project::LocalMetadata; -const AUTHKEYS: &str = ".sciflow_authkeys.yml"; +const AUTHKEYS: &str = ".scidataflow_authkeys.yml"; #[derive(Debug, Clone, PartialEq)] pub struct DownloadInfo { diff --git a/src/main.rs b/src/main.rs index 63d6038..bc8aa28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,13 @@ use structopt::StructOpt; #[allow(unused_imports)] use log::{info, trace, debug}; -use sciflow::lib::project::Project; -use sciflow::logging_setup::setup; +use scidataflow::lib::project::Project; +use scidataflow::logging_setup::setup; pub mod logging_setup; const INFO: &str = "\ -SciFlow: Manage and Share Scientific Data +SciDataFlow: Manage and Share Scientific Data usage: scf [--help] Some examples: diff --git a/tests/common/mod.rs b/tests/common/mod.rs index c9574a6..4fafb04 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -20,8 +20,8 @@ use rand::rngs::StdRng; use rand::SeedableRng; use lazy_static::lazy_static; -use sciflow::lib::project::Project; -use sciflow::lib::data::StatusEntry; +use scidataflow::lib::project::Project; +use scidataflow::lib::data::StatusEntry; pub fn make_mock_fixtures() -> Vec { let files = vec![ @@ -190,6 +190,11 @@ pub fn setup(do_add: bool) -> TestFixture { let _ = test_env.build_project_directories(data_fixtures); // initializes sciflow in the test environment + let current_dir = env::current_dir().unwrap(); + info!("temp_dir: {:?}, current directory: {:?}", test_env.temp_dir, current_dir); + let _ = Project::set_config(&Some("Joan B. Scientist".to_string()), + &Some("joan@ucberkely.edu".to_string()), + &Some("UC Berkeley".to_string())); let _ = Project::init(Some(project_name)); let mut project = Project::new().expect("setting up TestFixture failed"); diff --git a/tests/test_project.rs b/tests/test_project.rs index 5ef2da5..fd2d524 100644 --- a/tests/test_project.rs +++ b/tests/test_project.rs @@ -14,7 +14,7 @@ mod tests { use super::get_statuses; use super::generate_random_tsv; use std::path::PathBuf; - use sciflow::lib::data::LocalStatusCode; + use scidataflow::lib::data::LocalStatusCode; #[test] fn test_fixture() {