mara-metabase icon indicating copy to clipboard operation
mara-metabase copied to clipboard

Add a button which reruns sync

Open jankatins opened this issue 4 years ago • 2 comments

We do not have easy access to the commandline, so it would be nice to get a button somewhere to run the sync without triggering a pipeline run or so.

jankatins avatar Dec 17 '20 23:12 jankatins

Hi Jan,

where would that button be? And would a click command (then triggered from jenkins or whatever) also do?

martin-loetzsch avatar Jan 23 '21 21:01 martin-loetzsch

The problem in our "normal" case is that we do not have a jenkins but start stuff via K8s cron in a separate pod, so no easy SSH access, but always some infra spinup to actually run something. So running it from the UI would be way easier.

Re placement: That's a good question: We have that button on a separate page under the Admin menu item which also checks all the Attributes/measures for size (more than 63 chars will somewhere be cut down as PG does not support more than that). Another problem here is that the job takes about 20sec or so, which means no response in the UI during that time.

(The Admin menu has in our case the config, a view which allows me to kill queries, see our Prometheus output,...)

One think I think this could be solved is simply add the endpoint with sufficient access control (and maybe some code to generate the button for you) and let a user add it to a page on their own?

Currently it's solved by this endpoint:

@etl_status_bp.route('/sync-datasets-to-metabase')
@acl.require_permission(admin_change_power_acl_resource)
def sync_datasets_to_metabase():
    """Sync datasets to metabase

    Currently does not show any status, so takes a while!
    """
    import mara_metabase.metadata
    if mara_metabase.metadata.update_metadata():
        flask.flash(f'Synced all datasets to metabase', category='message')
    else:
        flask.flash(f'Error while syncing datasets to metabase', category='danger')

    return flask.redirect(flask.url_for('.dataset_problems'))

Which is on a page with this on it:

@etl_status_bp.route('/dataset-problems')
@acl.require_permission(admin_read_only_acl_resource)
def dataset_problems():
    from app.schema.cli import _check_all_datasets

    checked_datasets, failed, messages = _check_all_datasets()

    body = [
        _.p[f"Checked {checked_datasets} datasets and their entities."],
        _.p[f"Found {failed} Error(s):" if failed else "All ok."],
        _.ul()[[_.li[msg] for msg in messages]] if failed else "",
    ]

    return response.Response(title='Dataset Problems',
                             html=[bootstrap.card(body=body)],
                             action_buttons=[response.ActionButton(
                                 action=flask.url_for('.sync_datasets_to_metabase'),
                                 label='Sync Datasets to Metabase', icon='sync',
                                 title='Sync Datasets to Metabase. This takes a while, do not close the tab!')]
                             )

jankatins avatar Jan 24 '21 21:01 jankatins