Skip to content

Commit

Permalink
some log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Aug 19, 2024
1 parent 3fe904d commit 6ed9be6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 46 deletions.
52 changes: 26 additions & 26 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 @@ -44,7 +44,7 @@ fastbloom-rs = "0.5.9"
ollama-workflows = { git = "https://github.com/andthattoo/ollama-workflows", rev = "25467d2" }

# peer-to-peer
libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "c5cefa1", features = [
libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "be2ed55", features = [
"dcutr",
"ping",
"relay",
Expand Down
2 changes: 1 addition & 1 deletion src/config/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl ModelConfig {
match result {
Ok(result) => Some(result),
Err(e) => {
log::error!("Ignoring model: {}", e);
log::debug!("Ignoring model: {}", e);
None
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/config/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ struct OpenAIModelsResponse {
object: String,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
pub struct OpenAIConfig {
pub(crate) api_key: Option<String>,
}

#[derive(Debug, Clone, Deserialize)]
struct OpenAIError {
message: String,
}

impl OpenAIConfig {
/// Looks at the environment variables for OpenAI API key.
pub fn new() -> Self {
Expand Down
4 changes: 2 additions & 2 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ impl DriaComputeNode {
// };

log::info!(
"Received {} message ({})\nFrom: {}\nOrigin: {:?}",
"Received {} message ({})\nFrom: {}\nOrigin: {}",
topic_str,
message_id,
peer_id,
source_peer_id
source_peer_id.map(|p| p.to_string()).unwrap_or("None".to_string())
);

// ensure that message is from the static RPCs
Expand Down
16 changes: 6 additions & 10 deletions src/p2p/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,21 @@ impl P2PClient {
.get_closest_peers(random_peer);
self.peer_last_refreshed = tokio::time::Instant::now();

// print number of peers
// get peer count
let gossipsub = &self.swarm.behaviour().gossipsub;

// print peers if the count has changed
let num_peers = gossipsub.all_peers().count();
let num_mesh_peers = gossipsub.all_mesh_peers().count();

// print peers if the count has changed
if num_peers != self.peer_count.0 || num_mesh_peers != self.peer_count.1 {
self.peer_count = (num_peers, num_mesh_peers);
log::info!(
"Peer Count (mesh / all): {} / {}",
num_mesh_peers,
num_peers
);
log::info!("Peer Count (mesh/all): {} / {}", num_mesh_peers, num_peers);
log::debug!(
"All Peers:\n{}",
gossipsub
.all_peers()
.enumerate()
.map(|(i, (p, _))| format!("{:#3}: {}", i, p.to_string()))
.map(|(i, (p, _))| format!("{:#3}: {}", i, p))
.collect::<Vec<_>>()
.join("\n")
);
Expand All @@ -338,7 +334,7 @@ impl P2PClient {
gossipsub
.all_mesh_peers()
.enumerate()
.map(|(i, p)| format!("{:#3}: {}", i, p.to_string()))
.map(|(i, p)| format!("{:#3}: {}", i, p))
.collect::<Vec<_>>()
.join("\n")
);
Expand Down

0 comments on commit 6ed9be6

Please sign in to comment.