コード例 #1
0
ファイル: slurm.py プロジェクト: markovg/NeuroMorphoVis
def create_batch_job_script_for_multiple_gids(arguments, gids, script_id):
    """Create a batch job file for different neurons with specific gids for the meshing.

    :param arguments:
        Command line arguments.
    :param gids:
        A list of GIDs.
    :param script_id:
        Script ID.
    """

    # Create slurm configuration
    slurm_config = slurm_configuration.SlurmConfiguration()

    # Update slurm configuration data
    # Job number should match the gid
    slurm_config.job_number = script_id

    # Execution directory, same as output directory
    slurm_config.execution_directory = '%s' % arguments.output_directory

    # Log directory
    slurm_config.logs_directory = '%s/%s' % (
        arguments.output_directory, paths_consts.Paths.SLURM_LOGS_FOLDER)

    # Generate the batch job configuration string
    batch_job_config_string = create_batch_job_config_string(slurm_config)

    # Add the shell command to run blender
    # Setup the shell command
    shell_command = ""
    for gid in gids:

        # Get all the shell commands that are given for a specific GID
        shell_commands = arguments_parser.create_executable_for_single_gid(
            arguments, gid) + '\n'

        shell_command = ''
        for command in shell_commands:
            shell_command += command + '\n'

    # Add the command to the batch job config string
    batch_job_config_string += shell_command

    # Write the batch job script to file in the slurm jobs directory
    slurm_jobs_directory = '%s/%s' % (arguments.output_directory,
                                      paths_consts.Paths.SLURM_JOBS_FOLDER)
    file_ops.write_batch_job_string_to_file(slurm_jobs_directory, script_id,
                                            batch_job_config_string)
コード例 #2
0
ファイル: slurm.py プロジェクト: markovg/NeuroMorphoVis
def create_batch_job_script_for_morphology_file(arguments, morphology_file):
    """Create a batch job file for a morphology file.

    :param arguments:
        Command line arguments.
    :param morphology_file:
        Neuron morphology_file.
    """

    # Create slurm configuration
    slurm_config = slurm_configuration.SlurmConfiguration()

    # Update slurm configuration data
    # Job number should match the gid
    slurm_config.job_number = 0

    # Execution directory, same as output directory
    slurm_config.execution_directory = '%s' % arguments.output_directory

    # Log directory
    slurm_config.logs_directory = '%s/%s' % (
        arguments.output_directory, paths_consts.Paths.SLURM_LOGS_FOLDER)

    # Generate the batch job configuration string
    batch_job_config_string = create_batch_job_config_string(slurm_config)

    # Setup the shell command
    shell_commands = arguments_parser.create_executable_for_single_morphology_file(
        arguments, morphology_file)

    shell_command = ''
    for command in shell_commands:
        shell_command += command + '\n'

    # Add the command to the batch job config string
    batch_job_config_string += shell_command

    # Write the batch job script to file in the slurm jobs directory
    slurm_jobs_directory = '%s/%s' % (arguments.output_directory,
                                      paths_consts.Paths.SLURM_JOBS_FOLDER)
    file_ops.write_batch_job_string_to_file(slurm_jobs_directory,
                                            morphology_file,
                                            batch_job_config_string)
コード例 #3
0
def create_batch_job_script_for_gid(arguments, gid):
    """Create a batch job file for a neuron with specific GID.

    :param arguments:
        Command line arguments.
    :param gid:
        Neuron GID.
    """

    # Create slurm configuration
    slurm_config = slurm_configuration.SlurmConfiguration()

    # Update slurm configuration data
    # Job number should match the gid
    slurm_config.job_number = int(gid)

    # Execution directory, same as output directory
    slurm_config.execution_directory = '%s' % arguments.output_directory

    # Log directory
    slurm_config.logs_directory = '%s/%s' % (
        arguments.output_directory, paths_consts.Paths.SLURM_LOGS_FOLDER)

    # Generate the batch job configuration string
    batch_job_config_string = create_batch_job_config_string(slurm_config)

    # Setup the shell command
    shell_command = arguments_parser.create_executable_for_single_gid(
        arguments, gid)

    # Add the command to the batch job config string
    batch_job_config_string += shell_command

    # Write the batch job script to file in the slurm jobs directory
    slurm_jobs_directory = '%s/%s' % (arguments.output_directory,
                                      paths_consts.Paths.SLURM_JOBS_FOLDER)
    file_ops.write_batch_job_string_to_file(slurm_jobs_directory, gid,
                                            batch_job_config_string)
コード例 #4
0
    # create slurm directory
    slurm_directory = "%s/%s" % (args.output_directory, "slurm")
    fh.clean_and_create_new_directory(slurm_directory)

    logs_directory = "%s/%s" % (args.output_directory, "logs")
    fh.clean_and_create_new_directory(logs_directory)

    # execute the workflow on the cluster
    if args.node == 'cluster':

        # write all the batch jobs to the directory
        for i, psh_file in enumerate(psh_file_list):

            # create the slurm configuration.
            slurm_configuration = s_config.SlurmConfiguration()
            slurm_configuration.job_number = i
            slurm_configuration.log_files_path = logs_directory

            # create the slurm configuration string.
            slurm_batch_string = slurm.create_batch_config(slurm_configuration)

            # create the execution command and then append it to the batch string
            execution_command = create_executable_command(args, psh_file)
            slurm_batch_string += execution_command

            # save the script
            script_path = "%s/%s.sh" % (slurm_directory, str(i))
            fh.save_file_to_disk(script_path, slurm_batch_string)

        # run all the batch scripts