def render_function(function_name, function): return _.tr[ _.td(style='max-width:15%;')[_.div(style='display:block;overflow:hidden;text-overflow:ellipsis')[ function_name.replace('_', '_<wbr/>')]], _.td(style='width:30%')[_.em[function['doc']]], _.td(style='width:55%;')[ _.pre(style='margin:0px;padding-top:3px;overflow:hidden;text-overflow:ellipsis;')[ html.escape(pprint.pformat(function['value']))]], ]
def preview(): from .query import Query from .data_set import Column query = Query.from_dict(flask.request.json['query']) def header(column: Column): if column.sortable(): if query.sort_column_name == column.column_name and query.sort_order == 'ASC': icon = _.span(class_=('fa fa-sort-amount-asc'))[''] elif query.sort_column_name == column.column_name and query.sort_order == 'DESC': icon = _.span(class_=('fa fa-sort-amount-desc'))[''] else: icon = '' return _.a(href="#", name=flask.escape(column.column_name))[ icon, ' ', flask.escape(column.column_name)] else: return flask.escape(column.column_name) if current_user_has_permission(query): rows = [_render_preview_row(query, row) for row in query.run(limit=flask.request.json['limit'], offset=flask.request.json['offset'], include_personal_data=acl.current_user_has_permission(personal_data_acl_resource))] else: rows = _.tr[_.td(colspan=len(query.column_names))[acl.inline_permission_denied_message()]] if rows: return str(bootstrap.table(headers=[header(query.data_set.columns[c]) for c in query.column_names], rows=rows)) else: return '∅'
def pipeline_children_table(path: str): """Creates a table that documents all child nodes of a table""" pipeline, __ = pipelines.find_node(path.split('/')) assert (isinstance(pipeline, pipelines.Pipeline)) node_durations_and_run_times = node_cost.node_durations_and_run_times(pipeline.path()) rows = [] for node in pipeline.nodes.values(): [avg_duration, avg_run_time] = node_durations_and_run_times.get(tuple(node.path()), ['', '']) rows.append( _.tr[_.td[_.a(href=views.node_url(node))[node.id.replace('_', '_<wbr>')]], _.td[node.description], _.td[views.format_labels(node)], _.td[node_cost.format_duration(avg_duration)], _.td(style='color:#bbb' if avg_duration == avg_run_time else '')[ node_cost.format_duration(avg_run_time)], _.td[node_cost.format_duration( node_cost.compute_cost(node, node_durations_and_run_times))], _.td[(_.input(class_='pipeline-node-checkbox', type='checkbox', value=node.id, name='ids[]', onchange='runButtons.update()') if config.allow_run_from_web_ui() else '')]]) return \ str(_.script['var runButtons = new PipelineRunButtons();']) \ + str(bootstrap.table(['ID', 'Description', '', 'Avg duration', 'Avg run time', 'Cost', ''], rows)) \ + str(_.script['floatMaraTableHeaders();'])
def _render_command(command: pipelines.Command): """Creates a html documentation for a command""" from mara_page.xml import render def __mask_passwords(content): masks = config.password_masks() if masks: content = ''.join(render(content)) for mask in masks: content = content.replace(mask, "***") return content try: doc = bootstrap.table([], [ _.tr[_.td[_.div[section]], _.td(style='width:90%')[__mask_passwords(content)]] for section, content in command.html_doc_items() ]) except Exception as e: import traceback doc = [ _.p(style='color:red')[ _.i['Error in rendering command documentation']], _.pre(style='color:red')[traceback.format_exc()] ] return [_.p[_.b[command.__class__.__name__]], doc]
def __(task: pipelines.ParallelTask): if not acl.current_user_has_permission(views.acl_resource): return bootstrap.card( header_left=acl.inline_permission_denied_message()) else: return [ bootstrap.card(header_left='Commands before', fixed_header_height=True, sections=[ _render_command(command) for command in task.commands_before ]) if task.commands_before else '', bootstrap.card(header_left='Sub task creation', body=bootstrap.table([], [ _.tr[_.td[_.div[section]], _.td(style='width:90%')[content]] for section, content in task.html_doc_items() ])), bootstrap.card(header_left='Commands after', fixed_header_height=True, sections=[ _render_command(command) for command in task.commands_after ]) if task.commands_after else '' ]
def _render_command(command: pipelines.Command): """Creates a html documentation for a command""" return [ _.p[_.b[command.__class__.__name__]], bootstrap.table([], [ _.tr[_.td[_.div[section]], _.td(style='width:90%')[content]] for section, content in command.html_doc_items() ]) ]
def _render_command(command: pipelines.Command): """Creates a html documentation for a command""" try: doc = bootstrap.table([], [_.tr[_.td[_.div[section]], _.td(style='width:90%')[content]] for section, content in command.html_doc_items()]) except Exception as e: import traceback doc = [_.p(style='color:red')[_.i['Error in rendering command documentation']], _.pre(style='color:red')[traceback.format_exc()]] return [_.p[_.b[command.__class__.__name__]], doc]
def data_set_preview(data_set_id): from .query import Query query = Query(data_set_id=data_set_id) if query.column_names: if current_user_has_permission(query): rows = [_render_preview_row(query, row) for row in query.run(limit=7, offset=0, include_personal_data=acl.current_user_has_permission(personal_data_acl_resource))] else: rows = _.tr[_.td(colspan=len(query.column_names))[acl.inline_permission_denied_message()]] return str( bootstrap.table(headers=[flask.escape(column_name) for column_name in query.column_names], rows=rows)) else: return '∅'
def attribute_rows(data_set: DataSet) -> []: rows = [] for path, attributes in data_set.connected_attributes().items(): if path: rows.append(_.tr[_.td( colspan=3, style='border-top:none; padding-top: 20px;' )[[[ '→ ', _.a( href=data_set_url(entity.data_set) )[link_title] if entity.data_set else link_title, ' ' ] for entity, link_title in [( entity_link.target_entity, entity_link.prefix or entity_link.target_entity.name) for entity_link in path]], [' ', _. i[path[-1].description]] if path[-1].description else '']]) for prefixed_name, attribute in attributes.items(): rows.append(_.tr[_.td[escape(prefixed_name)], _.td[_.i[escape( attribute.description )]], _.td[_.tt[escape( f'{path[-1].target_entity.table_name + "." if path else ""}{attribute.column_name}' )]]]) return rows