def test_runs_in_job_directory_when_specified(self): self._set_up_deploy_config() self.mock_arguments.job_directory = self.job_directory submit(self.mock_arguments) self.mock_os_chdir.assert_has_calls( [call(self.job_directory), call(self.current_directory)])
def test_sets_override_worker_container_config_with_docker_command_provided( self): self._set_up_deploy_config() command = self.faker.words() self.mock_arguments.command = command self.mock_os_path_exists.return_when(True, command[0]) submit(self.mock_arguments) self.assertEqual({'args': command}, self.config_manager['worker_container_overrides'])
def submit(**kwargs): from foundations_core_cli.job_submission.submit_job import submit from foundations_contrib.global_state import push_state, pop_state arguments = _deployment_arguments(**kwargs) try: push_state() return submit(arguments) finally: pop_state()
def test_sets_specified_resources_from_job_config(self): self._set_up_job_config() submit(self.mock_arguments) self.mock_set_resources.assert_called_with( num_gpus=self.job_config['num_gpus'], ram=self.job_config['ram'])
def test_sets_specified_memory_resources(self): self.mock_arguments.ram = self.ram self._set_up_deploy_config() submit(self.mock_arguments) self.mock_set_resources.assert_called_with(ram=self.ram)
def test_sets_specified_gpu_resources(self): self.mock_arguments.num_gpus = self.num_gpus self._set_up_deploy_config() submit(self.mock_arguments) self.mock_set_resources.assert_called_with(num_gpus=self.num_gpus)
def test_sets_default_job_resources(self): self._set_up_deploy_config() submit(self.mock_arguments) self.mock_set_resources.assert_called_with()
def test_streams_log_from_deployment_using_override_config(self): self._set_up_job_config() submit(self.mock_arguments) self.mock_stream_logs.assert_called_with(self.mock_deployment)
def test_loads_specific_scheduler_config(self): self._set_up_deploy_config() self.mock_arguments.scheduler_config = self.scheduler_config submit(self.mock_arguments) self.mock_load_config.assert_called_with(self.scheduler_config)
def test_sets_override_log_level_from_job_config(self): self._set_up_job_config() submit(self.mock_arguments) self.assertEqual(self.job_config['log_level'], self.config_manager['log_level'])
def test_does_not_break_when_interrupt_happens(self): self._set_up_deploy_config() self.mock_stream_logs.side_effect = self._send_interrupt with self.assert_does_not_raise(): submit(self.mock_arguments)
def test_returns_deployment(self): self._set_up_deploy_config() self.assertEqual(self.mock_deployment, submit(self.mock_arguments))
def test_does_not_stream_logs_if_disabled(self): self._set_up_deploy_config() self.mock_arguments.stream_job_logs = False submit(self.mock_arguments) self.mock_stream_logs.assert_not_called()
def test_streams_log_from_created_deployment(self): self._set_up_deploy_config() submit(self.mock_arguments) self.mock_stream_logs.assert_called_with(self.mock_deployment)
def _submit(self): from foundations_core_cli.job_submission.submit_job import submit submit(self._cli.arguments())
def test_sets_override_worker_container_config(self): self._set_up_job_config() submit(self.mock_arguments) self.assertEqual(self.job_config['worker'], self.config_manager['worker_container_overrides'])
def test_loads_default_scheduler_config(self): self._set_up_deploy_config() submit(self.mock_arguments) self.mock_load_config.assert_called_with('scheduler')