Skip to content

Commit e5c7a65

Browse files
committed
points api fix, rm old test
1 parent 585c398 commit e5c7a65

File tree

6 files changed

+20
-43
lines changed

6 files changed

+20
-43
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ default-members = ["compute"]
77

88
[workspace.package]
99
edition = "2021"
10-
version = "0.5.3"
10+
version = "0.5.4"
1111
license = "Apache-2.0"
1212
readme = "README.md"
1313

compute/src/node/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl DriaComputeNode {
138138
"$DRIA Points".purple(),
139139
steps.score,
140140
steps.score - self.points_client.initial,
141-
steps.percentile.unwrap_or("100".to_string())
141+
steps.percentile
142142
);
143143
}
144144
Err(err) => {

compute/src/utils/points.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use eyre::Context;
22

3-
/// Points URL, use with an `address` query parameter.
4-
const POINTS_API_BASE_URL: &str =
5-
"https://mainnet.dkn.dria.co/dashboard/supply/v0/leaderboard/steps";
6-
// TODO: support testnet here?
3+
const POINTS_API_BASE_URL: &str = "https://mainnet.dkn.dria.co/points/v0/total/node/";
74

85
pub struct DriaPointsClient {
96
pub url: String,
@@ -12,13 +9,21 @@ pub struct DriaPointsClient {
129
pub initial: f64,
1310
}
1411

12+
#[derive(Debug, serde::Deserialize)]
13+
pub struct DriaPoints {
14+
/// Indicates in which top percentile your points are.
15+
pub percentile: usize,
16+
/// The total number of points you have accumulated.
17+
pub score: f64,
18+
}
19+
1520
impl DriaPointsClient {
1621
/// Creates a new `DriaPointsClient` for the given address.
1722
pub fn new(address: &str) -> eyre::Result<Self> {
1823
const USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
1924

2025
let url = format!(
21-
"{}?address=0x{}",
26+
"{}/0x{}",
2227
POINTS_API_BASE_URL,
2328
address.trim_start_matches("0x")
2429
);
@@ -55,26 +60,15 @@ impl DriaPointsClient {
5560
}
5661
}
5762

58-
#[derive(Debug, serde::Deserialize)]
59-
pub struct DriaPoints {
60-
/// Indicates in which top percentile your points are.
61-
///
62-
/// TODO: can be number in API
63-
/// TODO: API sometimes returns `null` here?
64-
pub percentile: Option<String>,
65-
/// The total number of points you have accumulated.
66-
pub score: f64,
67-
}
68-
6963
#[cfg(test)]
7064
mod tests {
7165
use super::*;
7266

7367
#[tokio::test]
74-
#[ignore = "waiting for API"]
7568
async fn test_get_points() {
7669
let client = DriaPointsClient::new("0xa43536a6032a3907ccf60e8109429ee1047b207c").unwrap();
7770
let steps = client.get_points().await.unwrap();
78-
assert!(steps.score != 0.0);
71+
assert!(steps.score >= 0.0);
72+
assert!(steps.percentile <= 100);
7973
}
8074
}

workflows-v2/src/config.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,4 @@ mod tests {
249249
"Should not find anything for inexisting model"
250250
);
251251
}
252-
253-
#[test]
254-
#[ignore = "TODO: fix this test"]
255-
fn test_get_any_matching_model() {
256-
let cfg = DriaWorkflowsConfig::new_from_csv("gpt-4o-mini,llama3.2:1b-instruct-q4_K_M");
257-
let result = cfg.get_any_matching_model(vec![
258-
"i-dont-exist".to_string(),
259-
"llama3.1:latest".to_string(),
260-
"gpt-4o".to_string(),
261-
"ollama".to_string(),
262-
]);
263-
assert_eq!(
264-
result.unwrap(),
265-
Model::Llama3_2_1bInstructQ4Km,
266-
"Should find existing model"
267-
);
268-
}
269252
}

workflows/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ mod tests {
279279

280280
#[test]
281281
fn test_get_any_matching_model() {
282-
let cfg = DriaWorkflowsConfig::new_from_csv("gpt-4o,llama3.1:8b-instruct-q4_K_M");
282+
let cfg = DriaWorkflowsConfig::new_from_csv("gpt-4o,aaabbbccc");
283283
let result = cfg.get_any_matching_model(vec![
284284
"i-dont-exist".to_string(),
285285
"gpt-4o".to_string(),

0 commit comments

Comments
 (0)