当前位置: 首页>>代码示例>>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;未经允许,请勿转载。