Skip to content

Commit

Permalink
Ian's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GarethCabournDavies committed Jul 13, 2023
1 parent e4f73e4 commit 8627a88
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 30 deletions.
18 changes: 6 additions & 12 deletions bin/plotting/pycbc_page_versioning
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ 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")
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")

Expand All @@ -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'<h2>Version Information from Executables</h2>:<br>\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 += '<li><b>%s</b>:<br><pre>%s</pre></li><hr><br><br>\n' \
% (key, str(value).replace('@', '&#64;'))

Expand Down
2 changes: 1 addition & 1 deletion bin/pygrb/pycbc_pygrb_pp_workflow
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
29 changes: 12 additions & 17 deletions pycbc/workflow/versioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)

Expand Down

0 comments on commit 8627a88

Please sign in to comment.