|
1 | 1 | import io |
2 | 2 | import json |
| 3 | +import os |
3 | 4 | import resource |
4 | 5 | from unittest.mock import patch |
5 | 6 | from uuid import uuid4 |
@@ -192,7 +193,7 @@ def test_bad_command_inference_from_task_list(minio, monkeypatch): |
192 | 193 | f'{{"log": "Stopping due to failure of task {pk1}", "level": "ERROR", ' |
193 | 194 | '"source": "stderr", "internal": true, "task": null}' in result.output |
194 | 195 | ) |
195 | | - assert result.exit_code == 0 |
| 196 | + assert result.exit_code == 1 |
196 | 197 |
|
197 | 198 |
|
198 | 199 | def test_good_command_inference_from_s3_uri(minio, monkeypatch): |
@@ -317,7 +318,7 @@ def test_bad_command_inference_from_s3_uri(minio, monkeypatch): |
317 | 318 | f'{{"log": "Stopping due to failure of task {pk1}", "level": "ERROR", ' |
318 | 319 | '"source": "stderr", "internal": true, "task": null}' in result.output |
319 | 320 | ) |
320 | | - assert result.exit_code == 0 |
| 321 | + assert result.exit_code == 1 |
321 | 322 |
|
322 | 323 |
|
323 | 324 | def test_logging_setup(minio, monkeypatch): |
@@ -440,3 +441,50 @@ def test_memory_limit_defined(minio, monkeypatch): |
440 | 441 | '{"log": "Setting memory limit to 1337 MB", "level": "INFO", ' |
441 | 442 | '"source": "stdout", "internal": true, "task": null}' |
442 | 443 | ) in result.output |
| 444 | + |
| 445 | + |
| 446 | +def test_aux_data_failure(minio, monkeypatch, tmp_path): |
| 447 | + pk = str(uuid4()) |
| 448 | + prefix = f"tasks/{pk}" |
| 449 | + model_key = f"{prefix}/sub/dodgy.tar" |
| 450 | + model_destination = tmp_path / "model" |
| 451 | + tasks = [ |
| 452 | + { |
| 453 | + "pk": pk, |
| 454 | + "inputs": [], |
| 455 | + "output_bucket_name": minio.output_bucket_name, |
| 456 | + "output_prefix": prefix, |
| 457 | + "timeout": "PT10S", |
| 458 | + } |
| 459 | + ] |
| 460 | + |
| 461 | + monkeypatch.setenv( |
| 462 | + "GRAND_CHALLENGE_COMPONENT_CMD_B64J", |
| 463 | + encode_b64j(val=["echo", "hello"]), |
| 464 | + ) |
| 465 | + monkeypatch.setenv("GRAND_CHALLENGE_COMPONENT_SET_EXTRA_GROUPS", "False") |
| 466 | + monkeypatch.setenv("GRAND_CHALLENGE_COMPONENT_USE_LINKED_INPUT", "False") |
| 467 | + monkeypatch.setenv("GRAND_CHALLENGE_COMPONENT_WRITABLE_DIRECTORIES", "") |
| 468 | + monkeypatch.setenv( |
| 469 | + "GRAND_CHALLENGE_COMPONENT_MODEL", |
| 470 | + f"s3://{minio.input_bucket_name}/{model_key}", |
| 471 | + ) |
| 472 | + monkeypatch.setenv( |
| 473 | + "GRAND_CHALLENGE_COMPONENT_MODEL_DEST", str(model_destination) |
| 474 | + ) |
| 475 | + |
| 476 | + sync_s3_operation( |
| 477 | + method=s3_upload_fileobj, |
| 478 | + Fileobj=io.BytesIO(os.urandom(8)), |
| 479 | + Bucket=minio.input_bucket_name, |
| 480 | + Key=model_key, |
| 481 | + ) |
| 482 | + |
| 483 | + runner = CliRunner() |
| 484 | + result = runner.invoke(cli, ["invoke", "-t", json.dumps(tasks)]) |
| 485 | + |
| 486 | + assert result.exit_code == 1 |
| 487 | + assert result.stderr.splitlines()[-1] == ( |
| 488 | + '{"log": "Could not setup model: Tarfile could not be extracted", ' |
| 489 | + '"level": "ERROR", "source": "stderr", "internal": false, "task": null}' |
| 490 | + ) |
0 commit comments