From e8875fe19d0c60d184f78928b9e6572bcb06c4af Mon Sep 17 00:00:00 2001 From: Mikkel Denker Date: Thu, 29 Aug 2024 13:31:03 +0200 Subject: [PATCH] wait for webgraph to come online when instantiating remote webgraph conn --- crates/core/src/webgraph/remote.rs | 17 +++++++++++++++++ ltr/linear_model.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/core/src/webgraph/remote.rs b/crates/core/src/webgraph/remote.rs index ecc7b2eb..5d691563 100644 --- a/crates/core/src/webgraph/remote.rs +++ b/crates/core/src/webgraph/remote.rs @@ -98,6 +98,23 @@ impl RemoteWebgraph { pub async fn new(cluster: Arc, granularity: WebgraphGranularity) -> Self { let manager = WebgraphClientManager { granularity }; + tracing::info!("waiting for {granularity} webgraph to come online..."); + + cluster + .await_member(|member| { + if let Service::Webgraph { + host: _, + shard: _, + granularity: remote_granularity, + } = member.service + { + granularity == remote_granularity + } else { + false + } + }) + .await; + Self { client: Arc::new(Mutex::new( sonic::replication::ReusableShardedClient::new(cluster, manager).await, diff --git a/ltr/linear_model.py b/ltr/linear_model.py index 798d35e9..794dec68 100644 --- a/ltr/linear_model.py +++ b/ltr/linear_model.py @@ -91,7 +91,7 @@ def eval_query(query, expected_urls, weights): if len(weights) != 0: coeffs = {id2feature[i]: w for i, w in enumerate(weights)} - coeffs["lambda_mart"] = 10.0 + coeffs["lambda_mart"] = 1000.0 res = stract.search(query, signal_coefficients=coeffs) return sum([1 for r in res if r["url"] in expected_urls])