-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
253e01b
commit 4f1ee97
Showing
14 changed files
with
155 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"model_type": "MTLSD", | ||
"iterations": 100000, | ||
"warmup": 100000, | ||
"raw_file": "path/to/zarr/or/n5", | ||
"voxel_size": 33, | ||
"python_script_path": "path/to/python_script.py" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "segmonitor" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
mongodb = "2.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::process::Command; | ||
use serde::{Deserialize, Serialize}; | ||
use mongodb::{Client, options::ClientOptions}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
struct Config { | ||
model_type: String, | ||
iterations: i32, | ||
warmup: i32, | ||
raw_file: String, | ||
voxel_size: i32, | ||
python_script_path: String, | ||
} | ||
|
||
pub mod segmonitor { | ||
pub fn train_model_from_config(config_path: &str) { | ||
let config = load_config(config_path); | ||
|
||
println!("Training model: {}", config.model_type); | ||
println!("Iterations: {}", config.iterations); | ||
println!("Warmup: {}", config.warmup); | ||
println!("Raw file: {}", config.raw_file); | ||
println!("Voxel size: {}", config.voxel_size); | ||
|
||
call_python_train(&config.python_script_path); | ||
|
||
save_to_mongodb(&config); | ||
} | ||
|
||
fn load_config(config_path: &str) -> Config { | ||
// Load configuration from JSON file | ||
let config_str = std::fs::read_to_string(config_path).expect("Error reading config file"); | ||
serde_json::from_str(&config_str).expect("Error parsing JSON") | ||
} | ||
|
||
fn call_python_train(script_path: &str) { | ||
let output = Command::new("python") | ||
.arg(script_path) | ||
.output() | ||
.expect("Failed to execute training"); | ||
|
||
if output.status.success() { | ||
println!("Traning executed successfully!"); | ||
} else { | ||
println!("Error executing training:\n{}", String::from_utf8_lossy(&output.stderr)); | ||
} | ||
} | ||
|
||
fn save_to_mongodb(config: &Config) { | ||
println!("Saving metrics to MongoDB..."); | ||
let client_options = ClientOptions::parse("mongodb://localhost:27017").unwrap(); | ||
let client = Client::with_options(client_options).unwrap(); | ||
// TODO: dd MongoDB insertion logic here | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use segmonitor; | ||
|
||
fn main() { | ||
let config_path = "path/to/config.json"; | ||
segmonitor::train_model_from_config(config_path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.