Skip to content

name fixed

Aleksandra Mnich requested to merge nb_naming_fix into dev

Fix for the wrong path to the notebook (the report was not generated on SWAN, on GitLabCI/Jenkins we are injecting the paths from the outside). One notebook reported by Zinur, the rest found with:

import os
import re

DIRS = ['60A', '80-120A', '600A', 'ipd', 'ipq', 'it', 'pgc', 'qh', 'rb', 'rq']
NB_FILETYPE = '.ipynb'


def _check_notebook(path):
    name = path.split('/')[-1].split(NB_FILETYPE)[0]
    pattern = re.compile("path_to_notebook = '\./(.*)\.ipynb'")

    with open(path, 'r') as file:
        lines = file.readlines()
        for line in lines:
            result = pattern.search(line)
            if result:
                if result.group(1) != name:
                    print(result.group(1), name)


if __name__ == "__main__":
    for _dir in DIRS:
        notebooks = {file for file in os.listdir(f'../{_dir}') if file.endswith(NB_FILETYPE)}
        for notebook in notebooks:
            _check_notebook(f'../{_dir}/{notebook}')

Why don't we get the current notebook name directly from the notebook with some magic?

Merge request reports