Skip to content

Commit

Permalink
replace spaces in names with %20 during html link generation
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Nov 29, 2023
1 parent a202dd6 commit 887ed07
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
12 changes: 7 additions & 5 deletions pipestat/backends/file_backend/filebackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def __init__(

self.determine_results_file(self.results_file_path)


def determine_results_file(self, results_file_path: str) -> None:
"""Initialize or load results_file from given path
:param str results_file_path: YAML file to report into, if file is
Expand Down Expand Up @@ -345,7 +344,6 @@ def report(
# record_identifier = record_identifier or self.record_identifier
record_identifier = record_identifier


result_formatter = result_formatter or self.result_formatter
results_formatted = []
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
Expand Down Expand Up @@ -670,7 +668,7 @@ def _init_results_file(self) -> None:
def aggregate_multi_results(self, results_directory):
print(f"results directory {results_directory}")
all_result_files = get_all_result_files(results_directory)
aggregate_results_file_path = os.path.join(results_directory,"aggregate_results.yaml")
aggregate_results_file_path = os.path.join(results_directory, "aggregate_results.yaml")

Check warning on line 671 in pipestat/backends/file_backend/filebackend.py

View check run for this annotation

Codecov / codecov/patch

pipestat/backends/file_backend/filebackend.py#L669-L671

Added lines #L669 - L671 were not covered by tests

# THIS WILL OVERWRITE self.results_file_path and self._data on the current psm!
self.results_file_path = aggregate_results_file_path
Expand All @@ -683,9 +681,13 @@ def aggregate_multi_results(self, results_directory):
temp_data = YAMLConfigManager()
if self.pipeline_name in temp_data:
if "project" in temp_data[self.pipeline_name]:
self._data[self.pipeline_name]["project"].update(temp_data[self.pipeline_name]["project"])
self._data[self.pipeline_name]["project"].update(

Check warning on line 684 in pipestat/backends/file_backend/filebackend.py

View check run for this annotation

Codecov / codecov/patch

pipestat/backends/file_backend/filebackend.py#L677-L684

Added lines #L677 - L684 were not covered by tests
temp_data[self.pipeline_name]["project"]
)
if "sample" in temp_data[self.pipeline_name]:
self._data[self.pipeline_name]["sample"].update(temp_data[self.pipeline_name]["sample"])
self._data[self.pipeline_name]["sample"].update(

Check warning on line 688 in pipestat/backends/file_backend/filebackend.py

View check run for this annotation

Codecov / codecov/patch

pipestat/backends/file_backend/filebackend.py#L687-L688

Added lines #L687 - L688 were not covered by tests
temp_data[self.pipeline_name]["sample"]
)

with self._data as data_locked:
data_locked.write()

Check warning on line 693 in pipestat/backends/file_backend/filebackend.py

View check run for this annotation

Codecov / codecov/patch

pipestat/backends/file_backend/filebackend.py#L692-L693

Added lines #L692 - L693 were not covered by tests
Expand Down
3 changes: 1 addition & 2 deletions pipestat/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def force_symlink(file1, file2):


def get_all_result_files(results_file_path):
files = glob.glob(results_file_path+'**/*.yaml')
files = glob.glob(results_file_path + "**/*.yaml")

Check warning on line 224 in pipestat/helpers.py

View check run for this annotation

Codecov / codecov/patch

pipestat/helpers.py#L224

Added line #L224 was not covered by tests
# get parent directory, glob all results files, build one results file return
return files

Check warning on line 226 in pipestat/helpers.py

View check run for this annotation

Codecov / codecov/patch

pipestat/helpers.py#L226

Added line #L226 was not covered by tests

25 changes: 15 additions & 10 deletions pipestat/pipestat.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,14 @@ def __init__(
"pipeline_type", default="sample", override=pipeline_type
)

self.cfg[FILE_KEY] = mk_abs_via_cfg(self.resolve_results_file_path(
self.cfg[CONFIG_KEY].priority_get(
"results_file_path",
env_var=ENV_VARS["results_file"],
override=results_file_path,
)),
self.cfg[FILE_KEY] = mk_abs_via_cfg(
self.resolve_results_file_path(
self.cfg[CONFIG_KEY].priority_get(
"results_file_path",
env_var=ENV_VARS["results_file"],
override=results_file_path,
)
),
self.cfg["config_path"],
)

Expand Down Expand Up @@ -290,16 +292,17 @@ def resolve_results_file_path(self, results_file_path):
if results_file_path:
assert isinstance(results_file_path, str), TypeError("Path is expected to be a str")
if not self.record_identifier and "{record_identifier}" in results_file_path:
raise NotImplementedError(f"Must provide record identifier during PipestatManager creation for this results_file_path: {results_file_path}")
raise NotImplementedError(

Check warning on line 295 in pipestat/pipestat.py

View check run for this annotation

Codecov / codecov/patch

pipestat/pipestat.py#L295

Added line #L295 was not covered by tests
f"Must provide record identifier during PipestatManager creation for this results_file_path: {results_file_path}"
)
self.cfg["unresolved_result_path"] = results_file_path
return results_file_path.format(record_identifier=self.record_identifier)
return results_file_path
def initialize_filebackend(self, record_identifier, results_file_path, flag_file_dir):

def initialize_filebackend(self, record_identifier, results_file_path, flag_file_dir):
# Check if there will be multiple results_file_paths
_LOGGER.debug(f"Determined file as backend: {results_file_path}")


if self.cfg[DB_ONLY_KEY]:
_LOGGER.debug(
"Running in database only mode does not make sense with a YAML file as a backend. "
Expand Down Expand Up @@ -760,7 +763,9 @@ def check_multi_results(self):
if self.file and self.cfg["unresolved_result_path"] != self.file:
if "{record_identifier}" in self.cfg["unresolved_result_path"]:

Check warning on line 764 in pipestat/pipestat.py

View check run for this annotation

Codecov / codecov/patch

pipestat/pipestat.py#L763-L764

Added lines #L763 - L764 were not covered by tests
# assume there are multiple result files in sub-directories
results_directory = self.cfg["unresolved_result_path"].split("{record_identifier}")[0]
results_directory = self.cfg["unresolved_result_path"].split(

Check warning on line 766 in pipestat/pipestat.py

View check run for this annotation

Codecov / codecov/patch

pipestat/pipestat.py#L766

Added line #L766 was not covered by tests
"{record_identifier}"
)[0]
results_directory = mk_abs_via_cfg(results_directory, self.cfg["config_path"])
self.backend.aggregate_multi_results(results_directory)

Check warning on line 770 in pipestat/pipestat.py

View check run for this annotation

Codecov / codecov/patch

pipestat/pipestat.py#L769-L770

Added lines #L769 - L770 were not covered by tests

Expand Down
4 changes: 2 additions & 2 deletions pipestat/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def _get_navbar_dropdown_data_objects(self, objs, wd, context):
for obj_id in objs:
displayable_ids.append(obj_id.replace("_", " "))
page_name = os.path.join(
self.pipeline_reports, (obj_id + ".html").replace(" ", "_").lower()
self.pipeline_reports, (obj_id + ".html").replace(" ", "%20").lower()
)
relpaths.append(_make_relpath(page_name, wd, context))
return relpaths, displayable_ids
Expand All @@ -650,7 +650,7 @@ def _get_navbar_dropdown_data_samples(self, wd, context):
sample_name = sample["record_identifier"]
page_name = os.path.join(
self.pipeline_reports,
f"{sample_name}.html".replace(" ", "_").lower(),
f"{sample_name}.html".replace(" ", "%20").lower(),
)
relpaths.append(_make_relpath(page_name, wd, context))
sample_names.append(sample_name)
Expand Down

0 comments on commit 887ed07

Please sign in to comment.