Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v.0.1.3 #110

Merged
merged 5 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["discovery", "miner", "validator", "shared", "orchestrator", "dev-uti
resolver = "2"

[workspace.package]
version = "0.1.2"
version = "0.1.3"
edition = "2021"

[workspace.features]
Expand Down
6 changes: 6 additions & 0 deletions miner/src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,15 @@ pub async fn execute_command(
None => None,
};

let system_memory = node_config
.compute_specs
.as_ref()
.map(|specs| specs.ram_mb.unwrap_or(0));

let docker_service = Arc::new(DockerService::new(
cancellation_token.clone(),
has_gpu,
system_memory,
task_bridge.socket_path.clone(),
docker_storage_path,
));
Expand Down
3 changes: 3 additions & 0 deletions miner/src/docker/docker_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl DockerManager {
Ok(())
}

#[allow(clippy::too_many_arguments)]
/// Start a new container with the given image and configuration
pub async fn start_container(
&self,
Expand All @@ -105,6 +106,7 @@ impl DockerManager {
gpu_enabled: bool,
// Simple Vec of (host_path, container_path, read_only)
volumes: Option<Vec<(String, String, bool)>>,
shm_size: Option<u64>,
) -> Result<String, DockerError> {
println!("Starting to pull image: {}", image);

Expand Down Expand Up @@ -178,6 +180,7 @@ impl DockerManager {
options: Some(HashMap::new()),
}]),
binds: volume_binds,
shm_size: shm_size.map(|s| s as i64),
..Default::default()
})
} else {
Expand Down
16 changes: 14 additions & 2 deletions miner/src/docker/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct DockerService {
cancellation_token: CancellationToken,
pub state: Arc<DockerState>,
has_gpu: bool,
system_memory_mb: Option<u32>,
task_bridge_socket_path: String,
}

Expand All @@ -27,6 +28,7 @@ impl DockerService {
pub fn new(
cancellation_token: CancellationToken,
has_gpu: bool,
system_memory_mb: Option<u32>,
task_bridge_socket_path: String,
storage_path: Option<String>,
) -> Self {
Expand All @@ -36,6 +38,7 @@ impl DockerService {
cancellation_token,
state: Arc::new(DockerState::new()),
has_gpu,
system_memory_mb,
task_bridge_socket_path,
}
}
Expand Down Expand Up @@ -142,6 +145,7 @@ impl DockerService {
let manager_clone = manager_clone.clone();
let state_clone = state.clone();
let has_gpu = self.has_gpu;
let system_memory_mb = self.system_memory_mb;
let task_bridge_socket_path = self.task_bridge_socket_path.clone();
let handle = tokio::spawn(async move {
let payload = task_clone.unwrap();
Expand Down Expand Up @@ -170,8 +174,14 @@ impl DockerService {
false,
)
];

match manager_clone.start_container(&payload.image, &container_task_id, Some(env_vars), Some(cmd), has_gpu, Some(volumes)).await {
let shm_size = match system_memory_mb {
Some(mem_mb) => (mem_mb as u64) * 1024 * 1024 / 2, // Convert MB to bytes and divide by 2
None => {
Console::warning("System memory not available, using default shm size");
67108864 // Default to 64MB in bytes
}
};
match manager_clone.start_container(&payload.image, &container_task_id, Some(env_vars), Some(cmd), has_gpu, Some(volumes), Some(shm_size)).await {
Ok(container_id) => {
Console::info("DockerService", &format!("Container started with id: {}", container_id));
},
Expand Down Expand Up @@ -276,6 +286,7 @@ mod tests {
let docker_service = DockerService::new(
cancellation_token.clone(),
false,
Some(1024),
"/tmp/com.prime.miner/metrics.sock".to_string(),
None,
);
Expand Down Expand Up @@ -319,6 +330,7 @@ mod tests {
let docker_service = DockerService::new(
cancellation_token.clone(),
false,
Some(1024),
"/tmp/com.prime.miner/metrics.sock".to_string(),
None,
);
Expand Down
Loading