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, )
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, )
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, )
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, )
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, )
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, )
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, )
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, )
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"}, )
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, )
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, )
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, )
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, )
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"}, )
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"}, )