Metadata-Version: 2.1
Name: metashovel
Version: 0.2.1
Summary: CLI tool to import and export Metabase items (questions, dashboards, collections) across instances
Home-page: https://gitlab.wemove.eu/campeval/metashovel
Author: Romain Thouvenin, Marcin Koziej
Author-email: romain@wemove.eu, marcin@cahoots.pl
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: click
Requires-Dist: metabase (>=1.3.2)
Requires-Dist: pyaml
Requires-Dist: slug

# Metashovel

Metashovel is a Metabase utility tool to mainly import/export questions and dashboards


## Setup
### Running from source

1. Install Pipenv command in your system: `sudo apt install pipenv`
2. Install dependencies from the root of this project directory: `pipenv install`
3. Open shell with requirements loaded in a virtual environment: `pipenv shell`

## Configuration

Depending on subcommand, you configure the cli with:
1. environment variables (mostly for credentials eg API keys, or access urls, eg. url to database with user, pass, hostname, db name)
2. command line switches and arguments

### Environment variables reference

1. API keys and Database access urls

Metashovel uses the Metabase API. Define Metabase url, username and password with these variables:

- `METABASE_ENDPOINT` - url of Metabase instance with scheme, eg: https://data.awesome.com
- `METABASE_AUTH_EMAIL` - email for login
- `METABASE_AUTH_PASSWORD` - password for login

## Usage

Metashovel has a set of subcommands, similar to git or heroku.

#### Export

`keanu.py metabase export` generates a JSON dump of all the data required to import the collections / dashboards / questions given in options.

The generated JSON is printed on standard output. It contains a property `items` with the list of objects that got exported, as well as a property `mappings` with information to translate ids that make sense only in the context of a Metabase instance (table ids, card ids, etc).

Options:
 - `-c "Some collection"` - Exports all the questions and dashboards contained in the named collection and its child collections. You should ensure that the dashboards refer only to questions contained within that collection, unless you plan to import the data within the same Metabase instance. The collection must exist.

#### Import

`keanu.py metabase import` reads a JSON dump generated by the export command and import the object into a Metabase instance.

Options:
 - `-c "Some collection"` - The name of the collection into which the objects should be imported. The collection must exist and be empty (no support for overwrite / merge at the moment).
 - `-j /path/to/file.json` - The JSON file to import.


## Package building

To build the package use `python setup.py bdist_wheel`.

To install the package locally:

```pip install --upgrade dist/metashovel-0.1-py3-none-any.whl```


To upload it to PyPI:

1. Create a `~/.pypirc` file:
```
[distutils] 
index-servers=pypi
[pypi] 
repository = https://upload.pypi.org/legacy/ 
username = pypi-username
```

2. Use `python -m twine upload dist/*`.

### Contributing

TODO

#### Code Linting and Formatting

A pylint configuration is in pylintrc - configure your editor to run it automatically. Use black for formatting.


