From 8627a8808edb441af879c4a7ddf4812163b47ea6 Mon Sep 17 00:00:00 2001 From: GarethCabournDavies Date: Thu, 13 Jul 2023 07:36:58 -0700 Subject: [PATCH] Ian's comments --- bin/plotting/pycbc_page_versioning | 18 ++++++------------ bin/pygrb/pycbc_pygrb_pp_workflow | 2 +- pycbc/workflow/versioning.py | 29 ++++++++++++----------------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/bin/plotting/pycbc_page_versioning b/bin/plotting/pycbc_page_versioning index 9fc7402a7d9..caad807139a 100755 --- a/bin/plotting/pycbc_page_versioning +++ b/bin/plotting/pycbc_page_versioning @@ -15,11 +15,11 @@ parser = argparse.ArgumentParser() parser.add_argument('--version', action="version", version=pycbc.version.git_verbose_msg) parser.add_argument('--verbose', action='store_true') -parser.add_argument('--executables-files', nargs='+', required=True, - help="List of executable files to provide version " +parser.add_argument('--executables', nargs='+', required=True, + help="List of executables to provide version " "information for") parser.add_argument('--executables-names', nargs='+', required=True, - help="List of executable names, must be in the " + help="Names of the executables, must be in the " "same order as --executables-files") parser.add_argument("--output-file", required=True, help="The directory for output html snippets") @@ -27,7 +27,7 @@ args = parser.parse_args() init_logging(args.verbose) -if not len(args.executables_files) == len(args.executables_names): +if not len(args.executables) == len(args.executables_names): raise parser.error("--executables-files and executables-names must be " "the same number of arguments") @@ -45,18 +45,12 @@ for curr_lib in library_list: code_version_dict = get_code_version_numbers( args.executables_names, - args.executables_files + args.executables ) html_text += f'

Version Information from Executables

:
\n' for key, value in code_version_dict.items(): - # value might be a str or a bytes object in python3. python2 is happy - # to combine these objects (or uniocde and str, their equivalents) - # but python3 is not. - try: - value = value.decode() - except AttributeError: - pass + value = value.decode() html_text += '
  • %s:
    %s



  • \n' \ % (key, str(value).replace('@', '@')) diff --git a/bin/pygrb/pycbc_pygrb_pp_workflow b/bin/pygrb/pycbc_pygrb_pp_workflow index 521dbe2dd88..7e51112c303 100644 --- a/bin/pygrb/pycbc_pygrb_pp_workflow +++ b/bin/pygrb/pycbc_pygrb_pp_workflow @@ -385,7 +385,7 @@ ini_file = _workflow.FileList([_workflow.File(wflow.ifos, '', wflow.analysis_time, file_url='file://' + ini_file_path)]) layout.single_layout(base, ini_file) - + # Create versioning information wf.make_versioning_page( _workflow, diff --git a/pycbc/workflow/versioning.py b/pycbc/workflow/versioning.py index 780d37f9491..11f52a536b8 100644 --- a/pycbc/workflow/versioning.py +++ b/pycbc/workflow/versioning.py @@ -25,9 +25,7 @@ Module to generate/manage the executable used for version information in workflows """ - -from urllib.request import pathname2url -from urllib.parse import urljoin +import os from pycbc.workflow.core import File, FileList, Executable @@ -50,25 +48,22 @@ def make_versioning_page(workflow, config_parser, out_dir, tags=None): tags=tags, ) node = vers_exe.create_node() - exe_names = [] - exe_paths = [] + config_names = [] + exes = [] for name, path in config_parser.items('executables'): - file_url = urljoin('file:', pathname2url(path)) - exe_to_test = File(workflow.ifos, '', - workflow.analysis_time, file_url=file_url) - exe_to_test.add_pfn(file_url, site='local') - if exe_to_test in exe_paths: + exe_to_test = os.path.basename(path) + if exe_to_test in exes: # executable is already part of the list, # find which index and add the name to the # one already stored - path_idx = exe_paths.index(exe_to_test) - name_orig = exe_names[path_idx] - exe_names[path_idx] = f"{name_orig},{name}" + path_idx = exes.index(exe_to_test) + name_orig = config_names[path_idx] + config_names[path_idx] = f"{name_orig},{name}" else: - exe_names.append(name) - exe_paths.append(exe_to_test) - node.add_input_list_opt('--executables-files', FileList(exe_paths)) - node.add_list_opt('--executables-names', exe_names) + config_names.append(name) + exes.append(exe_to_test) + node.add_list_opt('--executables', exes) + node.add_list_opt('--executables-names', config_names) node.new_output_file_opt(workflow.analysis_time, '.html', '--output-file') workflow.add_node(node)