diff master/src/wecu/wecu.py @ 60:5fdca5baa4e9

refactor a bit, add support for sac with bespoke mapper
author Henry S. Thompson <ht@markup.co.uk>
date Thu, 28 May 2020 12:55:03 +0000
parents a3edba8dab11
children cfaf5223b071
line wrap: on
line diff
--- a/master/src/wecu/wecu.py	Thu May 28 09:58:38 2020 +0000
+++ b/master/src/wecu/wecu.py	Thu May 28 12:55:03 2020 +0000
@@ -105,20 +105,16 @@
 
     cores_per_worker = num_cores(args)
 
-    if args.by_file:
-        os.system('run_sac.sh {} {} {} by-file {} {}'.format(cores_per_worker,
-                                                             HOSTS_FILEPATH,
-                                                             WORK_DIR,
-                                                             regex_str,
-                                                             patterns_str))
-        return
-
-
-    os.system('run_sac.sh {} {} {} aggregate {} {}'.format(cores_per_worker,
-                                                           HOSTS_FILEPATH,
-                                                           WORK_DIR,
-                                                           regex_str,
-                                                           patterns_str))
+    os.system('run_sac.sh {} {} {} {} {} {} {}'.format(
+        cores_per_worker,
+        HOSTS_FILEPATH,
+        WORK_DIR,
+        ('sac_mapper.py' if args.mapper is None
+         else args.mapper),
+        ('by-file' if args.by_file
+         else 'aggregate'),
+        regex_str,
+        patterns_str))
 
 def generate_handler(args):
     import generate_file_list
@@ -174,6 +170,7 @@
 sac_list.add_argument('pattern', type=str, nargs='+')
 sac_list.add_argument('--regex', action="store_true", help="Provide this flag to indicate that the provided strings should be treated as regular expressions")
 sac_list.add_argument('--by-file', action="store_true", help="Provide this flag to indicate that the output should not be aggregated and displayed per file instead")
+sac_list.add_argument('--mapper', type=str, help="Supply a bespoke mapper for use in place of sac_mapper.py")
 sac_list.add_argument('--jobs-per-worker', type=int, help="By deafult the number of concurrent tasks is set to the number of available logical cores. Provide this flag to set a different number of concurrent tasks.")
 sac_list.set_defaults(handler=sac_handler)