def make_project_database_name(name): """Small utility function that creates a unique name for a project database. Returns the name. """ random_string = general_utils.get_random_string(length=5) database_name = name + '_' + random_string + '_' + 'project' return database_name
def adjust_template_collection(template): """Method used to build a unique collection name and add it to the template dictionary. Returns the updated template. """ unique_collection = 'mars_' + general_utils.get_random_string(numbers=True, length=8) template['collection'] = unique_collection return template
def make_workflow_structure(workflow): """Creates and returns a new structure for use in structure storage. """ structure = {} structure['group'] = 'workflow' structure['name'] = workflow['name'] + '_' + general_utils.get_random_string() structure['description'] = 'The storage collection for the {0} workflow.'.format(workflow['name']) return structure
def adjust_name(template): if 'name' not in list(template.keys()): if 'template_file' in list(template.keys()): template['name'] = parse_template_file_name( template['template_file']) else: template['name'] = 'auto_' + general_utils.get_random_string( length=10) general_utils.remove_dictionary_keys(template, ['template_file']) return template
def git_create_branch(directory, git_hash, branch=None, checkout=True): """Creates a new branch based on a given hash. Optionally allows for specifiying branch name, but will generate a random branch name if none specified. Optionally allows to create branch without checking it out. """ if not branch: branch = general_utils.get_random_string() if checkout: git_string = 'git -C {directory} checkout -b {branch} {git_hash}'.format(directory=directory, git_hash=git_hash, branch=branch) else: git_string = 'git -C {directory} branch {branch} {git_hash}'.format(directory=directory, git_hash=git_hash, branch=branch) output = get_Popen_output(git_string) if output: return branch return False
def add_unique_id(workflow_function): workflow_function['unique_id'] = general_utils.get_random_string()
def adjust_collection(template): if 'collection' not in list(template.keys()): unique_collection = 'mars_' + general_utils.get_random_string( numbers=True, length=10) template['collection'] = unique_collection return template
def add_unique_id(function): """Adds a unique id for the function when it is added to a workflow to support multiple copies of the same function. """ function['unique_id'] = general_utils.get_random_string() return function