Skip to main content

Mara Metabase

Build Status PyPI - License PyPI version Slack Status

Automating the setup and configuration of Metabase instances. Comes with

  • Functions for adding users, databases & settings

  • Syncing of field descriptions and metrics defined with Mara Schema to Metabase

  • Syncing of users and permissions to Metabase

  • A Makefile for running Metabase locally

 

Installation

To use the library directly, use pip:

pip install mara-metabase

or

pip install -e git+https://github.com/mara/mara-metabase.git

For an example of an integration into a flask application, have a look at the mara example project 1.

 

Running Metabase

From within a project, include [https://github.com/mara/mara-metabase/tree/master/.scripts/metabase.mk] in your project Makefile (as for example in https://github.com/mara/mara-example-project-1/blob/master/Makefile).

Running make setup-metabase will download a Metabase jar file, run database migrations, add an admin user & create a database connection to the data warehouse. Then, running make run-metabase will start Metabase on port 3000:

Metabase

You can log in with the default username admin@my-company.com and the password 123abc (configurable via mara_metabase/config.py, please change in production).

For running Metabase in production, please have a look at https://www.metabase.com/docs/latest/operations-guide/installing-metabase.html.

 

Features

Programatically setting up Metabase

The file mara_metabase/setup.py contains functions for configuring a Metabase instance by directly writing to its metadata database (rather than manually configuring an instance through the UI). These functions are particularly useful when multiple Metabase instances are maintained (e.g. one for each testing / staging environment).

There is a flask cli command for running the setup function: flask mara_metabase.setup.

Danger: this will remove any other configured database connections from metabase!

 

Metadata sync

If you have a data warehouse schema defined in Mara Schema, then you can automatically sync field descriptions and metric definitions with the update_metadata function in mara_metabase/metadata.py.

Here's an example of an automatically synced definition for the metric average order value:

Metabae metadata sync

This function assumes that all reporting tables were created using the sql-generation features of Mara Schema.

The schema sync can be triggered manually with flask mara_metabase.update-metadata.

Have a look at https://github.com/mara/mara-example-project-1/blob/master/app/pipelines/update_frontends/__init__.py for how to integrate schema sync into a data pipeline.

 

Syncing of users, groups & permissions from Mara ACL

Once you add the Metabase ACL resource in mara_metabase/views.py to your project, you can easily control which users can query which data set:

Metabase ACL

The sync must be explicitly enabled in your setup code to not interfere with a metabase instance which has its own user management:

# e.g. in app/ui/__init__.py 
import mara_metabase.acl
mara_metabase.acl.enable_automatic_sync_of_users_and_permissions_to_metabase()

Danger: Enabling this feature will overwrite any existing users, groups & permissions in Metabase

After enabling, all users in Mara ACL will be synced to Metabase together with their respective groups on "Save" of the permissions. Permissions in Metabase can be given for all or for individual data sets.

In this example, users from the "Management" group can query all data sets, and users from "Marketing" only "Customers" and "Leads" (with the exception of Thomas who can also query "Order items" and "Sellers").

This is the same data in the Metabase admin UI:

Metabase permissions

 

The easiest way to try out Mara Metabase is to run the mara example project 1.

Release files for mara-metabase 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mara-metabase 2.0.1
File Size Uploaded
mara-metabase-2.0.1.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mara-metabase 2.0.1
File Interpreter ABI Platform
mara_metabase-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 25.5 kB

Release files / mara-metabase-2.0.1.tar.gz

Download URL mara-metabase-2.0.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
999c825aa38a43cb9741187afd8696a29e0e5aa9d672da95bc9228ec4a96d07f
BLAKE2b-256 checksum
How to use checksums
52f219e79ef58e63b55bd5c71ecd3426cebe1359252282cd5f74415ab38db21d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.3

Release files / mara_metabase-2.0.1-py3-none-any.whl

Download URL mara_metabase-2.0.1-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a66b75f29b790ac1469a64fee2f9600f7e8d56ee97ff6e16861567b8695958ac
BLAKE2b-256 checksum
How to use checksums
1ed1f84fb51c5930cf52356294274b2b61e6066030c18610cc4da1cfb2c36264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

2.0.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page