本文整理汇总了Python中cylc.suite_logging.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cylc.suite_logging.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_message_succeeded
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _process_message_succeeded(self, itask, event_time):
"""Helper for process_message, handle a succeeded message."""
self.pflag = True
itask.set_summary_time('finished', event_time)
self.suite_db_mgr.put_update_task_jobs(itask, {
"run_status": 0,
"time_run_exit": event_time,
})
# Update mean elapsed time only on task succeeded.
if itask.summary['started_time'] is not None:
itask.tdef.elapsed_times.append(
itask.summary['finished_time'] -
itask.summary['started_time'])
if not itask.state.outputs.all_completed():
msg = ""
for output in itask.state.outputs.get_not_completed():
if output not in [TASK_OUTPUT_EXPIRED,
TASK_OUTPUT_SUBMIT_FAILED,
TASK_OUTPUT_FAILED]:
msg += "\n " + output
if msg:
LOG.info("Succeeded with outputs not completed: %s" % msg,
itask=itask)
if itask.state.reset_state(TASK_STATUS_SUCCEEDED):
self.setup_event_handlers(itask, "succeeded", "job succeeded")
self._reset_job_timers(itask)
示例2: _process_message_submit_failed
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _process_message_submit_failed(self, itask, event_time):
"""Helper for process_message, handle a submit-failed message."""
LOG.error(self.EVENT_SUBMIT_FAILED, itask=itask)
if event_time is None:
event_time = get_current_time_string()
self.suite_db_mgr.put_update_task_jobs(itask, {
"time_submit_exit": get_current_time_string(),
"submit_status": 1,
})
itask.summary['submit_method_id'] = None
if (TASK_STATUS_SUBMIT_RETRYING not in itask.try_timers or
itask.try_timers[TASK_STATUS_SUBMIT_RETRYING].next() is None):
# No submission retry lined up: definitive failure.
self.pflag = True
# See github #476.
if itask.state.reset_state(TASK_STATUS_SUBMIT_FAILED):
self.setup_event_handlers(
itask, self.EVENT_SUBMIT_FAILED,
'job %s' % self.EVENT_SUBMIT_FAILED)
else:
# There is a submission retry lined up.
timer = itask.try_timers[TASK_STATUS_SUBMIT_RETRYING]
delay_msg = "submit-retrying in %s" % timer.delay_timeout_as_str()
msg = "%s, %s" % (self.EVENT_SUBMIT_FAILED, delay_msg)
LOG.info("job(%02d) %s" % (itask.submit_num, msg), itask=itask)
itask.summary['latest_message'] = msg
if itask.state.reset_state(TASK_STATUS_SUBMIT_RETRYING):
self.setup_event_handlers(
itask, self.EVENT_SUBMIT_RETRY,
"job %s, %s" % (self.EVENT_SUBMIT_FAILED, delay_msg))
self._reset_job_timers(itask)
示例3: poll_task_jobs
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def poll_task_jobs(self, suite, itasks, poll_succ=True, msg=None):
"""Poll jobs of specified tasks.
Any job that is or was submitted or running can be polled, except for
retrying tasks - which would poll (correctly) as failed. And don't poll
succeeded tasks by default.
This method uses _poll_task_jobs_callback() and
_manip_task_jobs_callback() as help/callback methods.
_poll_task_job_callback() executes one specific job.
"""
to_poll_tasks = []
pollable_statuses = set([
TASK_STATUS_SUBMITTED, TASK_STATUS_RUNNING, TASK_STATUS_FAILED])
if poll_succ:
pollable_statuses.add(TASK_STATUS_SUCCEEDED)
for itask in itasks:
if itask.state.status in pollable_statuses:
to_poll_tasks.append(itask)
else:
LOG.debug("skipping %s: not pollable, "
"or skipping 'succeeded' tasks" % itask.identity)
if to_poll_tasks:
if msg is not None:
LOG.info(msg)
self._run_job_cmd(
self.JOBS_POLL, suite, to_poll_tasks,
self._poll_task_jobs_callback)
示例4: report
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def report(self, request, server_obj):
"""Log client requests with identifying information.
In debug mode log all requests including task messages. Otherwise log
all user commands, and just the first info request from each client.
"""
if threading.current_thread().__class__.__name__ == '_MainThread':
# Server methods may be called internally as well as by clients.
return
auth_user, prog_name, user, host, uuid, priv_level = get_client_info()
name = server_obj.__class__.__name__
log_me = (
cylc.flags.debug or
name in ["SuiteCommandServer",
"ExtTriggerServer",
"BroadcastServer"] or
(name not in ["SuiteIdServer", "TaskMessageServer"] and
uuid not in self.clients))
if log_me:
LOG.debug(
self.__class__.LOG_CONNECT_ALLOWED_TMPL % (
user, host, prog_name, priv_level, uuid)
)
LOG.info(
self.__class__.LOG_COMMAND_TMPL % (
request, user, host, prog_name, uuid))
if name == "SuiteIdServer":
self._num_id_requests += 1
self.report_id_requests()
self.clients[uuid] = datetime.datetime.utcnow()
self._housekeep()
示例5: _process_message_failed
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _process_message_failed(self, itask, event_time, message):
"""Helper for process_message, handle a failed message."""
if event_time is None:
event_time = get_current_time_string()
itask.set_summary_time('finished', event_time)
self.suite_db_mgr.put_update_task_jobs(itask, {
"run_status": 1,
"time_run_exit": event_time,
})
if (TASK_STATUS_RETRYING not in itask.try_timers or
itask.try_timers[TASK_STATUS_RETRYING].next() is None):
# No retry lined up: definitive failure.
self.pflag = True
if itask.state.reset_state(TASK_STATUS_FAILED):
self.setup_event_handlers(itask, "failed", message)
LOG.critical("job(%02d) %s" % (
itask.submit_num, "failed"), itask=itask)
else:
# There is a retry lined up
delay_msg = "retrying in %s" % (
itask.try_timers[TASK_STATUS_RETRYING].delay_timeout_as_str())
msg = "failed, %s" % (delay_msg)
LOG.info("job(%02d) %s" % (itask.submit_num, msg), itask=itask)
itask.summary['latest_message'] = msg
if itask.state.reset_state(TASK_STATUS_RETRYING):
self.setup_event_handlers(
itask, "retry", "%s, %s" % (self.JOB_FAILED, delay_msg))
self._reset_job_timers(itask)
示例6: _run_event_handlers_callback
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _run_event_handlers_callback(self, proc_ctx, abort_on_error=False):
"""Callback on completion of a suite event handler."""
if proc_ctx.ret_code:
msg = '%s EVENT HANDLER FAILED' % proc_ctx.cmd_key[1]
LOG.error(str(proc_ctx))
ERR.error(msg)
if abort_on_error:
raise SuiteEventError(msg)
else:
LOG.info(str(proc_ctx))
示例7: signout
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def signout(self, server_obj):
"""Force forget this client (for use by GUI etc.)."""
caller = server_obj.getLocalStorage().caller
LOG.info(
self.__class__.LOG_SIGNOUT_TMPL % (
caller.user, caller.host, caller.prog_name, caller.uuid))
try:
del self.clients[caller.uuid]
except KeyError:
# Already forgotten.
pass
self._housekeep()
示例8: check_task_jobs
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def check_task_jobs(self, suite, task_pool):
"""Check submission and execution timeout and polling timers.
Poll tasks that have timed out and/or have reached next polling time.
"""
now = time()
poll_tasks = set()
for itask in task_pool.get_tasks():
if self.task_events_mgr.check_job_time(itask, now):
poll_tasks.add(itask)
if itask.poll_timer.delay is not None:
LOG.info(
'poll now, (next in %s)' % (
itask.poll_timer.delay_timeout_as_str()),
itask=itask)
if poll_tasks:
self.poll_task_jobs(suite, poll_tasks)
示例9: report_id_requests
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def report_id_requests(self):
"""Report the frequency of identification (scan) requests."""
current_time = time.time()
interval = current_time - self._id_start_time
if interval > self.CLIENT_ID_REPORT_SECONDS:
rate = float(self._num_id_requests) / interval
if rate > self.CLIENT_ID_MIN_REPORT_RATE:
LOG.warning(
self.__class__.LOG_IDENTIFY_TMPL % (
self._num_id_requests, interval)
)
elif cylc.flags.debug:
LOG.info(
self.__class__.LOG_IDENTIFY_TMPL % (
self._num_id_requests, interval)
)
self._id_start_time = current_time
self._num_id_requests = 0
示例10: _process_message_submitted
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _process_message_submitted(self, itask, event_time):
"""Helper for process_message, handle a submit-succeeded message."""
try:
LOG.info(
('job[%(submit_num)02d] submitted to'
' %(host)s:%(batch_sys_name)s[%(submit_method_id)s]') %
itask.summary,
itask=itask)
except KeyError:
pass
self.suite_db_mgr.put_update_task_jobs(itask, {
"time_submit_exit": event_time,
"submit_status": 0,
"batch_sys_job_id": itask.summary.get('submit_method_id')})
if itask.tdef.run_mode == 'simulation':
# Simulate job execution at this point.
itask.set_summary_time('submitted', event_time)
itask.set_summary_time('started', event_time)
itask.state.reset_state(TASK_STATUS_RUNNING)
itask.state.outputs.set_completion(TASK_OUTPUT_STARTED, True)
return
itask.set_summary_time('submitted', event_time)
# Unset started and finished times in case of resubmission.
itask.set_summary_time('started')
itask.set_summary_time('finished')
itask.summary['latest_message'] = TASK_OUTPUT_SUBMITTED
self.setup_event_handlers(
itask, TASK_OUTPUT_SUBMITTED, 'job submitted')
self.pflag = True
if itask.state.status == TASK_STATUS_READY:
# The job started message can (rarely) come in before the submit
# command returns - in which case do not go back to 'submitted'.
itask.state.reset_state(TASK_STATUS_SUBMITTED)
try:
itask.timeout_timers[TASK_STATUS_SUBMITTED] = (
itask.summary['submitted_time'] +
float(self._get_events_conf(itask, 'submission timeout')))
except (TypeError, ValueError):
itask.timeout_timers[TASK_STATUS_SUBMITTED] = None
self.set_poll_time(itask)
示例11: set_poll_time
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def set_poll_time(itask, now=None):
"""Set the next task execution/submission poll time.
If now is set, set the timer only if the previous delay is done.
Return the next delay.
"""
key = itask.state.status
timer = itask.poll_timers.get(key)
if timer is None:
return
if now is not None and not timer.is_delay_done(now):
return
if timer.num is None:
timer.num = 0
delay = timer.next(no_exhaust=True)
if delay is not None:
LOG.info(
'next job poll in %s (after %s)' % (
timer.delay_as_seconds(), timer.timeout_as_str()),
itask=itask)
return delay
示例12: print_result
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def print_result(result):
"""Print result"""
if result['OUT']:
LOG.info('result> ' + result['OUT'].strip())
if result['ERR']:
LOG.info('FAILED> ' + result['CMD'])
LOG.info(result['ERR'].strip())
示例13: log_task_job_activity
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def log_task_job_activity(ctx, suite, point, name, submit_num=None):
"""Log an activity for a task job."""
ctx_str = str(ctx)
if not ctx_str:
return
if isinstance(ctx.cmd_key, tuple): # An event handler
submit_num = ctx.cmd_key[-1]
job_activity_log = get_task_job_activity_log(
suite, point, name, submit_num)
try:
with open(job_activity_log, "ab") as handle:
handle.write(ctx_str + '\n')
except IOError as exc:
# This happens when there is no job directory, e.g. if job host
# selection command causes an submission failure, there will be no job
# directory. In this case, just send the information to the suite log.
LOG.debug(exc)
LOG.info(ctx_str)
if ctx.cmd and ctx.ret_code:
LOG.error(ctx_str)
elif ctx.cmd:
LOG.debug(ctx_str)
示例14: _check_access_priv_and_report
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def _check_access_priv_and_report(
self, required_privilege_level, log_info=True):
"""Check access privilege and log requests with identifying info.
In debug mode log all requests including task messages. Otherwise log
all user commands, and just the first info command from each client.
Return:
dict: containing the client session
"""
self._check_access_priv(required_privilege_level)
command = inspect.currentframe().f_back.f_code.co_name
auth_user, prog_name, user, host, uuid = _get_client_info()
priv_level = self._get_priv_level(auth_user)
LOG.debug(self.__class__.LOG_CONNECT_ALLOWED_TMPL % (
user, host, prog_name, priv_level, uuid))
if cylc.flags.debug or uuid not in self.clients and log_info:
LOG.info(self.__class__.LOG_COMMAND_TMPL % (
command, user, host, prog_name, uuid))
self.clients.setdefault(uuid, {})
self.clients[uuid]['time'] = time()
self._housekeep()
return self.clients[uuid]
示例15: main
# 需要导入模块: from cylc.suite_logging import LOG [as 别名]
# 或者: from cylc.suite_logging.LOG import info [as 别名]
def main():
"""Manual test playground."""
log = logging.getLogger(LOG)
log.setLevel(logging.INFO) # or logging.DEBUG
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
log.addHandler(handler)
def print_result(result):
"""Print result"""
if result['OUT']:
LOG.info('result> ' + result['OUT'].strip())
if result['ERR']:
LOG.info('FAILED> ' + result['CMD'])
LOG.info(result['ERR'].strip())
pool = SuiteProcPool(3)
for i in range(3):
com = "sleep 5 && echo Hello from JOB " + str(i)
pool.put_command(SuiteProcPool.JOBS_SUBMIT, com, print_result)
com = "sleep 5 && echo Hello from POLL " + str(i)
pool.put_command("poll", com, print_result)
com = "sleep 5 && echo Hello from HANDLER " + str(i)
pool.put_command("event-handler", com, print_result)
com = "sleep 5 && echo Hello from HANDLER && badcommand"
pool.put_command("event-handler", com, print_result)
LOG.info(' sleeping')
time.sleep(3)
pool.handle_results_async()
LOG.info(' sleeping')
time.sleep(3)
pool.close()
# pool.terminate()
pool.handle_results_async()
LOG.info(' sleeping')
time.sleep(3)
pool.join()
pool.handle_results_async()