Skip to content

Commit

Permalink
fix: image build test
Browse files Browse the repository at this point in the history
Signed-off-by: SdgJlbl <[email protected]>
  • Loading branch information
SdgJlbl committed Feb 16, 2024
1 parent 19cbd64 commit 5787aff
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
8 changes: 5 additions & 3 deletions tests/test_docker_image_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions tests/test_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_execution_compute_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(
Expand Down
10 changes: 4 additions & 6 deletions tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5787aff

Please sign in to comment.