From 3d029f686dec85b950cd2d6f7b59f74dc7c6c9c8 Mon Sep 17 00:00:00 2001 From: Iaroslav Igoshev Date: Mon, 27 May 2024 22:34:27 +0200 Subject: [PATCH] REFACTOR-#000: Format code to be in line with latest black (#415) Signed-off-by: Igoshev, Iaroslav --- .../mpi/core/monitor/shared_memory_manager.py | 14 ++++++---- .../backends/mpi/core/shared_object_store.py | 28 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/unidist/core/backends/mpi/core/monitor/shared_memory_manager.py b/unidist/core/backends/mpi/core/monitor/shared_memory_manager.py index 12afad6f..17d0063a 100644 --- a/unidist/core/backends/mpi/core/monitor/shared_memory_manager.py +++ b/unidist/core/backends/mpi/core/monitor/shared_memory_manager.py @@ -208,13 +208,15 @@ def clear(self, data_id_list): has_refs = array( "B", [ - 1 - if data_id in self._reservation_info - and self.shared_store.get_ref_number( - data_id, self._reservation_info[data_id]["service_index"] + ( + 1 + if data_id in self._reservation_info + and self.shared_store.get_ref_number( + data_id, self._reservation_info[data_id]["service_index"] + ) + > 0 + else 0 ) - > 0 - else 0 for data_id in cleanup_list ], ) diff --git a/unidist/core/backends/mpi/core/shared_object_store.py b/unidist/core/backends/mpi/core/shared_object_store.py index 85050081..2b34057e 100644 --- a/unidist/core/backends/mpi/core/shared_object_store.py +++ b/unidist/core/backends/mpi/core/shared_object_store.py @@ -230,9 +230,11 @@ def _allocate_shared_memory(self): info = MPI.Info.Create() info.Set("alloc_shared_noncontig", "true") self.win = MPI.Win.Allocate_shared( - self.shared_memory_size * MPI.BYTE.size - if mpi_state.is_monitor_process() - else 0, + ( + self.shared_memory_size * MPI.BYTE.size + if mpi_state.is_monitor_process() + else 0 + ), MPI.BYTE.size, comm=mpi_state.host_comm, info=info, @@ -245,9 +247,11 @@ def _allocate_shared_memory(self): * self.INFO_SIZE ) self.service_win = MPI.Win.Allocate_shared( - self.service_info_max_count * MPI.LONG.size - if mpi_state.is_monitor_process() - else 0, + ( + self.service_info_max_count * MPI.LONG.size + if mpi_state.is_monitor_process() + else 0 + ), MPI.LONG.size, comm=mpi_state.host_comm, info=info, @@ -363,13 +367,13 @@ def _put_service_info(self, service_index, data_id, first_index): worker_id, data_number = self._parse_data_id(data_id) with WinLock(self.service_win): - self.service_shared_buffer[ - service_index + self.FIRST_DATA_INDEX - ] = first_index + self.service_shared_buffer[service_index + self.FIRST_DATA_INDEX] = ( + first_index + ) self.service_shared_buffer[service_index + self.REFERENCES_NUMBER] = 1 - self.service_shared_buffer[ - service_index + self.DATA_NUMBER_INDEX - ] = data_number + self.service_shared_buffer[service_index + self.DATA_NUMBER_INDEX] = ( + data_number + ) self.service_shared_buffer[service_index + self.WORKER_ID_INDEX] = worker_id self.finalizers.append(