def acl_resources(): return [ acl.AclResource(name='Documentation', children=data_integration.MARA_ACL_RESOURCES + mara_db.MARA_ACL_RESOURCES), acl.AclResource(name='Admin', children=mara_app.MARA_ACL_RESOURCES + mara_acl.MARA_ACL_RESOURCES) ]
def acl_resources(): return [ acl.AclResource( name='Documentation', children=[ data_integration.MARA_ACL_RESOURCES().get('Data Integration'), mara_db.MARA_ACL_RESOURCES().get('DB Schema') ]), acl.AclResource(name='Admin', children=[ mara_app.MARA_ACL_RESOURCES().get('Configuration'), mara_acl.MARA_ACL_RESOURCES().get('Acl') ]) ]
def acl_resources(): return [ acl.AclResource( name='Documentation', children=[ mara_pipelines.MARA_ACL_RESOURCES().get('Pipelines'), mara_db.MARA_ACL_RESOURCES().get('DB Schema') ]), acl.AclResource( name='Data', children=mara_data_explorer.MARA_ACL_RESOURCES().values()), acl.AclResource(name='Admin', children=[ mara_app.MARA_ACL_RESOURCES().get('Configuration'), mara_acl.MARA_ACL_RESOURCES().get('Acl') ]) ]
def _create_acl_resource_for_each_data_set(): for ds in config.data_sets(): resource = acl.AclResource(name=ds.name) data_set_acl_resources[ds.id] = resource acl_resource.add_child(resource)
import json import os import flask from mara_page import acl, navigation, response, bootstrap, _, html from . import config SCOPES = ['https://www.googleapis.com/auth/userinfo.profile', 'openid', 'https://www.googleapis.com/auth/drive.file', 'https://www.googleapis.com/auth/spreadsheets', 'https://www.googleapis.com/auth/userinfo.email'] blueprint = flask.Blueprint('mara_data_explorer', __name__, static_folder='static', url_prefix='/explore', template_folder='templates') acl_resource = acl.AclResource(name='Explore') personal_data_acl_resource = acl.AclResource(name='Personal Data') data_set_acl_resources = {} @blueprint.before_app_first_request # configuration needs to be loaded before we can access it def _create_acl_resource_for_each_data_set(): for ds in config.data_sets(): resource = acl.AclResource(name=ds.name) data_set_acl_resources[ds.id] = resource acl_resource.add_child(resource) def navigation_entry(): return navigation.NavigationEntry( label='Explore', uri_fn=lambda: flask.url_for('mara_data_explorer.index_page'), icon='table',
import datetime import re import flask import mara_db.postgresql from mara_db import config, dbs from mara_page import acl, navigation, response, bootstrap, html, _, xml blueprint = flask.Blueprint('mara_db', __name__, static_folder='static', template_folder='templates', url_prefix='/db') acl_resource = acl.AclResource(name='DB Schema') def navigation_entry(): return navigation.NavigationEntry( label='DB Schema', icon='star', description='Data base schemas', children=[ navigation.NavigationEntry( label=alias, icon='database', description=f'The schema of the {alias} db', uri_fn=lambda current_db=alias: flask.url_for( 'mara_db.index_page', db_alias=current_db)) for alias, db in config.databases().items()
from html import escape import flask from mara_page import acl, navigation, response, bootstrap, _, html from ..data_set import DataSet # The flask blueprint that does blueprint = flask.Blueprint('mara_schema', __name__, static_folder='static', template_folder='templates', url_prefix='/schema') # Defines an ACL resource (needs to be handled by the application) acl_resource_schema = acl.AclResource(name='Schema') def data_set_url(data_set: DataSet) -> str: return flask.url_for('mara_schema.data_set_page', id=data_set.id()) def schema_navigation_entry() -> navigation.NavigationEntry: """Defines a part of the navigation tree (needs to be handled by the application). Returns: A mara NavigationEntry object. """ from ..config import data_sets
import html import pprint import sys import flask from mara_page import acl from mara_page import navigation, response, _, bootstrap from . import get_get_current_config mara_config = flask.Blueprint('mara_config', __name__, url_prefix='/config2', static_folder='static') acl_resource = acl.AclResource('Configuration') @mara_config.route('/') @acl.require_permission(acl_resource) def configuration_page(): config_modules = {} for configs in get_get_current_config(): api_name, func = configs module_name = func.__module__ module = sys.modules[module_name] if module_name not in config_modules: config_modules[module_name] = { 'doc': module.__doc__, 'functions': {} }
from mara_page import acl, navigation, response, bootstrap blueprint = flask.Blueprint('mara_acl', __name__, static_folder='static', url_prefix='/acl', template_folder='templates') @blueprint.before_app_first_request def load_resource_tree(): config.resources( ) # load the tree of resources so that parents / children become linked acl_resource = acl.AclResource(name='Users', rank=100) def navigation_entry(): return navigation.NavigationEntry( label='Users & Permissions', uri_fn=lambda: flask.url_for('mara_acl.acl_page'), icon='users', rank=200, description='User management, roles & permissions') @blueprint.route('') @acl.require_permission(acl_resource) def acl_page(): roles = {}
import flask import pathlib import dataclasses from mara_page import navigation, response, _, bootstrap, acl from . import config docs = flask.Blueprint('docs', __name__, url_prefix='/docs', static_folder='static') documentation_acl_resource = acl.AclResource(name='Documentation') @dataclasses.dataclass class Doc: full_doc_id: str full_name: str path: pathlib.Path @property def doc_name(self): """The Page title which should show up in the menu""" doc_name = self.full_name if '/' in self.full_doc_id and '/' in self.full_name: _, doc_name = self.full_name.split('/', maxsplit=1) return doc_name @property def folder_name(self): """The Name of the Folder this doc is in (or empty for root)""" folder_name = ''
from mara_page import acl, navigation, response, _, html, bootstrap from mara_prophet import config import io import pickle import mara_db.postgresql import base64 import pandas as pd import matplotlib matplotlib.use('agg') from matplotlib import pyplot as plt from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas acl_resource = acl.AclResource(name='Forecasts') blueprint = flask.Blueprint('forecasts', __name__, static_folder='static', url_prefix='/forecasts') def forecasts_navigation_entry(): return navigation.NavigationEntry( label='Forecasts', uri_fn=lambda: flask.url_for('forecasts.view_plots'), icon='fast-forward', description='KPI forecasting')
import json import flask from data_sets import config from data_sets.data_set import find_data_set, Column from data_sets.query import Query, delete_query, list_queries from mara_page import acl, navigation, response, bootstrap, _, html blueprint = flask.Blueprint('data_sets', __name__, static_folder='static', url_prefix='/data-sets', template_folder='templates') acl_resource = acl.AclResource(name='Data sets') personal_data_acl_resource = acl.AclResource(name='Personal Data') data_set_acl_resources = {} @blueprint.before_app_first_request # configuration needs to be loaded before we can access it def _create_acl_resource_for_each_data_set(): for ds in config.data_sets(): resource = acl.AclResource(name=ds.name) data_set_acl_resources[ds.id] = resource acl_resource.add_child(resource) def navigation_entry(): return navigation.NavigationEntry( label='Data sets',
def _create_acl_resource_for_each_data_set(): import mara_schema.config for data_set in mara_schema.config.data_sets(): resource = acl.AclResource(name=data_set.name) acl_resource.add_child(resource)
import flask from mara_page import acl, navigation blueprint = flask.Blueprint('mara_metabase', __name__, url_prefix='/') acl_resource = acl.AclResource(name='Metabase') @blueprint.before_app_first_request # configuration needs to be loaded before we can access it def _create_acl_resource_for_each_data_set(): import mara_schema.config for data_set in mara_schema.config.data_sets(): resource = acl.AclResource(name=data_set.name) acl_resource.add_child(resource) def navigation_entry(): return navigation.NavigationEntry( label='Metabase', uri_fn=lambda: flask.url_for('mara_metabase.metabase'), icon='bar-chart', description='Company wide dashboards, pivoting & ad hoc analysis') @blueprint.route('/metabase') @acl.require_permission(acl_resource) def metabase(): from . import config return flask.redirect(config.external_metabase_url())
"""Data integration web UI""" import functools import flask from mara_page import acl, navigation, _ from .. import config, pipelines blueprint = flask.Blueprint('mara_pipelines', __name__, url_prefix='/pipelines', static_folder='static') acl_resource = acl.AclResource(name='Pipelines') @functools.singledispatch def navigation_icon(node: pipelines.Node): """Returns the navigation entry icon for a pipeline node""" return 'question' navigation_icon.register(pipelines.Task)(lambda _: 'play') navigation_icon.register(pipelines.ParallelTask)(lambda _: 'forward') navigation_icon.register(pipelines.Pipeline)(lambda _: 'random') def navigation_entry(): """Creates a navigation entry that contains links to all data pipelines and their nodes""" def node_entry(node: pipelines.Node) -> navigation.NavigationEntry: return navigation.NavigationEntry( label=node.id, description=node.description, icon=navigation_icon(node),
"""Data integration web UI""" import functools import flask from data_integration import config, pipelines from mara_page import acl, navigation, _ blueprint = flask.Blueprint('data_integration', __name__, url_prefix='/data-integration', static_folder='static') acl_resource = acl.AclResource(name='Data Integration') @functools.singledispatch def navigation_icon(node: pipelines.Node): """Returns the navigation entry icon for a pipeline node""" return 'question' navigation_icon.register(pipelines.Task)(lambda _: 'play') navigation_icon.register(pipelines.ParallelTask)(lambda _: 'forward') navigation_icon.register(pipelines.Pipeline)(lambda _: 'random') def navigation_entry(): """Creates a navigation entry that contains links to all data pipelines and their nodes""" def node_entry(node: pipelines.Node) -> navigation.NavigationEntry: return navigation.NavigationEntry(