示例#1
0
def safe_log_experiment_job(experiment_name, log_lines):
    log_path = get_experiment_logs_path(experiment_name)
    try:
        _lock_log(log_path, log_lines)
    except (FileNotFoundError, OSError):
        create_experiment_logs_path(experiment_name=experiment_name)
        # Retry
        _lock_log(log_path, log_lines)
示例#2
0
def safe_log_experiment_job(experiment_name, log_lines):
    log_path = get_experiment_logs_path(experiment_name)
    try:
        _lock_log(log_path, log_lines)
    except (FileNotFoundError, OSError):
        create_experiment_logs_path(experiment_name=experiment_name)
        # Retry
        _lock_log(log_path, log_lines)
 def test_experiment_logs_path_creation_deletion(self):
     create_experiment_logs_path(self.experiment.unique_name)
     experiment_logs_path = get_experiment_logs_path(self.experiment.unique_name)
     filepath = get_experiment_logs_path(self.experiment.unique_name)
     open(filepath, '+w')
     assert os.path.exists(experiment_logs_path) is True
     assert os.path.exists(filepath) is True
     delete_experiment_logs(self.experiment.unique_name)
     assert os.path.exists(filepath) is False
 def test_experiment_logs_path_creation_deletion(self):
     create_experiment_logs_path(self.experiment.unique_name)
     experiment_logs_path = get_experiment_logs_path(
         self.experiment.unique_name)
     filepath = get_experiment_logs_path(self.experiment.unique_name)
     open(filepath, '+w')
     assert os.path.exists(experiment_logs_path) is True
     assert os.path.exists(filepath) is True
     delete_experiment_logs(self.experiment.unique_name)
     assert os.path.exists(filepath) is False
def new_experiment(sender, **kwargs):
    instance = kwargs['instance']
    instance.set_status(ExperimentLifeCycle.CREATED)

    # Clean outputs and logs
    delete_experiment_logs(instance.unique_name)
    delete_experiment_outputs(instance.unique_name)

    # Create logs path
    create_experiment_logs_path(instance.unique_name)
 def test_project_outputs_path_creation_deletion(self):
     with patch('scheduler.tasks.experiments.experiments_build.apply_async') as _:  # noqa
         experiment = ExperimentFactory(user=self.project.user, project=self.project)
     create_experiment_outputs_path(experiment.unique_name)
     create_experiment_logs_path(experiment.unique_name)
     experiment_outputs_path = get_experiment_outputs_path(experiment.unique_name)
     project_outputs_path = get_project_outputs_path(self.project.unique_name)
     assert os.path.exists(experiment_outputs_path) is True
     assert os.path.exists(project_outputs_path) is True
     delete_project_outputs(self.project.unique_name)
     assert os.path.exists(experiment_outputs_path) is False
     assert os.path.exists(project_outputs_path) is False
 def test_experiment_group_logs_path_creation_deletion(self):
     experiment = ExperimentFactory(user=self.project.user,
                                    project=self.project,
                                    experiment_group=self.experiment_group)
     experiment_logs_path = get_experiment_logs_path(experiment.unique_name, temp=False)
     create_experiment_logs_path(experiment.unique_name, temp=False)
     open(experiment_logs_path, '+w')
     experiment_group_logs_path = get_experiment_group_logs_path(
         self.experiment_group.unique_name)
     # Should be true, created by the signal
     assert os.path.exists(experiment_logs_path) is True
     assert os.path.exists(experiment_group_logs_path) is True
     delete_experiment_group_logs(self.experiment_group.unique_name)
     assert os.path.exists(experiment_logs_path) is False
     assert os.path.exists(experiment_group_logs_path) is False
 def test_experiment_group_logs_path_creation_deletion(self):
     experiment = ExperimentFactory(user=self.project.user,
                                    project=self.project,
                                    experiment_group=self.experiment_group)
     experiment_logs_path = get_experiment_logs_path(experiment.unique_name)
     create_experiment_logs_path(experiment.unique_name)
     open(experiment_logs_path, '+w')
     experiment_group_logs_path = get_experiment_group_logs_path(
         self.experiment_group.unique_name)
     # Should be true, created by the signal
     assert os.path.exists(experiment_logs_path) is True
     assert os.path.exists(experiment_group_logs_path) is True
     delete_experiment_group_logs(self.experiment_group.unique_name)
     assert os.path.exists(experiment_logs_path) is False
     assert os.path.exists(experiment_group_logs_path) is False
 def test_project_logs_path_creation_deletion(self):
     with patch('scheduler.tasks.experiments.experiments_build.apply_async') as _:  # noqa
         experiment = ExperimentFactory(user=self.project.user, project=self.project)
     experiment_logs_path = get_experiment_logs_path(experiment.unique_name)
     create_experiment_logs_path(experiment.unique_name)
     open(experiment_logs_path, '+w')
     project_logs_path = get_project_logs_path(self.project.unique_name)
     project_repos_path = get_project_logs_path(self.project.unique_name)
     # Should be true, created by the signal
     assert os.path.exists(experiment_logs_path) is True
     assert os.path.exists(project_logs_path) is True
     assert os.path.exists(project_repos_path) is True
     delete_project_logs(self.project.unique_name)
     assert os.path.exists(experiment_logs_path) is False
     assert os.path.exists(project_logs_path) is False
     assert os.path.exists(project_repos_path) is False
示例#10
0
    def setUp(self):
        super().setUp()
        project = ProjectFactory(user=self.auth_client.user)
        experiment = ExperimentFactory(project=project)
        self.url = '/{}/{}/{}/experiments/{}/logs'.format(
            API_V1, project.user.username, project.name, experiment.sequence)

        log_path = get_experiment_logs_path(experiment.unique_name)
        create_experiment_logs_path(experiment_name=experiment.unique_name)
        fake = Faker()
        self.logs = []
        for _ in range(self.num_log_lines):
            self.logs.append(fake.sentence())
        with open(log_path, 'w') as file:
            for line in self.logs:
                file.write(line)
                file.write('\n')
示例#11
0
    def setUp(self):
        super().setUp()
        project = ProjectFactory(user=self.auth_client.user)
        experiment = ExperimentFactory(project=project)
        self.url = '/{}/{}/{}/experiments/{}/logs'.format(
            API_V1,
            project.user.username,
            project.name,
            experiment.sequence)

        log_path = get_experiment_logs_path(experiment.unique_name)
        create_experiment_logs_path(experiment_name=experiment.unique_name)
        fake = Faker()
        self.logs = []
        for _ in range(self.num_log_lines):
            self.logs.append(fake.sentence())
        with open(log_path, 'w') as file:
            for line in self.logs:
                file.write(line)
                file.write('\n')