[ARVADOS] updated: 55ed403e8bd408c70ce97cefc10156141ccd46a6

git at public.curoverse.com git at public.curoverse.com
Thu Aug 28 10:05:48 EDT 2014


Summary of changes:
 crunch_scripts/crunchutil/robust_put.py | 13 ++++++++-----
 crunch_scripts/run-command              | 33 +++++++++++++++++++--------------
 2 files changed, 27 insertions(+), 19 deletions(-)

       via  55ed403e8bd408c70ce97cefc10156141ccd46a6 (commit)
      from  e32be386f2378807a79da5810414982769aa046c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 55ed403e8bd408c70ce97cefc10156141ccd46a6
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Thu Aug 28 10:02:15 2014 -0400

    3719: run-command uses its own logger instead of the default Python logger to
    avoid cross talk with badly behaved modules.

diff --git a/crunch_scripts/crunchutil/robust_put.py b/crunch_scripts/crunchutil/robust_put.py
index 4ea9d56..5a6d593 100644
--- a/crunch_scripts/crunchutil/robust_put.py
+++ b/crunch_scripts/crunchutil/robust_put.py
@@ -16,7 +16,10 @@ class Args(object):
 
 # Upload to Keep with error recovery.
 # Return a uuid or raise an exception if there are too many failures.
-def upload(source_dir):
+def upload(source_dir, logger=None):
+    if logger is None:
+        logger = logging.getLogger("arvados")
+
     source_dir = os.path.abspath(source_dir)
     done = False
     if 'TASK_WORK' in os.environ:
@@ -35,15 +38,15 @@ def upload(source_dir):
             outuuid = out.finish()
             done = True
         except KeyboardInterrupt as e:
-            logging.critical("caught interrupt signal 2")
+            logger.critical("caught interrupt signal 2")
             raise e
         except Exception as e:
-            logging.exception("caught exception:")
+            logger.exception("caught exception:")
             backoff *= 2
             if backoff > 256:
-                logging.critical("Too many upload failures, giving up")
+                logger.critical("Too many upload failures, giving up")
                 raise e
             else:
-                logging.warning("Sleeping for %s seconds before trying again" % backoff)
+                logger.warning("Sleeping for %s seconds before trying again" % backoff)
                 time.sleep(backoff)
     return outuuid
diff --git a/crunch_scripts/run-command b/crunch_scripts/run-command
index 916e6b2..1635ecd 100755
--- a/crunch_scripts/run-command
+++ b/crunch_scripts/run-command
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
 
 import logging
-logging.basicConfig(level=logging.INFO, format="run-command: %(message)s")
+
+logger = logging.getLogger('run-command')
+log_handler = logging.StreamHandler()
+log_handler.setFormatter(logging.Formatter("run-command: %(message)s"))
+logger.addHandler(log_handler)
+logger.setLevel(logging.INFO)
 
 import arvados
 import re
@@ -124,7 +129,7 @@ try:
         if arvados.current_task()['sequence'] == 0:
             var = jobp["task.foreach"]
             items = get_items(jobp, jobp[var])
-            logging.info("parallelizing on %s with items %s" % (var, items))
+            logger.info("parallelizing on %s with items %s" % (var, items))
             if items is not None:
                 for i in items:
                     params = copy.copy(jobp)
@@ -165,16 +170,16 @@ try:
         stdoutname = subst.do_substitution(taskp, taskp["task.stdout"])
         stdoutfile = open(stdoutname, "wb")
 
-    logging.info("{}{}{}".format(' '.join(cmd), (" < " + stdinname) if stdinname is not None else "", (" > " + stdoutname) if stdoutname is not None else ""))
+    logger.info("{}{}{}".format(' '.join(cmd), (" < " + stdinname) if stdinname is not None else "", (" > " + stdoutname) if stdoutname is not None else ""))
 except subst.SubstitutionError as e:
-    logging.error(str(e))
-    logging.error("task parameters was:")
-    logging.error(pprint.pformat(taskp))
+    logger.error(str(e))
+    logger.error("task parameters was:")
+    logger.error(pprint.pformat(taskp))
     sys.exit(1)
 except Exception as e:
-    logging.exception("caught exception")
-    logging.error("task parameters was:")
-    logging.error(pprint.pformat(taskp))
+    logger.exception("caught exception")
+    logger.error("task parameters was:")
+    logger.error(pprint.pformat(taskp))
     sys.exit(1)
 
 try:
@@ -190,13 +195,13 @@ try:
     rcode = sp.wait()
 
     if sig.sig is not None:
-        logging.critical("terminating on signal %s" % sig.sig)
+        logger.critical("terminating on signal %s" % sig.sig)
         sys.exit(2)
     else:
-        logging.info("completed with exit code %i (%s)" % (rcode, "success" if rcode == 0 else "failed"))
+        logger.info("completed with exit code %i (%s)" % (rcode, "success" if rcode == 0 else "failed"))
 
 except Exception as e:
-    logging.exception("caught exception")
+    logger.exception("caught exception")
 
 # restore default signal handlers.
 signal.signal(signal.SIGINT, signal.SIG_DFL)
@@ -206,11 +211,11 @@ signal.signal(signal.SIGQUIT, signal.SIG_DFL)
 for l in links:
     os.unlink(l)
 
-logging.info("the following output files will be saved to keep:")
+logger.info("the following output files will be saved to keep:")
 
 subprocess.call(["find", ".", "-type", "f", "-printf", "run-command: %12.12s %h/%f\\n"], stdout=sys.stderr)
 
-logging.info("start writing output to keep")
+logger.info("start writing output to keep")
 
 if "task.vwd" in taskp:
     if "task.foreach" in jobp:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list