PoC: Successful End-to-End integration of CHORUS core components

This commit is contained in:
anthonyrawlins
2026-03-03 17:43:43 +11:00
parent 6147dd97ca
commit cc03616918
3 changed files with 125 additions and 14 deletions

View File

@@ -17,20 +17,22 @@ pub enum GraphError {
}
pub struct DoltGraph {
repo_path: std::path::PathBuf,
pub repo_path: std::path::PathBuf,
}
impl DoltGraph {
pub fn init(path: &Path) -> Result<Self, GraphError> {
let status = Command::new("dolt")
.arg("init")
.current_dir(path)
.status()?;
if !status.success() {
return Err(GraphError::CommandFailed(format!(
"dolt init failed with status {:?}",
status
)));
if !path.join(".dolt").exists() {
let status = Command::new("dolt")
.arg("init")
.current_dir(path)
.status()?;
if !status.success() {
return Err(GraphError::CommandFailed(format!(
"dolt init failed with status {:?}",
status
)));
}
}
Ok(Self {
repo_path: path.to_path_buf(),
@@ -44,7 +46,6 @@ impl DoltGraph {
.output()?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
eprintln!("Dolt Command Failed: {:?} -> {}", args, stderr);
return Err(GraphError::CommandFailed(stderr.to_string()));
}
Ok(())
@@ -58,8 +59,12 @@ impl DoltGraph {
pub fn create_table(&self, table_name: &str, schema: &str) -> Result<(), GraphError> {
let query = format!("CREATE TABLE {} ({})", table_name, schema);
println!("Executing: dolt sql -q \"{}\"", query);
self.run_cmd(&["sql", "-q", &query])?;
if let Err(e) = self.run_cmd(&["sql", "-q", &query]) {
if e.to_string().contains("already exists") {
return Ok(());
}
return Err(e);
}
self.commit(&format!("Create table {}", table_name))?;
Ok(())
}
@@ -93,7 +98,6 @@ impl DoltGraph {
columns.join(", "),
values.join(", ")
);
println!("Executing: dolt sql -q \"{}\"", query);
self.run_cmd(&["sql", "-q", &query])?;
Ok(())
}