Example #1
0
def create_experiment_outputs_path(experiment_name):
    values = experiment_name.split('.')
    path = create_experiment_path(experiment_name, settings.OUTPUTS_ROOT)
    path = os.path.join(path, values[-1])
    if not os.path.isdir(path):
        create_path(path)
    return path
Example #2
0
def create_experiment_path(experiment_name, path):
    values = experiment_name.split('.')
    if len(values) == 3:
        values.insert(2, 'independents')

    for value in values[:-1]:
        path = os.path.join(path, value)
        if not os.path.isdir(path):
            create_path(path)

    return path
Example #3
0
def set_git_repo(repo):
    # Check that the user has a dir
    if not os.path.isdir(repo.user_path):
        create_path(repo.user_path)

    # Check that the project has a dir
    if not os.path.isdir(repo.project_path):
        create_path(repo.project_path)

    # Create a new repo
    get_git_repo(repo_path=repo.path, init=True)
Example #4
0
def new_external_repo(sender, **kwargs):
    instance = kwargs['instance']

    # Check that the user has a dir
    if not os.path.isdir(instance.user_path):
        create_path(instance.user_path)

    # Check that the project has a dir
    if not os.path.isdir(instance.project_path):
        create_path(instance.project_path)

    # Create a new repo
    git.clone_git_repo(repo_path=instance.path, git_url=instance.git_url)
Example #5
0
def get_git_repo(repo_path, init=False):
    if os.path.isdir(repo_path):
        try:
            return GitRepo(repo_path)
        except InvalidGitRepositoryError:
            if init:
                return GitRepo.init(repo_path)
    elif init:
        try:
            create_path(repo_path)
            return get_git_repo(repo_path, init=init)
        except FileNotFoundError:
            pass

    raise ValueError('Could not create a repo on this path {}'.format(repo_path))
Example #6
0
def new_external_repo(sender, **kwargs):
    if kwargs.get('raw'):
        # Ignore signal handling for fixture loading
        return

    instance = kwargs['instance']
    created = kwargs.get('created', False)

    # Check if the experiment is newly created and that we can start it independently
    if not created:
        return

    # Check that the user has a dir
    if not os.path.isdir(instance.user_path):
        create_path(instance.user_path)

    # Check that the project has a dir
    if not os.path.isdir(instance.project_path):
        create_path(instance.project_path)

    # Create a new repo
    git.clone_git_repo(repo_path=instance.path, git_url=instance.git_url)