Package: mara-metabase
Mara MetabaseAutomating the setup and configuration of Metabase instances. Comes withFunctions for adding users, databases & settingsSyncing of field descriptions and metrics defined withMara Schemato MetabaseSyncing of users and permissions to MetabaseA Makefile for running Metabase locallyInstallationTo use the library directly, use pip:pip install mara-metabaseorpip install -e git+https://github.com/mara/mara-metabase.gitFor an example of an integration into a flask application, have a look at themara example project 1.Running MetabaseFrom within a project, include [https://github.com/mara/mara-metabase/tree/master/.scripts/metabase.mk] in your project Makefile (as for example inhttps://github.com/mara/mara-example-project-1/blob/master/Makefile).Runningmake setup-metabasewill download a Metabase jar file, run database migrations, add an admin user & create a database connection to the data warehouse. Then, runningmake run-metabasewill start Metabase on port 3000:You can log in with the default usernameadmin@my-company.comand the password123abc(configurable viamara_metabase/config.py, please change in production).For running Metabase in production, please have a look athttps://www.metabase.com/docs/latest/operations-guide/installing-metabase.html.FeaturesProgramatically setting up MetabaseThe filemara_metabase/setup.pycontains 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 thesetupfunction:flask mara_metabase.setup.Danger: this will remove any other configured database connections from metabase!Metadata syncIf you have a data warehouse schema defined inMara Schema, then you can automatically sync field descriptions and metric definitions with theupdate_metadatafunction inmara_metabase/metadata.py.Here's an example of an automatically synced definition for the metric average order value:This function assumes that all reporting tables were created using the sql-generation features of Mara Schema.The schema sync can be triggered manually withflask mara_metabase.update-metadata.Have a look athttps://github.com/mara/mara-example-project-1/blob/master/app/pipelines/update_frontends/__init__.pyfor how to integrate schema sync into a data pipeline.Syncing of users, groups & permissions fromMara ACLOnce you add the Metabase ACL resource inmara_metabase/views.pyto your project, you can easily control which users can query which data set: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__.pyimportmara_metabase.aclmara_metabase.acl.enable_automatic_sync_of_users_and_permissions_to_metabase()Danger: Enabling this feature will overwrite any existing users, groups & permissions in MetabaseAfter 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:The easiest way to try out Mara Metabase is to run themara example project 1.