예제 #1
0
    def submit_jobs(self,
                    username,
                    password,
                    subject_list,
                    config,
                    force_job_submission=False):

        # submit jobs for the listed subjects
        for subject in subject_list:

            if not force_job_submission:
                run_status_checker = one_subject_run_status_checker.OneSubjectRunStatusChecker(
                )
                if run_status_checker.get_queued_or_running(subject):
                    print("-----")
                    print("\t NOT SUBMITTING JOBS FOR")
                    print("\t			   project: " + subject.project)
                    print("\t			   subject: " + subject.subject_id)
                    print("\t	session classifier: " + subject.classifier)
                    print("\t JOBS ARE ALREADY QUEUED OR RUNNING")
                    continue

            submitter = one_subject_job_submitter.OneSubjectJobSubmitter(
                self._archive, self._archive.build_home)

            put_server_name = os.environ.get(
                "XNAT_PBS_JOBS_PUT_SERVER_LIST").split(" ")
            put_server = random.choice(put_server_name)

            # get information for the subject from the configuration
            clean_output_first = config.get_bool_value(subject.subject_id,
                                                       'CleanOutputFirst')
            processing_stage_str = config.get_value(subject.subject_id,
                                                    'ProcessingStage')
            processing_stage = submitter.processing_stage_from_string(
                processing_stage_str)
            walltime_limit_hrs = config.get_value(subject.subject_id,
                                                  'WalltimeLimitHours')
            vmem_limit_gbs = config.get_value(subject.subject_id,
                                              'VmemLimitGbs')
            output_resource_suffix = config.get_value(subject.subject_id,
                                                      'OutputResourceSuffix')
            brain_size = config.get_value(subject.subject_id, 'BrainSize')
            use_prescan_normalized = config.get_bool_value(
                subject.subject_id, 'UsePrescanNormalized')

            print("-----")
            print("\tSubmitting", submitter.PIPELINE_NAME, "jobs for:")
            print("\t			   project:", subject.project)
            print("\t			   subject:", subject.subject_id)
            print("\t	session classifier:", subject.classifier)
            print("\t			put_server:", put_server)
            print("\t	clean_output_first:", clean_output_first)
            print("\t	  processing_stage:", processing_stage)
            print("\t	walltime_limit_hrs:", walltime_limit_hrs)
            print("\t		vmem_limit_gbs:", vmem_limit_gbs)
            print("\toutput_resource_suffix:", output_resource_suffix)
            print("\t			brain_size:", brain_size)
            print("\tuse_prescan_normalized:", use_prescan_normalized)

            # configure one subject submitter

            # user and server information
            submitter.username = username
            submitter.password = password
            submitter.server = 'https://' + os_utils.getenv_required(
                'XNAT_PBS_JOBS_XNAT_SERVER')

            # subject and project information
            submitter.project = subject.project
            submitter.subject = subject.subject_id
            submitter.session = subject.subject_id + '_' + subject.classifier
            submitter.classifier = subject.classifier
            submitter.brain_size = brain_size
            submitter.use_prescan_normalized = use_prescan_normalized

            # job parameters
            submitter.clean_output_resource_first = clean_output_first
            submitter.put_server = put_server
            submitter.walltime_limit_hours = walltime_limit_hrs
            submitter.vmem_limit_gbs = vmem_limit_gbs
            submitter.output_resource_suffix = output_resource_suffix

            # submit jobs
            submitted_job_list = submitter.submit_jobs(processing_stage)

            for job in submitted_job_list:
                print("\tsubmitted jobs:", job)

            print("-----")
            print(completed_mark_cmd_process.stdout)

            return


if __name__ == "__main__":
    import ccf.structural_preprocessing.one_subject_run_status_checker as one_subject_run_status_checker

    xnat_server = os_utils.getenv_required('XNAT_PBS_JOBS_XNAT_SERVER')
    username, password = user_utils.get_credentials(xnat_server)
    archive = ccf_archive.CcfArchive()

    subject = ccf_subject.SubjectInfo(sys.argv[1], sys.argv[2], sys.argv[3])
    submitter = OneSubjectJobSubmitter(archive, archive.build_home)

    run_status_checker = one_subject_run_status_checker.OneSubjectRunStatusChecker(
    )
    if run_status_checker.get_queued_or_running(subject):
        print("-----")
        print("NOT SUBMITTING JOBS FOR")
        print("project: " + subject.project)
        print("subject: " + subject.subject_id)
        print("session classifier: " + subject.classifier)
        print("JOBS ARE ALREADY QUEUED OR RUNNING")
        print('Process terminated')
        sys.exit()

    job_submitter = OneSubjectJobSubmitter(archive, archive.build_home)
    put_server_name = os.environ.get("XNAT_PBS_JOBS_PUT_SERVER_LIST").split(
        " ")
    put_server = random.choice(put_server_name)