|
30 | 30 | from mock import patch, Mock, MagicMock |
31 | 31 |
|
32 | 32 | import sagemaker |
33 | | -from sagemaker.local.image import _SageMakerContainer, _aws_credentials |
| 33 | +from sagemaker.local.image import _SageMakerContainer, _Volume, _aws_credentials |
34 | 34 |
|
35 | 35 | REGION = "us-west-2" |
36 | 36 | BUCKET_NAME = "mybucket" |
@@ -513,6 +513,7 @@ def test_train_local_code(get_data_source_instance, tmpdir, sagemaker_session): |
513 | 513 | assert config["services"][h]["image"] == image |
514 | 514 | assert config["services"][h]["command"] == "train" |
515 | 515 | volumes = config["services"][h]["volumes"] |
| 516 | + volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] |
516 | 517 | assert "%s:/opt/ml/code" % "/tmp/code" in volumes |
517 | 518 | assert "%s:/opt/ml/shared" % shared_folder_path in volumes |
518 | 519 |
|
@@ -564,9 +565,26 @@ def test_train_local_intermediate_output(get_data_source_instance, tmpdir, sagem |
564 | 565 | assert config["services"][h]["image"] == image |
565 | 566 | assert config["services"][h]["command"] == "train" |
566 | 567 | volumes = config["services"][h]["volumes"] |
| 568 | + volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] |
567 | 569 | assert "%s:/opt/ml/output/intermediate" % intermediate_folder_path in volumes |
568 | 570 |
|
569 | 571 |
|
| 572 | +@patch("platform.system", Mock(return_value="Linux")) |
| 573 | +@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True)) |
| 574 | +def test_container_selinux_has_label(tmpdir): |
| 575 | + volume = _Volume(str(tmpdir), "/opt/ml/model") |
| 576 | + |
| 577 | + assert volume.map.endswith(":z") |
| 578 | + |
| 579 | + |
| 580 | +@patch("platform.system", Mock(return_value="Darwin")) |
| 581 | +@patch("sagemaker.local.image.SELINUX_ENABLED", Mock(return_value=True)) |
| 582 | +def test_container_has_selinux_no_label(tmpdir): |
| 583 | + volume = _Volume(str(tmpdir), "/opt/ml/model") |
| 584 | + |
| 585 | + assert not volume.map.endswith(":z") |
| 586 | + |
| 587 | + |
570 | 588 | def test_container_has_gpu_support(tmpdir, sagemaker_session): |
571 | 589 | instance_count = 1 |
572 | 590 | image = "my-image" |
@@ -650,6 +668,7 @@ def test_serve_local_code(tmpdir, sagemaker_session): |
650 | 668 | assert config["services"][h]["command"] == "serve" |
651 | 669 |
|
652 | 670 | volumes = config["services"][h]["volumes"] |
| 671 | + volumes = [v[:-2] if v.endswith(":z") else v for v in volumes] |
653 | 672 | assert "%s:/opt/ml/code" % "/tmp/code" in volumes |
654 | 673 | assert ( |
655 | 674 | "SAGEMAKER_SUBMIT_DIRECTORY=/opt/ml/code" |
|
0 commit comments