From 92681cde024177b9c65a224660719a5faa28f4b4 Mon Sep 17 00:00:00 2001 From: "r.jaepel" <r.jaepel@fz-juelich.de> Date: Mon, 18 Dec 2023 16:38:27 +0100 Subject: [PATCH] Improve error messages and import checks --- cadetrdm/jupyter_functionality.py | 10 ++++++++-- cadetrdm/repositories.py | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cadetrdm/jupyter_functionality.py b/cadetrdm/jupyter_functionality.py index 35db563..615b2c3 100644 --- a/cadetrdm/jupyter_functionality.py +++ b/cadetrdm/jupyter_functionality.py @@ -2,13 +2,19 @@ import sys import time import os from pathlib import Path +import traceback from cadetrdm.io_utils import wait_for_user from ipylab import JupyterFrontEnd import junix import nbformat as nbf -from nbconvert.preprocessors import ExecutePreprocessor -from nbconvert.nbconvertapp import NbConvertApp + +try: + from nbconvert.preprocessors import ExecutePreprocessor + from nbconvert.nbconvertapp import NbConvertApp +except ModuleNotFoundError as e: + traceback.print_exc() + print("No working nbconvert installation found OR a conflict in your packages found.") class Notebook: diff --git a/cadetrdm/repositories.py b/cadetrdm/repositories.py index 1abc0db..6fc2d69 100644 --- a/cadetrdm/repositories.py +++ b/cadetrdm/repositories.py @@ -6,7 +6,6 @@ import traceback from datetime import datetime import shutil import time -import zipfile import contextlib import glob from stat import S_IREAD, S_IWRITE @@ -611,7 +610,10 @@ class ProjectRepo(BaseRepo): super().__init__(repository_path, search_parent_directories=search_parent_directories, *args, **kwargs) with open(repository_path / "output_remotes.json", "r") as handle: - output_remotes = json.load(handle) + try: + output_remotes = json.load(handle) + except FileNotFoundError: + raise RuntimeError(f"Folder {self.working_dir} does not appear to be a CADET-RDM repository.") if output_folder is not None: print("Deprecation Warning. Setting the outputfolder manually during repo instantiation is deprecated" -- GitLab