Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a button which reruns sync #10

Open
jankatins opened this issue Dec 17, 2020 · 2 comments
Open

Add a button which reruns sync #10

jankatins opened this issue Dec 17, 2020 · 2 comments

Comments

@jankatins
Copy link
Member

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.

@martin-loetzsch
Copy link
Member

Hi Jan,

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

@jankatins
Copy link
Member Author

jankatins commented Jan 24, 2021

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!')]
                             )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants