Skip to content

Commit 16ae371

Browse files
committed
slight renamings
1 parent ea74fdf commit 16ae371

File tree

14 files changed

+45
-43
lines changed

14 files changed

+45
-43
lines changed

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ parking_lot = "0.12.2"
1616
serde = { version = "1.0", features = ["derive"] }
1717
serde_json = "1.0"
1818
async-trait = "0.1.81"
19-
dotenvy = "0.15.7"
2019
reqwest = "0.12.5"
20+
21+
dotenvy = "0.15.7"
22+
2123
rand = "0.8.5"
24+
2225
env_logger = "0.11.3"
2326
log = "0.4.21"
2427
eyre = "0.6.12"

compute/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,18 @@ async-trait = "0.1.81"
2828
reqwest = "0.12.5"
2929

3030
# utilities
31-
dotenvy = "0.15.7"
31+
dotenvy.workspace = true
3232
base64 = "0.22.0"
3333
hex = "0.4.3"
3434
hex-literal = "0.4.1"
3535
url = "2.5.0"
3636
urlencoding = "2.1.3"
3737
uuid = { version = "1.8.0", features = ["v4"] }
38-
rand = "0.8.5"
38+
3939
port_check = "0.2.1"
4040

4141
# logging & errors
42+
rand.workspace = true
4243
env_logger.workspace = true
4344
log.workspace = true
4445
eyre.workspace = true

compute/src/config/mod.rs renamed to compute/src/config.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::utils::{address_in_use, crypto::to_address};
22
use dkn_p2p::libp2p::Multiaddr;
3-
use dkn_workflows::ModelConfig;
3+
use dkn_workflows::DriaWorkflowsConfig;
44
use eyre::{eyre, Result};
55
use libsecp256k1::{PublicKey, SecretKey};
66

@@ -18,8 +18,8 @@ pub struct DriaComputeNodeConfig {
1818
pub admin_public_key: PublicKey,
1919
/// P2P listen address, e.g. `/ip4/0.0.0.0/tcp/4001`.
2020
pub p2p_listen_addr: Multiaddr,
21-
/// Available LLM models & providers for the node.
22-
pub model_config: ModelConfig,
21+
/// Workflow configurations, e.g. models and providers.
22+
pub workflows: DriaWorkflowsConfig,
2323
}
2424

2525
/// The default P2P network listen address.
@@ -79,7 +79,8 @@ impl DriaComputeNodeConfig {
7979
let address = to_address(&public_key);
8080
log::info!("Node Address: 0x{}", hex::encode(address));
8181

82-
let model_config = ModelConfig::new_from_csv(&env::var("DKN_MODELS").unwrap_or_default());
82+
let model_config =
83+
DriaWorkflowsConfig::new_from_csv(&env::var("DKN_MODELS").unwrap_or_default());
8384
#[cfg(not(test))]
8485
if model_config.models.is_empty() {
8586
log::error!("No models were provided, make sure to restart with at least one model provided within DKN_MODELS.");
@@ -98,7 +99,7 @@ impl DriaComputeNodeConfig {
9899
secret_key,
99100
public_key,
100101
address,
101-
model_config,
102+
workflows: model_config,
102103
p2p_listen_addr,
103104
}
104105
}

compute/src/handlers/pingpong.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl ComputeHandler for PingpongHandler {
5454
// respond
5555
let response_body = PingpongResponse {
5656
uuid: pingpong.uuid.clone(),
57-
models: node.config.model_config.models.clone(),
57+
models: node.config.workflows.models.clone(),
5858
timestamp: get_current_time_nanos(),
5959
};
6060

compute/src/handlers/workflow.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,16 @@ impl ComputeHandler for WorkflowHandler {
6666
}
6767

6868
// read model / provider from the task
69-
let (model_provider, model) = config
70-
.model_config
71-
.get_any_matching_model(task.input.model)?;
69+
let (model_provider, model) = config.workflows.get_any_matching_model(task.input.model)?;
7270
let model_name = model.to_string(); // get model name, we will pass it in payload
7371
log::info!("Using model {} for task {}", model_name, task.task_id);
7472

7573
// prepare workflow executor
7674
let executor = if model_provider == ModelProvider::Ollama {
7775
Executor::new_at(
7876
model,
79-
&config.model_config.ollama.host,
80-
config.model_config.ollama.port,
77+
&config.workflows.ollama.host,
78+
config.workflows.ollama.port,
8179
)
8280
} else {
8381
Executor::new(model)

compute/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async fn main() -> Result<()> {
5454
_ = service_check_token.cancelled() => {
5555
log::info!("Service check cancelled.");
5656
}
57-
result = config_clone.model_config.check_services() => {
57+
result = config_clone.workflows.check_services() => {
5858
if let Err(err) = result {
5959
log::error!("Error checking services: {:?}", err);
6060
panic!("Service check failed.")

compute/src/node.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dkn_p2p::{libp2p::gossipsub, P2PClient};
1+
use dkn_p2p::{libp2p::gossipsub, DriaP2P};
22
use eyre::{eyre, Result};
33
use std::time::Duration;
44
use tokio_util::sync::CancellationToken;
@@ -27,7 +27,7 @@ const RPC_PEER_ID_REFRESH_INTERVAL_SECS: u64 = 30;
2727
/// ```
2828
pub struct DriaComputeNode {
2929
pub config: DriaComputeNodeConfig,
30-
pub p2p: P2PClient,
30+
pub p2p: DriaP2P,
3131
pub available_nodes: AvailableNodes,
3232
pub available_nodes_last_refreshed: tokio::time::Instant,
3333
pub cancellation: CancellationToken,
@@ -51,7 +51,7 @@ impl DriaComputeNode {
5151
)
5252
.sort_dedup();
5353

54-
let p2p = P2PClient::new(
54+
let p2p = DriaP2P::new(
5555
keypair,
5656
config.p2p_listen_addr.clone(),
5757
&available_nodes.bootstrap_nodes,

p2p/src/client.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::*;
12
use eyre::Result;
23
use libp2p::futures::StreamExt;
34
use libp2p::gossipsub::{
@@ -12,10 +13,8 @@ use libp2p_identity::Keypair;
1213
use std::time::Duration;
1314
use std::time::Instant;
1415

15-
use super::*;
16-
1716
/// P2P client, exposes a simple interface to handle P2P communication.
18-
pub struct P2PClient {
17+
pub struct DriaP2P {
1918
/// `Swarm` instance, everything is accesses through this one.
2019
swarm: Swarm<DriaBehaviour>,
2120
/// Peer count for All and Mesh peers.
@@ -33,7 +32,7 @@ const IDLE_CONNECTION_TIMEOUT_SECS: u64 = 60;
3332
/// Number of seconds between refreshing the Kademlia DHT.
3433
const PEER_REFRESH_INTERVAL_SECS: u64 = 30;
3534

36-
impl P2PClient {
35+
impl DriaP2P {
3736
/// Creates a new P2P client with the given keypair and listen address.
3837
pub fn new(
3938
keypair: Keypair,

p2p/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ mod behaviour;
22
pub use behaviour::{DriaBehaviour, DriaBehaviourEvent};
33

44
mod client;
5-
pub use client::P2PClient;
5+
pub use client::DriaP2P;
66

77
mod versioning;
88
pub use versioning::*;
99

10-
mod data_transform;
10+
mod transform;
1111

1212
// re-exports
13-
1413
pub use libp2p;
1514
pub use libp2p_identity;
File renamed without changes.

0 commit comments

Comments
 (0)