-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: new model_reuse_type to enable sync by peers and creation by leader #170
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -154,8 +154,15 @@ impl CeramicModelInstanceTestUser { | |||||
debug!(params=?config.params, "setting up scenario"); | ||||||
let (small_model_id, large_model_id) = match config.params.model_reuse { | ||||||
super::ReuseType::PerUser => { | ||||||
Self::generate_list_models(user, &config.admin_cli, &config.redis_cli, true, None) | ||||||
.await? | ||||||
Self::generate_list_models( | ||||||
user, | ||||||
&config.admin_cli, | ||||||
&config.redis_cli, | ||||||
true, | ||||||
None, | ||||||
false, | ||||||
) | ||||||
.await? | ||||||
} | ||||||
super::ReuseType::Shared => { | ||||||
let (small, large) = Self::generate_list_models( | ||||||
|
@@ -164,6 +171,7 @@ impl CeramicModelInstanceTestUser { | |||||
&config.redis_cli, | ||||||
global_leader, | ||||||
None, | ||||||
false, | ||||||
) | ||||||
.await?; | ||||||
// js ceramic subscribes to the meta model, so we'll get all models created synced to us. we just need to make sure they sync before starting | ||||||
|
@@ -180,9 +188,24 @@ impl CeramicModelInstanceTestUser { | |||||
&config.redis_cli, | ||||||
lead_user, | ||||||
Some(goose::get_worker_id().to_string()), | ||||||
false, | ||||||
) | ||||||
.await? | ||||||
} | ||||||
crate::scenario::ceramic::ReuseType::LeadWorkerSubscriber => { | ||||||
let (small, large) = Self::generate_list_models( | ||||||
user, | ||||||
&config.admin_cli, | ||||||
&config.redis_cli, | ||||||
global_leader, | ||||||
None, | ||||||
true, | ||||||
) | ||||||
.await?; | ||||||
Self::ensure_model_exists(user, &config.user_cli, &small).await?; | ||||||
Self::ensure_model_exists(user, &config.user_cli, &large).await?; | ||||||
(small, large) | ||||||
} | ||||||
}; | ||||||
|
||||||
if lead_user { | ||||||
|
@@ -251,6 +274,20 @@ impl CeramicModelInstanceTestUser { | |||||
) | ||||||
.await? | ||||||
} | ||||||
super::ReuseType::LeadWorkerSubscriber => { | ||||||
// For model instance reuse type make it work the same way as shared | ||||||
Self::generate_mids( | ||||||
user, | ||||||
&config.user_cli, | ||||||
&config.redis_cli, | ||||||
&small_model_id, | ||||||
&large_model_id, | ||||||
config.params.number_of_documents, | ||||||
global_leader, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically, we need the |
||||||
None, | ||||||
) | ||||||
.await? | ||||||
} | ||||||
}; | ||||||
|
||||||
let resp = Self { | ||||||
|
@@ -293,6 +330,7 @@ impl CeramicModelInstanceTestUser { | |||||
redis_cli: &redis::Client, | ||||||
should_create: bool, | ||||||
redis_postfix: Option<String>, | ||||||
should_subscribe: bool, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might not be necessary - see my comment above. One user on each worker is already making sure that the corresponding node is subscribed to the models. |
||||||
) -> Result<(StreamId, StreamId), TransactionError> { | ||||||
let mut conn = redis_cli.get_async_connection().await.unwrap(); | ||||||
let (small_key, large_key) = if let Some(pf) = redis_postfix { | ||||||
|
@@ -332,6 +370,10 @@ impl CeramicModelInstanceTestUser { | |||||
info!("waiting for shared model IDs to be set in redis"); | ||||||
let small = loop_until_key_value_set(&mut conn, &small_key).await; | ||||||
let large = loop_until_key_value_set(&mut conn, &large_key).await; | ||||||
if should_subscribe { | ||||||
Self::subscribe_to_model(user, &small).await?; | ||||||
Self::subscribe_to_model(user, &large).await?; | ||||||
} | ||||||
Ok((small, large)) | ||||||
} | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of this
if
-block, one user per worker will call the model subscription API, which means each node will already be subscribed to the models. This means that we shouldn't need to pass theshould_subscribe
flag as you're doing below.