From b2a09a2f9ecd6d8dc064bec4eb4d4ca4b11846ae Mon Sep 17 00:00:00 2001 From: LuLu Zuo Date: Wed, 6 Dec 2023 21:21:28 +0800 Subject: [PATCH] Optimization log --- .../executor/_line_execution_process_pool.py | 16 +++++++++------- .../test_line_execution_process_pool.py | 19 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/promptflow/promptflow/executor/_line_execution_process_pool.py b/src/promptflow/promptflow/executor/_line_execution_process_pool.py index 3be9c8e24212..0d6405a91b5a 100644 --- a/src/promptflow/promptflow/executor/_line_execution_process_pool.py +++ b/src/promptflow/promptflow/executor/_line_execution_process_pool.py @@ -589,14 +589,16 @@ def get_available_max_worker_count(): # 2. When the degree of parallelism is 1, main process executes the task directly and not # create the child process bulk_logger.warning( - f"Available max worker count {estimated_available_worker_count} is less than 1, set it to 1.") + f"Current system's available memory is {available_memory}MB, less than the memory " + f"{process_memory}MB required by the process. The maximum available worker count is 1.") estimated_available_worker_count = 1 - bulk_logger.info( - f"Current system's available memory is {available_memory}MB, " - f"memory consumption of current process is {process_memory}MB, " - f"estimated available worker count is {available_memory}/{process_memory} " - f"= {estimated_available_worker_count}" - ) + else: + bulk_logger.info( + f"Current system's available memory is {available_memory}MB, " + f"memory consumption of current process is {process_memory}MB, " + f"estimated available worker count is {available_memory}/{process_memory} " + f"= {estimated_available_worker_count}" + ) return estimated_available_worker_count diff --git a/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py b/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py index 3230b32e7dfa..37626d02514d 100644 --- a/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py +++ b/src/promptflow/tests/executor/unittests/processpool/test_line_execution_process_pool.py @@ -436,7 +436,7 @@ class TestGetAvailableMaxWorkerCount: "available_memory, process_memory, expected_max_worker_count, actual_calculate_worker_count", [ (128.0, 64.0, 2, 2), # available_memory/process_memory > 1 - (63.0, 64.0, 1, 1), # available_memory/process_memory < 1 + (63.0, 64.0, 1, 0), # available_memory/process_memory < 1 ], ) def test_get_available_max_worker_count( @@ -452,12 +452,13 @@ def test_get_available_max_worker_count( assert estimated_available_worker_count == expected_max_worker_count if actual_calculate_worker_count < 1: mock_logger.warning.assert_called_with( - f"Available max worker count {actual_calculate_worker_count} is less than 1, " - "set it to 1." + f"Current system's available memory is {available_memory}MB, less than the memory " + f"{process_memory}MB required by the process. The maximum available worker count is 1." + ) + else: + mock_logger.info.assert_called_with( + f"Current system's available memory is {available_memory}MB, " + f"memory consumption of current process is {process_memory}MB, " + f"estimated available worker count is {available_memory}/{process_memory} " + f"= {actual_calculate_worker_count}" ) - mock_logger.info.assert_called_with( - f"Current system's available memory is {available_memory}MB, " - f"memory consumption of current process is {process_memory}MB, " - f"estimated available worker count is {available_memory}/{process_memory} " - f"= {actual_calculate_worker_count}" - )