Exemplo n.º 1
0
def read_bbarfile(bbarfile_path, overrides):

    debug(f"Using bbarfile \"{bbarfile_path}\"", condition=bbarfile_path)
    bbarfile_path = bbarfile_path or default_bbarfile_name
    debug(f"Command line override parameters: {overrides}",
          condition=overrides)

    check_valid_file(bbarfile_path)
    defaults = toml.loads(bbarfile_defaults)

    try:
        bbarfile_data = toml.load(bbarfile_path)
        bbarfile_data = deep_dict_union(defaults, bbarfile_data)
        bbarfile_data = apply_user_overrides(bbarfile_data, overrides)
        bset = BBAR_Project(bbarfile_data)
        if not bset.initialized:
            raise ("Unknown error")
    except toml.decoder.TomlDecodeError as e:
        raise BBARFile_Error(
            f"Error parsing bbarfile TOML in \"{bbarfile_path}\":\n\t{e}")
    except Exception as e:
        raise (e)
        #raise BBARFile_Error(f"Error reading or parsing bbarfile \"{bbarfile_path}\":\n\t{e}")

    return bset
Exemplo n.º 2
0
    def __init__(self, storage_path=default_storage_path):

        if storage_path is not None:
            self.storage_path = storage_path
        if os.path.isfile(self.storage_path):
            debug(f"Loading {self.storage_path}")
            self.state = toml.load(self.storage_path)
        else:
            self.state = {}
Exemplo n.º 3
0
 def on_analyze(self):
     debug("Analyzing output files.")
Exemplo n.º 4
0
 def on_scan(self):
     debug("Scanning for SLURM output files.")
     self.bbar_project.scan_for_results()
Exemplo n.º 5
0
 def on_enter_completed(self):
     self.store.set_status(self.current_state.value)
     debug("Status set to completed")
Exemplo n.º 6
0
 def on_enter_running(self):
     self.store.set_status(self.current_state.value)
     debug("Status set to running")
Exemplo n.º 7
0
 def on_enter_generated(self):
     self.store.set_status(self.current_state.value)
     debug("Status set to generated")
Exemplo n.º 8
0
 def on_enter_init(self):
     self.store.set_status(self.current_state.value)
     debug("Status set to init")
Exemplo n.º 9
0
 def decorator(metric):
     debug(f"Registering metric {name}")
     _PLUGINS[system_plugin_importpath][name] = MetricPlugin(name=name,
                                                             metric=metric)
     return metric
Exemplo n.º 10
0
def get_metric(name, importpath=system_metrics_plugin_importpath):
    """Get a given plugin"""
    debug(f"Trying to register metric {importpath}.{name}")
    importlib.import_module(f"{importpath}.{name}")
    return _METRICS[importpath][name].metric
Exemplo n.º 11
0
def get_report(name, importpath=system_reports_plugin_importpath):
    """Get a given plugin"""
    debug(f"Trying to register report {importpath}.{name}")
    importlib.import_module(f"{importpath}.{name}")
    return _ANALYZER_PLUGINS[importpath][name].report
Exemplo n.º 12
0
 def decorator(report):
     debug(f"Registering report {name}")
     _PLUGINS[system_plugin_importpath][name] = ReportPlugin(name=name,
                                                             report=report)
     return report
Exemplo n.º 13
0
def get(name, importpath=system_plugin_importpath):
    """Get a given plugin"""
    debug(f"Trying to register scheduler {importpath}.{name}")
    importlib.import_module(f"{importpath}.{name}")
    return _PLUGINS[importpath][name].scheduler
Exemplo n.º 14
0
 def decorator(scheduler):
     debug(f"Registering scheduler {name}")
     _PLUGINS[system_plugin_importpath][name] = SchedulerPlugin(
         name=name, scheduler=scheduler)
     return scheduler
Exemplo n.º 15
0
import importlib
from collections import namedtuple
from bbar.logging import debug

debug(f"plugin __file__: {__file__}")

SchedulerPlugin = namedtuple("Plugin", ("name", "scheduler"))
system_plugin_importpath = "bbar.scheduler"
_PLUGINS = {system_plugin_importpath: {}}


def register_scheduler(name):
    """Decorator factory for registering a new plugin"""
    def decorator(scheduler):
        debug(f"Registering scheduler {name}")
        _PLUGINS[system_plugin_importpath][name] = SchedulerPlugin(
            name=name, scheduler=scheduler)
        return scheduler

    return decorator


def register_custom_scheduler(name):
    """Decorator factory for registering user plugins """
    #Not implemented yet, checkout https://realpython.com/python-import/#example-a-package-of-plugins
    pass


def list_plugins():
    """List all plugins"""
    return sorted(list(_PLUGINS))