Skip to content

Commit 87f53f0

Browse files
committed
style: fixed naming of model handler
Signed-off-by: Tobias Anker <tobias.anker@kitsunemimi.moe>
1 parent 1d26ecb commit 87f53f0

12 files changed

Lines changed: 34 additions & 42 deletions

File tree

src/binaries/sakura/src/api/http_endpoints/model/create_model_internal_v1_0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use apistos::api_operation;
1818
use uuid::Uuid;
1919
use validator::Validate;
2020

21-
use crate::core::model_handler::CLUSTER_HANDLER;
21+
use crate::core::model_handler::MODEL_HANDLER;
2222
use crate::database::model_table;
2323

2424
use ainari_api::common_functions::*;
@@ -56,7 +56,7 @@ pub async fn create_model_internal(
5656
parsed_model.uuid = model_uuid;
5757

5858
// parse model-template and create model from it
59-
let mut model_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
59+
let mut model_handler = MODEL_HANDLER.write().expect("mutex poisoned");
6060
model_handler
6161
.init_new_model(&model_uuid, &parsed_model)
6262
.map_err(map_ainari_error_to_api_response)?;

src/binaries/sakura/src/api/http_endpoints/model/delete_model_internal_v1_0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub async fn delete_model_internal(
6363
}
6464

6565
// prepare delete of model from core
66-
let model_handle = model_handler::CLUSTER_HANDLER
66+
let model_handle = model_handler::MODEL_HANDLER
6767
.write()
6868
.expect("mutex poisoned");
6969
let model_interface = model_handle
@@ -76,7 +76,7 @@ pub async fn delete_model_internal(
7676
interface.stop();
7777

7878
// delete model from core
79-
let mut model_handle = model_handler::CLUSTER_HANDLER
79+
let mut model_handle = model_handler::MODEL_HANDLER
8080
.write()
8181
.expect("mutex poisoned");
8282
model_handle

src/binaries/sakura/src/api/http_endpoints/model/request_model_v1_0.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ pub async fn request_model(
5050
.map_err(|e| map_db_uuid_get_delete_error("model", &model_uuid, e))?;
5151

5252
// get model-interface
53-
let model_handler = model_handler::CLUSTER_HANDLER
54-
.read()
55-
.expect("mutex poisoned");
53+
let model_handler = model_handler::MODEL_HANDLER.read().expect("mutex poisoned");
5654
let model_interface_mutex = model_handler
5755
.get_model_interface(&model_uuid)
5856
.map_err(map_ainari_error_to_api_response)?;

src/binaries/sakura/src/api/http_endpoints/model/task/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ use ainari_dataset::file_encryption::decrypt_file;
5757
/// * `Result<usize, ErrorResponse>` - The number of open tasks or an error
5858
fn get_current_number_of_open_tasks(model_uuid: &Uuid) -> Result<usize, ErrorResponse> {
5959
// get model-handle
60-
let model_handler = model_handler::CLUSTER_HANDLER
61-
.read()
62-
.expect("mutex poisoned");
60+
let model_handler = model_handler::MODEL_HANDLER.read().expect("mutex poisoned");
6361
let model_handle = match model_handler.models.get(model_uuid) {
6462
Some(model_handle) => model_handle,
6563
None => return Err(ErrorResponse::InternalError("".to_string())),
@@ -165,9 +163,7 @@ fn add_task_to_model(
165163
task_type: &TaskType,
166164
context: &UserContext,
167165
) -> Result<(), ErrorResponse> {
168-
let model_handler = model_handler::CLUSTER_HANDLER
169-
.read()
170-
.expect("mutex poisoned");
166+
let model_handler = model_handler::MODEL_HANDLER.read().expect("mutex poisoned");
171167
let model_handle = match model_handler.models.get(&task.model_uuid) {
172168
Some(model_handle) => model_handle,
173169
None => return Err(ErrorResponse::InternalError("".to_string())),
@@ -224,7 +220,7 @@ fn handle_output(
224220
model_uuid: &Uuid,
225221
total_output_size: u64,
226222
) -> Result<(Column, u64), ErrorResponse> {
227-
let model_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
223+
let model_handler = MODEL_HANDLER.read().expect("mutex poisoned");
228224

229225
let size = {
230226
let output_buffer_mutex = model_handler

src/binaries/sakura/src/api/http_endpoints/model/train_model_v1_0.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ pub async fn train_model(
5050
.map_err(|e| map_db_uuid_get_delete_error("model", &model_uuid, e))?;
5151

5252
// get model-interface
53-
let model_handler = model_handler::CLUSTER_HANDLER
54-
.read()
55-
.expect("mutex poisoned");
53+
let model_handler = model_handler::MODEL_HANDLER.read().expect("mutex poisoned");
5654
let model_interface_mutex = model_handler
5755
.get_model_interface(&model_uuid)
5856
.map_err(map_ainari_error_to_api_response)?;

src/binaries/sakura/src/core/blocks/block_io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn connect_outputs(
7070
// in case of training, get targets for all not-connected axon-sections
7171
for (i, axon_section) in io_buffer.output_buffer.iter_mut().enumerate() {
7272
if axon_section.target_pos == UNINIT_STATE_8 {
73-
// let mut model_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
73+
// let mut model_handler = MODEL_HANDLER.write().expect("mutex poisoned");
7474

7575
// set source-values for the axon-section
7676
axon_section.model_uuid = *model_uuid;
@@ -82,7 +82,7 @@ pub fn connect_outputs(
8282
connect_to_new_target(axon_section)?;
8383
} else if axon_section.source_block.is_none() || axon_section.target_block.is_none() {
8484
// Get model handler to fetch block references
85-
let model_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
85+
let model_handler = MODEL_HANDLER.read().expect("mutex poisoned");
8686
axon_section.model_uuid = *model_uuid;
8787
axon_section.source_block = Some(model_handler.get_block(
8888
model_uuid,

src/binaries/sakura/src/core/blocks/output_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl OutputBlock {
137137
fn connect_output_buffer(&mut self) -> Result<(), AinariError> {
138138
// connect output-buffer if not already done
139139
if self.output_buffer.is_none() {
140-
let root_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
140+
let root_handler = MODEL_HANDLER.read().expect("mutex poisoned");
141141
let output_buffer_mutex =
142142
root_handler.get_output_buffer(&self.model_uuid, &self.output_buffer_name)?;
143143

src/binaries/sakura/src/core/blocks/target_search.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn connect_to_new_target(axon_section: &mut AxonSection) -> Result<(), Ainar
6464
let selected_block_option;
6565

6666
{
67-
let model_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
67+
let model_handler = MODEL_HANDLER.read().expect("mutex poisoned");
6868

6969
// get source-block
7070
source_block = model_handler.get_block(
@@ -109,7 +109,7 @@ pub fn connect_to_new_target(axon_section: &mut AxonSection) -> Result<(), Ainar
109109

110110
// create new block if no existing block is available
111111
if target_information.is_output {
112-
let mut model_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
112+
let mut model_handler = MODEL_HANDLER.write().expect("mutex poisoned");
113113
let output_block_mutex = Arc::new(Mutex::new(OutputBlock::new(
114114
&target_information.hexagon_uuid,
115115
&axon_section.model_uuid,
@@ -124,7 +124,7 @@ pub fn connect_to_new_target(axon_section: &mut AxonSection) -> Result<(), Ainar
124124
return Ok(());
125125
}
126126
} else {
127-
let mut model_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
127+
let mut model_handler = MODEL_HANDLER.write().expect("mutex poisoned");
128128
let core_block_mutex = Arc::new(Mutex::new(CoreBlock::new(
129129
&target_information.hexagon_uuid,
130130
&axon_section.model_uuid,
@@ -210,7 +210,7 @@ fn check_axon_setion(axon_section: &mut AxonSection) -> Result<(), AinariError>
210210
/// * `Ok(TargetInformation)` containing information about the target hexagon
211211
/// * `Err(AinariError)` if any step fails
212212
fn get_target_hexagon(axon_section: &mut AxonSection) -> Result<TargetInformation, AinariError> {
213-
let mut model_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
213+
let mut model_handler = MODEL_HANDLER.write().expect("mutex poisoned");
214214
let mut target_information = TargetInformation::default();
215215
let model_link = model_handler.get_model_mut(&axon_section.model_uuid)?;
216216

@@ -301,7 +301,7 @@ mod tests {
301301
key2: 2,2,2;"
302302
.to_string();
303303

304-
let mut root_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
304+
let mut root_handler = MODEL_HANDLER.write().expect("mutex poisoned");
305305
root_handler.models.clear();
306306
let mut parsed_model = parse_model_template(&model_name, &template).unwrap();
307307
parsed_model.uuid = model_uuid;

src/binaries/sakura/src/core/model_handler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ lazy_static::lazy_static! {
3737
/// Global singleton for model data handling.
3838
///
3939
/// This provides thread-safe access to all models and their components.
40-
pub static ref CLUSTER_HANDLER: RwLock<ModelDataHandler> = RwLock::new(init_model_data_handler());
40+
pub static ref MODEL_HANDLER: RwLock<ModelDataHandler> = RwLock::new(init_model_data_handler());
4141
}
4242

4343
// ==================================================================================================
@@ -1022,7 +1022,7 @@ mod tests {
10221022
key2: 2,2,2;"
10231023
.to_string();
10241024

1025-
let mut root_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
1025+
let mut root_handler = MODEL_HANDLER.write().expect("mutex poisoned");
10261026
root_handler.models.clear();
10271027

10281028
{
@@ -1072,7 +1072,7 @@ mod tests {
10721072
test_output: 2,2,2;"
10731073
.to_string();
10741074

1075-
let mut root_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
1075+
let mut root_handler = MODEL_HANDLER.write().expect("mutex poisoned");
10761076
root_handler.models.clear();
10771077
let mut parsed_model = parse_model_template(&model_name, &template).unwrap();
10781078
parsed_model.uuid = model_uuid;
@@ -1228,7 +1228,7 @@ mod tests {
12281228
test_output: 2,2,2;"
12291229
.to_string();
12301230

1231-
let mut root_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
1231+
let mut root_handler = MODEL_HANDLER.write().expect("mutex poisoned");
12321232
root_handler.models.clear();
12331233
let mut parsed_model = parse_model_template(&model_name, &template).unwrap();
12341234
parsed_model.uuid = model_uuid;

src/binaries/sakura/src/core/model_interface.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl ModelInterface {
196196

197197
// reset output-values in the backend
198198
{
199-
let model_data_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
199+
let model_data_handler = MODEL_HANDLER.read().expect("mutex poisoned");
200200
for hexagon_name in outputs.keys() {
201201
let output_buffer_mutex =
202202
model_data_handler.get_output_buffer(&self.model_uuid, hexagon_name)?;
@@ -220,7 +220,7 @@ impl ModelInterface {
220220
run_iteration(&self.model_uuid, &self.finish_counter_mutex)?;
221221

222222
// get output-values from the backend
223-
let model_data_handler = CLUSTER_HANDLER.read().expect("mutex poisoned");
223+
let model_data_handler = MODEL_HANDLER.read().expect("mutex poisoned");
224224
for (hexagon_name, data) in outputs.iter_mut() {
225225
let output_buffer_mutex =
226226
model_data_handler.get_output_buffer(&self.model_uuid, hexagon_name)?;
@@ -379,7 +379,7 @@ mod tests {
379379
// Initialize processing
380380
let worker_handler = WORKER_HANDLER.lock().expect("mutex poisoned");
381381
drop(worker_handler);
382-
let model_data_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
382+
let model_data_handler = MODEL_HANDLER.write().expect("mutex poisoned");
383383
drop(model_data_handler);
384384

385385
// create dummy-model
@@ -408,7 +408,7 @@ mod tests {
408408
test_output: 3,2,2;"
409409
.to_string();
410410

411-
let mut root_handler = CLUSTER_HANDLER.write().expect("mutex poisoned");
411+
let mut root_handler = MODEL_HANDLER.write().expect("mutex poisoned");
412412
root_handler.models.clear();
413413
let mut parsed_model = parse_model_template(&model_name, &template).unwrap();
414414
parsed_model.uuid = model_uuid;

0 commit comments

Comments
 (0)