當前位置: 首頁>>代碼示例>>Python>>正文


Python drmaa.Session方法代碼示例

本文整理匯總了Python中drmaa.Session方法的典型用法代碼示例。如果您正苦於以下問題:Python drmaa.Session方法的具體用法?Python drmaa.Session怎麽用?Python drmaa.Session使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在drmaa的用法示例。


在下文中一共展示了drmaa.Session方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def __init__(self, **kwargs):
        Executor.__init__(self, **kwargs)
        self.session = GLOBAL_SESSION
        if self.session is None:
            raise ValueError("no Grid Session found")

        # if running on cluster, use a working directory on shared drive
        self.work_dir_is_local = iotools.is_local(self.work_dir)

        # connect to global session
        pid = os.getpid()
        self.logger.info('task: pid={}, grid-session={}, work_dir={}'.format(
            pid, str(self.session), self.work_dir))

        self.queue_manager = get_queue_manager(
            kwargs.get("cluster_queue_manager"),
            self.session,
            ignore_errors=self.ignore_errors) 
開發者ID:cgat-developers,項目名稱:cgat-core,代碼行數:20,代碼來源:execution.py

示例2: start_session

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def start_session():
    """start and initialize the global DRMAA session."""
    global GLOBAL_SESSION

    if HAS_DRMAA and GLOBAL_SESSION is None:
        GLOBAL_SESSION = drmaa.Session()
        try:
            GLOBAL_SESSION.initialize()
        except drmaa.errors.InternalException as ex:
            get_logger().warn("could not initialize global drmaa session: {}".format(
                ex))
            GLOBAL_SESSION = None
        return GLOBAL_SESSION 
開發者ID:cgat-developers,項目名稱:cgat-core,代碼行數:15,代碼來源:execution.py

示例3: run_array_job

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def run_array_job(self, session, jt, stdout_path, stderr_path,
                      statement, start, end, increment):

        logger = get_logger()
        logger.info("starting an array job: %i-%i,%i" %
                    (start, end, increment))

        jt.outputPath = ":" + stdout_path
        jt.errorPath = ":" + stderr_path

        logger.info("job submitted with %s" % jt.nativeSpecification)

        # sge works with 1-based, closed intervals
        job_ids = session.runBulkJobs(jt, start + 1, end, increment)
        logger.info("%i array jobs have been submitted as job_id %s" %
                    (len(job_ids), job_ids[0]))

        self.wait_for_job_completion(job_ids)

        logger.info("%i array jobs for job_id %s have completed" %
                    (len(job_ids), job_ids[0]))

        resource_usage = []
        for job in job_ids:
            r = session.wait(job, drmaa.Session.TIMEOUT_WAIT_FOREVER)
            r.resourceUsage["hostname"] = "unknown"
            resource_usage.append(r)

        stdout, stderr = self.queue_manager.get_drmaa_job_stdout_stderr(
            stdout_path, stderr_path)
        job_id = job_ids[0]
        return job_id, stdout, stderr, resource_usage 
開發者ID:cgat-developers,項目名稱:cgat-core,代碼行數:34,代碼來源:execution.py

示例4: __init__

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def __init__(self):
        self.session = drmaa.Session()
        self.session.initialize() 
開發者ID:genotoul-bioinfo,項目名稱:dgenies,代碼行數:5,代碼來源:drmaasession.py

示例5: startSession

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def startSession():
    """start and initialize the global DRMAA session."""

    global GLOBAL_SESSION
    GLOBAL_SESSION = drmaa.Session()
    GLOBAL_SESSION.initialize()
    return GLOBAL_SESSION 
開發者ID:CGATOxford,項目名稱:CGATPipelines,代碼行數:9,代碼來源:Execution.py

示例6: run_program

# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def run_program(self, command, working_directory=os.getcwd(),
                    environment=None, cleanup_files=True,
                    native_spec="-l cputype=intel"):
        """
        Run a program through the grid, capturing the standard output.
        """
        try:
            s = drmaa.Session()
            s.initialize()
            jt = s.createJobTemplate()
            jt.remoteCommand = os.path.dirname(
                os.path.abspath(__file__)) + '/run_program.sh'
            jt.args = [command]

            if environment is not None:
                jt.jobEnvironment = environment

            jt.workingDirectory = working_directory
            jt.nativeSpecification = native_spec
            output_filename = os.path.join(working_directory, 'output.txt')
            jt.outputPath = ':' + output_filename
            jt.joinFiles = True

            jobid = s.runJob(jt)

            s.wait(jobid, drmaa.Session.TIMEOUT_WAIT_FOREVER)

            with open(output_filename, 'r') as output:
                stdout = output.read()

            # Clean up
            if cleanup_files:
                os.remove(output_filename)

        finally:
            try:
                s.control(drmaa.JOB_IDS_SESSION_ALL,
                          drmaa.JobControlAction.TERMINATE)
                s.synchronize([drmaa.JOB_IDS_SESSION_ALL], dispose=True)
                s.exit()
            except(drmaa.errors.NoActiveSessionException):
                pass

        return stdout 
開發者ID:signetlabdei,項目名稱:sem,代碼行數:46,代碼來源:gridrunner.py


注:本文中的drmaa.Session方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。