コード例 #1
0
ファイル: validate_test.py プロジェクト: debtaru/cloud
    def test_invalid_entry_point(self):
        with pytest.raises(ValueError, match=r"Invalid `entry_point`"):
            validate.validate(
                entry_point="/mnist_example_using_fit.py",
                distribution_strategy="auto",
                requirements_txt=None,
                chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_count=1,
                region="us-central1",
                args=None,
                stream_logs=True,
                docker_image_bucket_name=None,
                called_from_notebook=False,
            )

        with pytest.raises(ValueError, match=r"Invalid `entry_point`"):
            validate.validate(
                entry_point="/mnist_example_using_fit.txt",
                distribution_strategy="auto",
                requirements_txt=None,
                chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_count=1,
                region="us-central1",
                args=None,
                stream_logs=True,
                docker_image_bucket_name=None,
                called_from_notebook=False,
            )
コード例 #2
0
ファイル: validate_test.py プロジェクト: jonah-kohn/cloud
    def test_invalid_entry_point(self, mock_os_path):
        mock_os_path.isfile.return_value = False
        with self.assertRaisesRegex(ValueError, r"Invalid `entry_point`"):
            validate.validate(
                entry_point="/mnist_example_using_fit.py",
                distribution_strategy="auto",
                requirements_txt=None,
                chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_count=1,
                region="us-central1",
                args=None,
                stream_logs=True,
                docker_image_bucket_name=None,
                called_from_notebook=False,
            )

        with self.assertRaisesRegex(ValueError, r"Invalid `entry_point`"):
            validate.validate(
                entry_point="/mnist_example_using_fit.txt",
                distribution_strategy="auto",
                requirements_txt=None,
                chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
                worker_count=1,
                region="us-central1",
                args=None,
                stream_logs=True,
                docker_image_bucket_name=None,
                called_from_notebook=False,
            )
コード例 #3
0
 def test_valid_args_no_entry_point(self):
     validate.validate(
         entry_point=None,
         distribution_strategy=None,
         requirements_txt=self.requirements_file,
         chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
         worker_config=None,
         worker_count=0,
         entry_point_args=["1000"],
         stream_logs=False,
         docker_image_build_bucket="abc",
         called_from_notebook=True,
     )
コード例 #4
0
 def test_valid_args_chief_worker(self):
     validate.validate(
         entry_point=self.script_entry_point,
         distribution_strategy="auto",
         requirements_txt=self.requirements_file,
         chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
         worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
         worker_count=1,
         entry_point_args=None,
         stream_logs=True,
         docker_image_build_bucket=None,
         called_from_notebook=False,
     )
コード例 #5
0
 def test_invalid_tpu_worker_count(self):
     with self.assertRaisesRegex(ValueError, r"Invalid `worker_count`"):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["CPU"],
             worker_config=machine_config.COMMON_MACHINE_CONFIGS["TPU"],
             worker_count=2,
             entry_point_args=None,
             stream_logs=True,
             docker_image_build_bucket=None,
             called_from_notebook=False,
         )
コード例 #6
0
ファイル: validate_test.py プロジェクト: nobillygreen/cloud
 def test_valid_args_chief_only(self):
     validate.validate(
         entry_point=self.script_entry_point,
         distribution_strategy=None,
         requirements_txt=self.requirements_file,
         chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
         worker_config=None,
         worker_count=0,
         region="us-central1",
         entry_point_args=["1000"],
         stream_logs=False,
         docker_image_bucket_name=None,
         called_from_notebook=False,
     )
コード例 #7
0
ファイル: validate_test.py プロジェクト: jonah-kohn/cloud
 def test_invalid_tpu_chief_config(self, mock_os_path):
     with self.assertRaisesRegex(ValueError, r"Invalid `chief_config`"):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["TPU"],
             worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
             worker_count=1,
             region="us-central1",
             args=None,
             stream_logs=True,
             docker_image_bucket_name=None,
             called_from_notebook=False,
         )
コード例 #8
0
ファイル: validate_test.py プロジェクト: debtaru/cloud
 def test_invalid_region(self):
     with pytest.raises(ValueError, match=r"Invalid `region`"):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
             worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
             worker_count=1,
             region=["us-region-a"],
             args=None,
             stream_logs=True,
             docker_image_bucket_name=None,
             called_from_notebook=False,
         )
コード例 #9
0
ファイル: validate_test.py プロジェクト: nobillygreen/cloud
 def test_valid_args_no_entry_point_with_job_label(self):
     validate.validate(
         entry_point=None,
         distribution_strategy=None,
         requirements_txt=self.requirements_file,
         chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
         worker_config=None,
         worker_count=0,
         region="us-central1",
         entry_point_args=["1000"],
         stream_logs=False,
         docker_image_bucket_name="abc",
         called_from_notebook=True,
         job_labels={"a": "b"},
     )
コード例 #10
0
ファイル: validate_test.py プロジェクト: debtaru/cloud
 def test_invalid_tpu_accelerator_count(self):
     with pytest.raises(ValueError, match=r"Invalid machine configuration"):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["CPU"],
             worker_config=machine_config.MachineConfig(
                 accelerator_type=machine_config.AcceleratorType.TPU_V3),
             worker_count=1,
             region="us-central1",
             args=None,
             stream_logs=True,
             docker_image_bucket_name=None,
             called_from_notebook=False,
         )
コード例 #11
0
 def test_invalid_distribution_strategy(self):
     with self.assertRaisesRegex(
             ValueError,
             r"Invalid `distribution_strategy`",
     ):
         validate.validate(
             entry_point=None,
             distribution_strategy="MirroredStrategy",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
             worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
             worker_count=1,
             entry_point_args=None,
             stream_logs=True,
             docker_image_build_bucket=None,
             called_from_notebook=False,
         )
コード例 #12
0
 def test_invalid_tpu_accelerator_count(self):
     with self.assertRaisesRegex(
             ValueError,
             r"Invalid machine configuration",
     ):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["CPU"],
             worker_config=machine_config.MachineConfig(
                 accelerator_type=machine_config.AcceleratorType.TPU_V3),
             worker_count=1,
             entry_point_args=None,
             stream_logs=True,
             docker_image_build_bucket=None,
             called_from_notebook=False,
         )
コード例 #13
0
ファイル: validate_test.py プロジェクト: jonah-kohn/cloud
 def test_invalid_tpu_accelerator_tf_version(self, mock_os_path):
     with self.assertRaisesRegex(
             NotImplementedError,
             r"TPUs are only supported for TF version <= 2.1.0"):
         validate.validate(
             entry_point=None,
             distribution_strategy="auto",
             requirements_txt=None,
             chief_config=machine_config.COMMON_MACHINE_CONFIGS["CPU"],
             worker_config=machine_config.MachineConfig(
                 accelerator_type=machine_config.AcceleratorType.TPU_V2,
                 accelerator_count=8,
             ),
             worker_count=1,
             region="us-central1",
             args=None,
             stream_logs=True,
             docker_image_bucket_name=None,
             called_from_notebook=False,
         )
コード例 #14
0
ファイル: validate_test.py プロジェクト: jonah-kohn/cloud
    def test_valid_args(self, mock_os_path):
        self.setup()
        validate.validate(
            entry_point=self.script_entry_point,
            distribution_strategy="auto",
            requirements_txt=self.requirements_file,
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_count=1,
            region="us-central1",
            args=None,
            stream_logs=True,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=self.script_entry_point,
            distribution_strategy=None,
            requirements_txt=self.requirements_file,
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=self.notebook_entry_point,
            distribution_strategy=None,
            requirements_txt=self.requirements_file,
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=None,
            distribution_strategy=None,
            requirements_txt=self.requirements_file,
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name="abc",
            called_from_notebook=True,
        )

        validate.validate(
            entry_point=None,
            distribution_strategy=None,
            requirements_txt=self.requirements_file,
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name="abc",
            called_from_notebook=True,
            job_labels={"a": "b"},
        )
コード例 #15
0
ファイル: validate_test.py プロジェクト: debtaru/cloud
    def test_valid_args(self):
        validate.validate(
            entry_point=
            "src/python/tensorflow_cloud/core/tests/testdata/mnist_example_using_fit.py",
            distribution_strategy="auto",
            requirements_txt=
            "src/python/tensorflow_cloud/core/tests/testdata/requirements.txt",
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_count=1,
            region="us-central1",
            args=None,
            stream_logs=True,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=
            "src/python/tensorflow_cloud/core/tests/testdata/mnist_example_using_fit.py",
            distribution_strategy=None,
            requirements_txt=
            "src/python/tensorflow_cloud/core/tests/testdata/requirements.txt",
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=
            "src/python/tensorflow_cloud/core/tests/testdata/mnist_example_using_fit.ipynb",
            distribution_strategy=None,
            requirements_txt=
            "src/python/tensorflow_cloud/core/tests/testdata/requirements.txt",
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name=None,
            called_from_notebook=False,
        )

        validate.validate(
            entry_point=None,
            distribution_strategy=None,
            requirements_txt=
            "src/python/tensorflow_cloud/core/tests/testdata/requirements.txt",
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name="abc",
            called_from_notebook=True,
        )

        validate.validate(
            entry_point=None,
            distribution_strategy=None,
            requirements_txt=
            "src/python/tensorflow_cloud/core/tests/testdata/requirements.txt",
            chief_config=machine_config.COMMON_MACHINE_CONFIGS["K80_1X"],
            worker_config=None,
            worker_count=0,
            region="us-central1",
            args=["1000"],
            stream_logs=False,
            docker_image_bucket_name="abc",
            called_from_notebook=True,
            job_labels={"a": "b"},
        )