Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suite log upgrade. #1958

Merged
merged 5 commits into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bin/cylc-cat-log
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ from cylc.option_parsers import CylcOptionParser as COP
from cylc.owner import is_remote_user
from cylc.rundb import CylcSuiteDAO
from cylc.suite_host import is_remote_host
from cylc.suite_logging import get_logs
from cylc.cfgspec.globalcfg import GLOBAL_CFG
from cylc.task_id import TaskID

Expand Down Expand Up @@ -127,6 +128,7 @@ def get_option_parser():

def get_suite_log_path(options, suite):
"""Return file name of a suite log, given the options."""
log_dir = GLOBAL_CFG.get_derived_host_item(suite, "suite log directory")
if options.list_mode:
basename = "."
else:
Expand All @@ -135,10 +137,12 @@ def get_suite_log_path(options, suite):
else:
basename = NAME_DEFAULT
if options.rotation_num:
basename += "." + options.rotation_num
return os.path.normpath(os.path.join(
GLOBAL_CFG.get_derived_host_item(suite, "suite log directory"),
basename))
log_files = get_logs(log_dir, basename)
try:
return os.path.normpath(log_files[int(options.rotation_num)])
except IndexError:
return ''
return os.path.normpath(os.path.join(log_dir, basename))


def get_task_job_log_path(
Expand Down
5 changes: 2 additions & 3 deletions bin/cylc-submit
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ from cylc.cycling.loader import get_point
from cylc.job_host import RemoteJobHostManager
from cylc.suite_host import get_suite_host, get_hostname
from cylc.regpath import RegPath
from cylc.suite_logging import suite_log
from cylc.suite_logging import SuiteLog
from cylc.cfgspec.globalcfg import GLOBAL_CFG
from cylc.mp_pool import SuiteProcPool
import cylc.version # Ensures '$CYLC_VERSION' is set.
Expand Down Expand Up @@ -116,9 +116,8 @@ def main():
os.environ['CYLC_MODE'] = 'submit'

GLOBAL_CFG.create_cylc_run_tree(suite)
slog = suite_log(suite)
slog = SuiteLog.get_inst(suite)
suite_log_dir = slog.get_dir()
slog.pimp()

RemoteJobHostManager.get_inst().single_task_mode = True

Expand Down
8 changes: 4 additions & 4 deletions lib/cylc/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import logging
from cylc.suite_logging import OUT

# BROKER:
# A collection of output messages with associated owner ids (of the
Expand All @@ -32,7 +32,6 @@ class broker(object):
# outputs.

def __init__(self):
self.log = logging.getLogger('main')
self.all_outputs = {} # all_outputs[ message ] = taskid
self.all_output_msgs = set()

Expand All @@ -52,9 +51,10 @@ def reset(self):

def dump(self):
# for debugging
print "BROKER DUMP:"
log_msg = "BROKER DUMP:"
for msg in self.all_outputs:
print " + " + self.all_outputs[msg], msg
log_msg += "\n+ " + self.all_outputs[msg] + '\t' + msg
OUT.info(log_msg)

def negotiate(self, task):
# can my outputs satisfy any of task's prerequisites
Expand Down
25 changes: 13 additions & 12 deletions lib/cylc/command_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import sys
from time import sleep, time

from cylc.suite_logging import OUT, ERR


class poller(object):
"""Encapsulates polling activity for cylc commands. Derived classes
Expand Down Expand Up @@ -53,14 +55,14 @@ def __init__(self, condition, interval, max_polls, args={}):
try:
self.max_polls = int(max_polls)
except:
sys.stderr.write("max_polls must be an int\n")
ERR.error("max_polls must be an int")
sys.exit(1)

"""check interval is an int"""
try:
self.interval = int(interval)
except:
sys.stderr.write("interval must be an integer\n")
ERR.error("interval must be an integer")
sys.exit(1)

self.n_polls = 0
Expand All @@ -74,10 +76,10 @@ def poll(self):
# exit 1 as we can't know if the condition is satisfied
sys.exit("WARNING: nothing to do (--max-polls=0)")
elif self.max_polls == 1:
sys.stdout.write("checking ")
log_msg = "checking"
else:
sys.stdout.write("polling ")
sys.stdout.write("for '" + self.condition + "'")
log_msg = "polling"
log_msg += " for '" + self.condition + "'"

done = False
while (not done and self.n_polls < self.max_polls):
Expand All @@ -86,16 +88,15 @@ def poll(self):
done = True
else:
if self.max_polls > 1:
sys.stdout.write('.')
log_msg += '.'
sleep(self.interval)
if done:
sys.stdout.write(": satisfied\n")
OUT.info(log_msg + ": satisfied")
return True
else:
print
print >> sys.stderr, " ERROR: condition not satisfied",
OUT.info(log_msg)
err_msg = "condition not satisfied",
if self.max_polls > 1:
print >> sys.stderr, "after " + str(self.max_polls) + " polls"
else:
print >> sys.stderr, ""
err_msg += "\nafter " + str(self.max_polls) + " polls"
ERR.error(err_msg)
return False
Loading