From 5787aff024e6f0a1693f02e375d383c61415bc2f Mon Sep 17 00:00:00 2001 From: SdgJlbl Date: Fri, 16 Feb 2024 11:10:28 +0100 Subject: [PATCH] fix: image build test Signed-off-by: SdgJlbl --- tests/test_docker_image_build.py | 8 +++++--- tests/test_execution.py | 7 +++---- tests/test_execution_compute_plan.py | 3 +-- tests/test_permissions.py | 10 ++++------ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/test_docker_image_build.py b/tests/test_docker_image_build.py index a8d4f22c..06830e42 100644 --- a/tests/test_docker_image_build.py +++ b/tests/test_docker_image_build.py @@ -40,12 +40,14 @@ def test_base_substra_tools_image(factory, cfg, client, default_dataset, worker) def test_function_build_when_submitted(factory, cfg, client, worker): substra_tools_image = cfg.substra_tools.image_local function_category = FunctionCategory.simple - dockerfile = get_dockerfile(substra_tools_image, function_category, extra_instructions="ENV test=0\nsleep 1") + dockerfile = get_dockerfile(substra_tools_image, function_category, extra_instructions="ENV test=0\nRUN sleep 1") spec = factory.create_function(function_category, dockerfile=dockerfile) function = client.add_function(spec) - function = client._backend._client.get("function", function.key) - assert function["status"] == "FUNCTION_STATUS_READY" + client.wait_function(function.key, raise_on_failure=True) + + function = client.get_function(function.key) + assert function.status == "FUNCTION_STATUS_READY" @pytest.mark.remote_only diff --git a/tests/test_execution.py b/tests/test_execution.py index 47012e19..01701504 100644 --- a/tests/test_execution.py +++ b/tests/test_execution.py @@ -148,7 +148,6 @@ def test_tasks_execution_on_different_organizations( default_metric_1, default_dataset_1, default_dataset_2, - channel, workers, ): """Execution of a traintask on organization 1 and the following testtask on organization 2.""" @@ -159,8 +158,8 @@ def test_tasks_execution_on_different_organizations( predict_function_spec = factory.create_function(FunctionCategory.predict) predict_function_2 = client_2.add_function(predict_function_spec) - channel.wait_for_asset_synchronized(function_2) - channel.wait_for_asset_synchronized(predict_function_2) + client_2.wait_function(function_2.key) + client_2.wait_function(predict_function_2.key) # add traintask on organization 2; should execute on organization 2 (dataset located on organization 2) spec = factory.create_traintask( @@ -256,7 +255,7 @@ def test_function_build_failure_different_backend(factory, network, default_data traintask = network.clients[0].add_task(spec) traintask = network.clients[0].wait_task(traintask.key, raise_on_failure=False) - assert traintask.status == Status.failed + assert traintask.status == ComputeTaskStatus.failed assert traintask.error_type == substra.sdk.models.TaskErrorType.build with pytest.raises(TaskAssetNotFoundError): network.clients[0].get_task_output_asset(traintask.key, OutputIdentifiers.shared) diff --git a/tests/test_execution_compute_plan.py b/tests/test_execution_compute_plan.py index 33048cd8..09d228b3 100644 --- a/tests/test_execution_compute_plan.py +++ b/tests/test_execution_compute_plan.py @@ -21,7 +21,6 @@ def test_compute_plan_simple( default_dataset_1, default_dataset_2, default_metrics, - channel, workers, ): """Execution of a compute plan containing multiple traintasks: @@ -40,7 +39,7 @@ def test_compute_plan_simple( predict_function_spec = factory.create_function(FunctionCategory.predict) predict_function_2 = client_2.add_function(predict_function_spec) - channel.wait_for_asset_synchronized(simple_function_2) + client_2.wait_function(simple_function_2.key) # create compute plan cp_spec = factory.create_compute_plan( diff --git a/tests/test_permissions.py b/tests/test_permissions.py index aa593774..5b0c55f2 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -168,7 +168,7 @@ def test_permissions(permissions_1, permissions_2, expected_permissions, factory outputs=FLTaskOutputGenerator.traintask(authorized_ids=expected_permissions.authorized_ids), worker=workers[0], ) - channel.wait_for_asset_synchronized(function_2) + traintask = client_1.add_task(spec) client_1.wait_task(traintask.key, raise_on_failure=True) @@ -206,7 +206,7 @@ def test_permissions_denied_process(factory, client_1, client_2, channel, worker category=FunctionCategory.simple, permissions=Permissions(public=False, authorized_ids=[]) ) function_2 = client_2.add_function(spec) - channel.wait_for_asset_synchronized(function_2) + client_2.wait_function(function_2.key) # traintasks @@ -254,7 +254,7 @@ def test_permissions_model_process( # function spec = factory.create_function(category=FunctionCategory.simple, permissions=permissions) function = client.add_function(spec) - channel.wait_for_asset_synchronized(function) + client.wait_function(function.key) functions.append(function) dataset_1, dataset_2 = datasets @@ -327,8 +327,7 @@ def test_merge_permissions_denied_process(factory, clients, channel, workers): data_sample_key_1 = client_1.add_data_sample(spec) spec = factory.create_function(category=FunctionCategory.metric, permissions=permissions_1) - metric_1 = client_1.add_function(spec) - channel.wait_for_asset_synchronized(metric_1) # used by client_3 + client_1.add_function(spec) # add function on organization 2 spec = factory.create_function(category=FunctionCategory.simple, permissions=permissions_2) @@ -384,7 +383,6 @@ def test_permissions_denied_head_model_process(factory, client_1, client_2, chan # create function spec = factory.create_function(category=FunctionCategory.composite) composite_function = client_1.add_function(spec) - channel.wait_for_asset_synchronized(composite_function) # used by client_2 # create composite task spec = factory.create_composite_traintask(