Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/fddaq v4.4.x #273

Merged
merged 9 commits into from
Jun 10, 2024
2 changes: 1 addition & 1 deletion src/nanorc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.2.4"
__version__ = "5.2.5"
9 changes: 5 additions & 4 deletions src/nanorc/__main_np04__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
from nanorc.cli import CONTEXT_SETTINGS, loglevels, updateLogLevel
from nanorc.nano_context import NanoContext

from .logbook import ElisaLogbook

# ------------------------------------------------------------------------------
@click_shell.shell(prompt='anonymous@np04rc> ', chain=True, context_settings=CONTEXT_SETTINGS)
@click.version_option(__version__)
Expand Down Expand Up @@ -126,6 +128,7 @@ def np04cli(ctx, obj, traceback, loglevel, elisa_conf, log_path, cfg_dumpdir, do
apparatus_id = apparatus_id,
session_number = partition_number,
username = user,
authenticate_elisa_user = (elisa_conf_data != 'file')
)

rc = NanoRC(
Expand Down Expand Up @@ -265,10 +268,8 @@ def is_authenticated(rc):
rc.log.error(f'\'{rc.session_handler.nanorc_user.username}\' does not have a valid kerberos ticket, use \'kinit\', or \'change_user\' to create a ticket, [bold]inside nanorc![/]', extra={"markup": True})
return False

if not rc.session_handler.elisa_user_is_authenticated():
rc.session_handler.authenticate_elisa_user(
credentials.get_login('elisa')
)
if not rc.session_handler.elisa_user_is_authenticated() and (type(rc.logbook) == ElisaLogbook):
rc.session_handler.authenticate_elisa_user()

return True

Expand Down
10 changes: 4 additions & 6 deletions src/nanorc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,14 @@ def add_decorator(function):
f1 = click.argument('run_num', type=int)(function)
f2 = click.option('--trigger-rate', type=float, default=None, help='Trigger rate (Hz)')(f1)
f3 = click.option('--disable-data-storage/--enable-data-storage', type=bool, default=False, help='Toggle data storage')(f2)
f4 = click.option(
'--ignore-run-registry-insertion-error', type=bool, is_flag=True, default=False,
help='Start the run, even if saving the configuration into the run registry fails')(f3)
f5 = accept_timeout(None)(f4)
f6 = click.option('--run-type', type=click.Choice(['TEST', 'PROD']), default='TEST')(f5)
return click.option('--message', type=str, default="")(f6)
f4 = accept_timeout(None)(f3)
f5 = click.option('--run-type', type=click.Choice(['TEST', 'PROD']), default='TEST')(f4)
return click.option('--message', type=str, default="")(f5)
# sigh end
return add_decorator

def start_defaults_overwrite(kwargs):
kwargs['ignore_run_registry_insertion_error'] = True
#kwargs['run_type'] = 'TEST'
kwargs['path'] = None
return kwargs
Expand Down
2 changes: 1 addition & 1 deletion src/nanorc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def start(self, run_type:str, trigger_rate:float, disable_data_storage:bool, ign
data=runtime_start_data,
)
except Exception as e:
self.log.error(f'Couldn\'t save the configuration so not starting a run!\n{str(e)}')
self.log.error(f'Couldn\'t save the configuration!\n{str(e)}')
self.return_code = 1
if not ignore_run_registry_insertion_error:
raise e
Expand Down
4 changes: 2 additions & 2 deletions src/nanorc/credmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def rm_login(self, service:str, user:str=".*"):


class CERNSessionHandler:
def __init__(self, console, apparatus_id:str, session_number:int, username:str):
def __init__(self, console, apparatus_id:str, session_number:int, username:str, authenticate_elisa_user=True):
self.console = console
import logging
self.log = logging.getLogger(self.__class__.__name__)
Expand All @@ -250,7 +250,7 @@ def __init__(self, console, apparatus_id:str, session_number:int, username:str):
self.log.error(f'User \'{username}\' cannot authenticate, exiting...')
exit(1)

if not self.elisa_user_is_authenticated():
if not self.elisa_user_is_authenticated() and authenticate_elisa_user:
self.authenticate_elisa_user()

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion src/nanorc/k8spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def create_namespace(self, namespace : str):
nslist = [ns.metadata.name for ns in self._core_v1_api.list_namespace().items]
if namespace in nslist:
self.log.debug(f"Not creating \"{namespace}\" namespace as it already exist")
self.log.info(f"Try `kubectl get pods -n {namespace}' and see if there is anything running")
self.log.info(f"If you are sure nothing is running and want to use same session name `kubectl delete ns {namespace}' before starting your next run")
return

self.log.info(f"Creating \"{namespace}\" namespace")
Expand Down Expand Up @@ -202,7 +204,7 @@ def create_namespace(self, namespace : str):
def delete_namespace(self, namespace: str):
nslist = [ns.metadata.name for ns in self._core_v1_api.list_namespace().items]
if not namespace in nslist:
self.log.debug(f"Not deleting \"{namespace}\" namespace as it already exist")
self.log.info(f"The \"{namespace}\" namespace has already been deleted")
return
self.log.info(f"Deleting \"{namespace}\" namespace")
try:
Expand Down