Exemplo n.º 1
0
    def test_job_delete(self):
        """Test that deleting a launched job returns it to the NOT_LAUNCHED
        state"""
        train_args = {'foo': 'bar'}
        sweep_output_dir = f'/tmp/{str(uuid.uuid4())}'
        job = sweep.Job(train_args, sweep_output_dir)
        sweep.Job.launch([job], (lambda commands: None))
        sweep.Job.delete([job])

        job = sweep.Job(train_args, sweep_output_dir)
        self.assertEqual(job.state, sweep.Job.NOT_LAUNCHED)
Exemplo n.º 2
0
    def test_job_launch(self):
        """Test that launching a job calls the launcher_fn with appropariate
        arguments, and sets the job to INCOMPLETE state."""
        train_args = {'foo': 'bar'}
        sweep_output_dir = f'/tmp/{str(uuid.uuid4())}'
        job = sweep.Job(train_args, sweep_output_dir)

        launcher_fn_called = False
        def launcher_fn(commands):
            nonlocal launcher_fn_called
            launcher_fn_called = True
            self.assertEqual(len(commands), 1)
            self.assertEqual(commands[0], job.command_str)

        sweep.Job.launch([job], launcher_fn)
        self.assertTrue(launcher_fn_called)

        job = sweep.Job(train_args, sweep_output_dir)
        self.assertEqual(job.state, sweep.Job.INCOMPLETE)
Exemplo n.º 3
0
 def test_job(self):
     """Test that a newly-created job has valid
     output_dir, state, and command_str properties."""
     train_args = {'foo': 'bar'}
     sweep_output_dir = f'/tmp/{str(uuid.uuid4())}'
     job = sweep.Job(train_args, sweep_output_dir)
     self.assertTrue(job.output_dir.startswith(sweep_output_dir))
     self.assertEqual(job.state, sweep.Job.NOT_LAUNCHED)
     self.assertEqual(job.command_str,
         f'python -m domainbed.scripts.train --foo bar --output_dir {job.output_dir}')