Skip to content

Commit a417b7b

Browse files
committed
update workflows doc, todo p2p versioning
1 parent 16ae371 commit a417b7b

File tree

10 files changed

+38
-29
lines changed

10 files changed

+38
-29
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ endif
77
###############################################################################
88
.PHONY: launch # | Run with INFO logs in release mode
99
launch:
10-
RUST_LOG=none,dkn_compute=info,dkn_workflows=info cargo run --release
10+
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info cargo run --release
1111

1212
.PHONY: run # | Run with INFO logs
1313
run:
14-
RUST_LOG=none,dkn_compute=info,dkn_workflows=info cargo run
14+
RUST_LOG=none,dkn_compute=info,dkn_workflows=info,dkn_p2p=info cargo run
1515

1616
.PHONY: debug # | Run with DEBUG logs with INFO log-level workflows
1717
debug:
18-
RUST_LOG=warn,dkn_compute=debug,,dkn_workflows=debug,ollama_workflows=info cargo run
18+
RUST_LOG=warn,dkn_compute=debug,dkn_workflows=debug,dkn_p2p=debug,ollama_workflows=info cargo run
1919

2020
.PHONY: trace # | Run with TRACE logs
2121
trace:

compute/Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
[package]
22
name = "dkn-compute"
3-
version = "0.2.10"
3+
version = "0.2.11"
44
edition.workspace = true
55
license.workspace = true
66
readme = "README.md"
7-
authors = [
8-
"Erhan Tezcan <[email protected]>",
9-
"Anil Altuner <[email protected]",
10-
]
7+
authors = ["Erhan Tezcan <[email protected]>"]
118

129
# profiling build for flamegraphs
1310
[profile.profiling]

p2p/Cargo.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ version = "0.1.0"
44
edition.workspace = true
55
license.workspace = true
66
readme = "README.md"
7-
authors = ["Erhan Tezcan <[email protected]>"]
7+
authors = [
8+
"Erhan Tezcan <[email protected]>",
9+
"Anil Altuner <[email protected]",
10+
]
811

912
[dependencies]
1013
libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "7ce9f9e", features = [
@@ -25,7 +28,8 @@ libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "7ce9f9
2528
"kad",
2629
] }
2730
libp2p-identity = { version = "0.2.9", features = ["secp256k1"] }
28-
29-
env_logger.workspace = true
3031
log.workspace = true
3132
eyre.workspace = true
33+
34+
[dev-dependencies]
35+
env_logger.workspace = true

p2p/src/behaviour.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::collections::hash_map;
22
use std::hash::{Hash, Hasher};
33
use std::time::Duration;
44

5-
use libp2p::identity::{Keypair, PublicKey};
5+
use libp2p::identity::{Keypair, PeerId, PublicKey};
66
use libp2p::kad::store::MemoryStore;
7-
use libp2p::{autonat, dcutr, gossipsub, identify, kad, relay, swarm::NetworkBehaviour, PeerId};
7+
use libp2p::{autonat, dcutr, gossipsub, identify, kad, relay, swarm::NetworkBehaviour};
88

9-
use super::{P2P_KADEMLIA_PROTOCOL, P2P_PROTOCOL_STRING};
9+
use crate::versioning::{P2P_KADEMLIA_PROTOCOL, P2P_PROTOCOL_STRING};
1010

1111
#[derive(NetworkBehaviour)]
1212
pub struct DriaBehaviour {
@@ -119,9 +119,8 @@ fn create_gossipsub_behavior(author: PeerId) -> gossipsub::Behaviour {
119119
/// This helps to avoid memory exhaustion during high load
120120
const MAX_SEND_QUEUE_SIZE: usize = 400;
121121

122-
// message id's are simply hashes of the message data
122+
// message id's are simply hashes of the message data, via SipHash13
123123
let message_id_fn = |message: &Message| {
124-
// uses siphash by default
125124
let mut hasher = hash_map::DefaultHasher::new();
126125
message.data.hash(&mut hasher);
127126
let digest = hasher.finish();

p2p/src/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use libp2p::{Multiaddr, PeerId, Swarm, SwarmBuilder};
1212
use libp2p_identity::Keypair;
1313
use std::time::Duration;
1414
use std::time::Instant;
15+
use versioning::{P2P_KADEMLIA_PREFIX, P2P_KADEMLIA_PROTOCOL, P2P_PROTOCOL_STRING};
1516

1617
/// P2P client, exposes a simple interface to handle P2P communication.
1718
pub struct DriaP2P {

p2p/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
mod transform;
2+
mod versioning;
3+
14
mod behaviour;
25
pub use behaviour::{DriaBehaviour, DriaBehaviourEvent};
36

47
mod client;
58
pub use client::DriaP2P;
69

7-
mod versioning;
8-
pub use versioning::*;
9-
10-
mod transform;
11-
1210
// re-exports
1311
pub use libp2p;
1412
pub use libp2p_identity;

workflows/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ authors = ["Erhan Tezcan <[email protected]>"]
1010
[dependencies]
1111
tokio-util.workspace = true
1212
tokio.workspace = true
13-
parking_lot.workspace = true
1413
serde.workspace = true
1514
serde_json.workspace = true
1615
async-trait.workspace = true

workflows/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,27 @@ This crate handles the configurations of models to be used, and implements vario
66
- **OpenAI**: We check that the chosen models are enabled for the user's profile by fetching their models with their API key. We filter out the disabled models.
77
- **Ollama**: We provide a sample workflow to measure TPS and then pick models that are above some TPS threshold. While calculating TPS, there is also a timeout so that beyond that timeout the TPS is not even considered and the model becomes invalid.
88

9-
## Environment Variables
9+
## Installation
10+
11+
TODO: !!!
12+
13+
## Usage
1014

1115
DKN Workflows make use of several environment variables, respecting the providers.
1216

1317
- `OPENAI_API_KEY` is used for OpenAI requests
1418
- `OLLAMA_HOST` is used to connect to Ollama server
1519
- `OLLAMA_PORT` is used to connect to Ollama server
1620
- `OLLAMA_AUTO_PULL` indicates whether we should pull missing models automatically or not
21+
- `SERPER_API_KEY` is optional API key to use **Serper**, for better Workflow executions
22+
- `JINA_API_KEY` is optional API key to use **Jina**, for better Workflow executions
23+
24+
With the environment variables ready, you can simply create a new configuration and call `check_services` to ensure all models are correctly setup:
25+
26+
```rs
27+
use dkn_workflows::{DriaWorkflowsConfig, Model};
1728

18-
SERPER_API_KEY=
19-
JINA_API_KEY=
29+
let models = vec![Model::Phi3_5Mini];
30+
let mut config = DriaWorkflowsConfig::new(models);
31+
config.check_services().await?;
32+
```

workflows/tests/models_test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use dkn_workflows::{DriaWorkflowsConfig, ModelProvider};
1+
use dkn_workflows::{DriaWorkflowsConfig, Model, ModelProvider};
22
use eyre::Result;
3-
use ollama_workflows::Model;
43
use std::env;
54

65
const LOG_LEVEL: &str = "none,dkn_workflows=debug";

0 commit comments

Comments
 (0)