def _get_commands(in_workspace): d = {} for cmd in iter_classes(ParadeCommand, 'parade.command', class_filter=lambda cls: cls != ParadeCommand): if in_workspace or not cmd.requires_workspace: cmd_name = cmd.__module__.split('.')[-1] d[cmd_name] = cmd() return d
def _get_config_repo(driver, uri, workdir=None): for repo in iter_classes(ConfigStore, 'parade.config', class_filter=lambda cls: cls != ConfigStore): repo_name = repo.__module__.split('.')[-1] if repo_name == driver: return repo(uri, workdir=workdir)
def load_table_component_class(context, driver): from parade.utils.modutils import iter_classes if driver not in _driver_class_cache: for table_class in iter_classes( CustomTable, 'parade.server.dash.table', context.name + '.dashboard.table', class_filter=lambda cls: cls != CustomTable): table_key = table_class.__module__.split('.')[-1] if table_key not in _driver_class_cache: _driver_class_cache[table_key] = table_class return _driver_class_cache[driver]
def load_filter_component_class(context, driver): from parade.utils.modutils import iter_classes if driver not in _driver_class_cache: for filter_class in iter_classes( CustomFilter, 'parade.server.dash.filter', context.name + '.dashboard.filter', class_filter=lambda cls: cls != CustomFilter): filter_key = filter_class.__module__.split('.')[-1] if filter_key not in _driver_class_cache: _driver_class_cache[filter_key] = filter_class return _driver_class_cache[driver]
def load_dashboards(app, context, name=None): """ generate the task dict [task_key => task_obj] :return: """ d = {} for dash_class in iter_classes(Dashboard, context.name + '.dashboard'): dashboard = dash_class(app, context) dash_name = dashboard.name if name and dash_name != name: continue d[dash_name] = dashboard return d
def load_chart_component_class(context, driver): from parade.utils.modutils import iter_classes # import pdb; pdb.set_trace() if driver not in _driver_class_cache: for chart_class in iter_classes( CustomChart, 'parade.server.dash.chart', context.name + '.dashboard.chart', class_filter=lambda cls: cls != CustomChart): chart_key = chart_class.__module__.split('.')[-1] if chart_key not in _driver_class_cache: _driver_class_cache[chart_key] = chart_class return _driver_class_cache[driver]
def _get_commands(in_workspace): d = {} for cmd in iter_classes(ParadeCommand, 'parade.command', class_filter=lambda cls: cls != ParadeCommand): if in_workspace or not cmd.requires_workspace: cmd_name = cmd.__module__.split('.')[-1] cmd_group = None if len(cmd.__module__) == len('parade.command') + 1 + len(cmd_name) else cmd.__module__[ len('parade.command') + 1:-len(cmd_name) - 1] if not cmd_group: d[cmd_name] = (cmd(), cmd_name, None) else: cmd_path = cmd_group + '.' + cmd_name d[cmd_path] = (cmd(), cmd_name, cmd_group) return d