diff --git a/.gitlab/workflow/replace_placeholders_in_md.py b/.gitlab/workflow/replace_placeholders_in_md.py index cd252c8b876eeb7e38dc83fc8203f147d2b2aa95..629adc39cdebedbd19fef9c6dee2ea9880c07ed4 100644 --- a/.gitlab/workflow/replace_placeholders_in_md.py +++ b/.gitlab/workflow/replace_placeholders_in_md.py @@ -138,6 +138,8 @@ def replace_placeholder_with_file_content( ------ ValueError If placeholder contains invalid number of colons. Valid numbers are 0, 1, 2 + FileNotFoundError + If the file specified in a placeholder does not exist. """ print(f"{90 * '-'}\nProcessing {input_file}") @@ -159,7 +161,6 @@ def replace_placeholder_with_file_content( output_file_content = "" replaced_placeholders = [] - skipped_placeholders = [] with open(input_file, "r") as original_file: # Loop over lines in input file and search for lines containing "§§§" @@ -216,15 +217,14 @@ def replace_placeholder_with_file_content( for line in rep_content.readlines()[start:end]: replacement += f"{indentation}{line}" replaced_placeholders.append(replacement_file) - except FileNotFoundError: - replacement = ( - f"FileNotFoundError: File '{replacement_file}' not found.\n " - f"\nOriginal line in input file:\n\n{original_line}" - ) - skipped_placeholders.append(replacement_file) - - # Add to md file - output_file_content += replacement + # Add to md file + output_file_content += replacement + except FileNotFoundError as err: + raise FileNotFoundError( + "\x1b[1;33;40m" + f"file: {input_file}, invalid placeholder: {original_line}" + "\x1b[0m" + ) from err else: output_file_content += original_line @@ -232,8 +232,6 @@ def replace_placeholder_with_file_content( md_file_new.write(output_file_content) print("SUMMARY:") print(f"Replaced placeholders: {replaced_placeholders}") - if len(skipped_placeholders) > 0: - print(f"\x1b[1;33;40mSkipped placeholders: {skipped_placeholders}\x1b[0m") def main(): diff --git a/changelog.md b/changelog.md index 6af44a1f71c04741455de551a08faa713767fe86..a868bc03d58f2f51f5d305f2e62a414ff41b41d1 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,7 @@ ### Latest +- Adding error message if file in placeholder does not exist [!519](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/merge_requests/519) - Update the LWTNN scripts [!512](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/merge_requests/512) - Adding pydash to requirements [!517](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/merge_requests/517) - (Plotting API) Change default value of atlas_second_tag [!514](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/merge_requests/514) diff --git a/docs/trainings/LWTNN-conversion.md b/docs/trainings/LWTNN-conversion.md index fc2337df897c7e14ad2c95282a8eddf3f6819310..8a8760817c6b4cfea463f469051de6840b291f67 100644 --- a/docs/trainings/LWTNN-conversion.md +++ b/docs/trainings/LWTNN-conversion.md @@ -87,7 +87,7 @@ An explanation how to run on the grid with the TDD can be found [here](https://t After having the hdf5 ntuples produced, the script [`check_lwtnn-model.py`](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/blob/master/scripts/check_lwtnn-model.py) can be used to compare the athena evaluation with the keras evaluation. The script requiries a short config files which can be found [here](https://gitlab.cern.ch/atlas-flavor-tagging-tools/algorithms/umami/-/blob/master/examples/check_lwtnn-model_config.yaml). This looks like this: ``` -§§§examples/check_lwtnn-model_config.yaml§§§ +§§§scripts/check_lwtnn-model_config.yaml§§§ ``` You can simply run the script via