recast-hep / recast-atlas

CLI for ATLAS RECAST contributors
https://recast.docs.cern.ch/
Apache License 2.0
5 stars 5 forks source link

feat: Report 'NOT AVAILABLE' if backend unloaded #78

Closed matthewfeickert closed 2 years ago

matthewfeickert commented 2 years ago

Resolves #75

If a backend is unloadable during recast backends ls --check, instead of raising a KeyError, instead catch the KeyError, raise recastatlas.exceptions.BackendNotAvailableException, and report 'NOT AVAILABLE' for the STATUS.

Example:

$ docker run --rm -it python:3.8 /bin/bash
root@d6fcd8105311:/# python -m venv venv && . venv/bin/activate
(venv) root@d6fcd8105311:/# python -m pip --quiet install --upgrade pip "setuptools<58.0.0" wheel six
(venv) root@d6fcd8105311:/# git clone https://github.com/recast-hep/recast-atlas.git && cd recast-atlas && git checkout origin/feat/note-module-misisng-over-fail -b feat/note-module-misisng-over-fail
(venv) root@d6fcd8105311:/recast-atlas# python -m pip install .
(venv) root@d6fcd8105311:/recast-atlas# recast backends ls --check
NAME                DESCRIPTION                                                 STATUS    
local               runs locally with natively installed tools                  NOT AVAILABLE
docker              runs with containerized tools                               NOT OK    
kubernetes          runs on a Kubernetes cluster                                NOT OK    
reana               runs on a REANA deployment                                  NOT AVAILABLE
(venv) root@d6fcd8105311:/recast-atlas# apt update -y && apt install -y graphviz graphviz-dev
(venv) root@d6fcd8105311:/recast-atlas# python -m pip install .[local,reana]
(venv) root@d6fcd8105311:/recast-atlas# recast backends ls --check
NAME                DESCRIPTION                                                 STATUS    
local               runs locally with natively installed tools                  NOT OK    
docker              runs with containerized tools                               NOT OK    
kubernetes          runs on a Kubernetes cluster                                NOT OK    
reana               runs on a REANA deployment                                  NOT AVAILABLE

In the example above this is hitting the recastatlas.exceptions.BackendNotAvailableException: no REANA auth found from

https://github.com/recast-hep/recast-atlas/blob/63d06a76fc231df7ce6af30c87db89e14cb5840c/src/recastatlas/backends/__init__.py#L11-L17

as the modules exist

(venv) root@d6fcd8105311:/recast-atlas# pip list | grep reana
reana-client           0.7.5
reana-commons          0.7.5