本文整理匯總了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)
示例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
示例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
示例4: __init__
# 需要導入模塊: import drmaa [as 別名]
# 或者: from drmaa import Session [as 別名]
def __init__(self):
self.session = drmaa.Session()
self.session.initialize()
示例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
示例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