diff --git a/crates/pile-config/src/lib.rs b/crates/pile-config/src/lib.rs index 4012d06..d25936b 100644 --- a/crates/pile-config/src/lib.rs +++ b/crates/pile-config/src/lib.rs @@ -33,9 +33,6 @@ pub struct DatasetConfig { /// Must be unique pub name: Label, - /// Root dir for indices - pub working_dir: Option, - /// Where to find this field pub source: HashMap, } diff --git a/crates/pile-dataset/src/dataset.rs b/crates/pile-dataset/src/dataset.rs index da56f0c..0ba2855 100644 --- a/crates/pile-dataset/src/dataset.rs +++ b/crates/pile-dataset/src/dataset.rs @@ -102,8 +102,6 @@ impl Datasets { let config = ConfigToml { dataset: DatasetConfig { name: Label::new("virtual-dataset").unwrap(), - working_dir: None, - source: [( Self::virt_source(), Source::Filesystem { @@ -155,7 +153,10 @@ impl Datasets { }); } - pub async fn open(config: impl Into) -> Result { + pub async fn open( + config: impl Into, + working_dir_root: impl Into, + ) -> Result { let path_config = config.into(); let path_parent = path_config .parent() @@ -184,12 +185,7 @@ impl Datasets { } }; - let path_workdir = config - .dataset - .working_dir - .clone() - .unwrap_or(path_parent.join(".pile")) - .join(config.dataset.name.as_str()); + let path_workdir = working_dir_root.into().join(config.dataset.name.as_str()); let mut sources = HashMap::new(); let mut disabled_sources = HashMap::new(); diff --git a/crates/pile/src/command/check.rs b/crates/pile/src/command/check.rs index 6d71d9f..033d760 100644 --- a/crates/pile/src/command/check.rs +++ b/crates/pile/src/command/check.rs @@ -13,6 +13,10 @@ pub struct CheckCommand { /// Path to dataset config #[arg(long, short = 'c', default_value = "./pile.toml")] config: PathBuf, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for CheckCommand { @@ -43,7 +47,7 @@ impl CliCmd for CheckCommand { } } - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/fields.rs b/crates/pile/src/command/fields.rs index 3ff61d0..b1596a0 100644 --- a/crates/pile/src/command/fields.rs +++ b/crates/pile/src/command/fields.rs @@ -43,6 +43,10 @@ pub struct FieldsCommand { /// Restrict to these sources (all sources if empty) #[arg(long, short = 's')] source: Vec, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for FieldsCommand { @@ -53,7 +57,7 @@ impl CliCmd for FieldsCommand { _ctx: GlobalContext, flag: CancelFlag, ) -> Result> { - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/index.rs b/crates/pile/src/command/index.rs index 9e53070..c7d751c 100644 --- a/crates/pile/src/command/index.rs +++ b/crates/pile/src/command/index.rs @@ -16,6 +16,10 @@ pub struct IndexCommand { /// Number of threads to use for indexing #[arg(long, short = 'j', default_value = "3")] jobs: usize, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for IndexCommand { @@ -24,7 +28,7 @@ impl CliCmd for IndexCommand { _ctx: GlobalContext, flag: CancelFlag, ) -> Result> { - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/item.rs b/crates/pile/src/command/item.rs index 5d40910..17e1e1a 100644 --- a/crates/pile/src/command/item.rs +++ b/crates/pile/src/command/item.rs @@ -30,6 +30,10 @@ pub struct ItemCommand { /// Path to dataset config #[arg(long, short = 'c', default_value = "./pile.toml")] config: PathBuf, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for ItemCommand { @@ -43,7 +47,7 @@ impl CliCmd for ItemCommand { let source = Label::new(&self.source) .ok_or_else(|| anyhow::anyhow!("invalid source name {:?}", self.source))?; - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/list.rs b/crates/pile/src/command/list.rs index b2943a1..8087eac 100644 --- a/crates/pile/src/command/list.rs +++ b/crates/pile/src/command/list.rs @@ -31,6 +31,10 @@ pub struct ListCommand { /// Restrict to these sources (all sources if empty) #[arg(long, short = 's')] source: Vec, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for ListCommand { @@ -44,7 +48,7 @@ impl CliCmd for ListCommand { .with_context(|| format!("invalid path {:?}", self.path))?; let path = Arc::new(path); - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/lookup.rs b/crates/pile/src/command/lookup.rs index e2e341a..ea08a9f 100644 --- a/crates/pile/src/command/lookup.rs +++ b/crates/pile/src/command/lookup.rs @@ -31,6 +31,10 @@ pub struct LookupCommand { /// Number of threads to use for indexing #[arg(long, short = 'j', default_value = "3")] jobs: usize, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for LookupCommand { @@ -40,7 +44,7 @@ impl CliCmd for LookupCommand { _ctx: GlobalContext, flag: CancelFlag, ) -> Result> { - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/serve.rs b/crates/pile/src/command/serve.rs index 4c14c92..df4462f 100644 --- a/crates/pile/src/command/serve.rs +++ b/crates/pile/src/command/serve.rs @@ -25,6 +25,10 @@ pub struct ServeCommand { /// Number of threads to use for indexing #[arg(long, short = 'j', default_value = "3")] jobs: usize, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for ServeCommand { @@ -33,7 +37,7 @@ impl CliCmd for ServeCommand { _ctx: GlobalContext, flag: CancelFlag, ) -> Result> { - let ds = Datasets::open(&self.config) + let ds = Datasets::open(&self.config, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", self.config.display()))?; diff --git a/crates/pile/src/command/server.rs b/crates/pile/src/command/server.rs index 6754acd..80a0a15 100644 --- a/crates/pile/src/command/server.rs +++ b/crates/pile/src/command/server.rs @@ -35,6 +35,10 @@ pub struct ServerCommand { /// If provided, require this bearer token for all requests #[arg(long)] token: Option, + + /// Working directory root + #[arg(long, default_value = "./.pile")] + workdir: PathBuf, } impl CliCmd for ServerCommand { @@ -46,7 +50,7 @@ impl CliCmd for ServerCommand { let datasets = { let mut datasets = Vec::new(); for c in &self.config { - let ds = Datasets::open(&c) + let ds = Datasets::open(&c, &self.workdir) .await .with_context(|| format!("while opening dataset for {}", c.display()))?; datasets.push(Arc::new(ds));