name fixed
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?
- using JavaScript is a bad idea (some environments prevent it from running, it's async) https://stackoverflow.com/questions/12544056/how-do-i-get-the-current-ipython-jupyter-notebook-name
- why not https://pypi.org/project/ipynbname/? jupyter on SWAN seems to be too old...
- we can of course write sth like https://forums.fast.ai/t/jupyter-notebook-enhancements-tips-and-tricks/17064/38 that would work with the jupyter
5.x.x
but ...