Setup

Installation

Git

If you want the latest code or even feel like contributing, the code is available on Github.

You can easily clone the code with git:

git clone git://github.com/metabrainz/sir.git

Now you can install it system-wide:

python setup.py install

or start hacking on the code. To do that, you’ll need to run at least:

python setup version

once to generate the file sir/version.py which the code needs. This file does not have to be added into the git repository because it only contains the hash of the current git commit, which changes after each commit operation.

Setup

The easiest way to run sir at the moment is to use a virtual environment. Once you have virtualenv for Python 3.13 installed, use the following to create the environment:

virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
cp config.ini.example config.ini

Note: Environment variables can be used in config.ini with the syntaxes $NAME and ${NAME}. Undefined variables will not be replaced at all. Escaping is not supported.

You can now use sir via:

python -m sir

PostgreSQL Setup

Database

Sir requires that you install the sir schema into your MusicBrainz database:

# From the sir checkout. python -m sir setup

It also requires to have built the materialized (or denormalized) tables for the MusicBrainz database:

# From the musicbrainz-server checkout. ./admin/BuildMaterializedTables –database=MAINTENANCE all

For standalone databases, it requires that you install dbmirror2 replication triggers. (These should not be installed on mirrors.) If you’re running MusicBrainz Docker, follow the setup instructions there. For MusicBrainz Server setups outside of Docker, run these commands:

# From the musicbrainz-server checkout. admin/psql MAINTENANCE < admin/sql/CreateAllReplicationTriggers.sql

# From the sir checkout. python -m sir setup_standalone_only

Solr

Of course you’ll need a Solr server somewhere to send the data to. The mbsssss repository contains instructions on how to add the MusicBrainz schemas to a Solr server.

Also check values for the following keys in the file config.ini:

Keys

Description

[solr] uri

The URI to Solr top-level V1 API (ending with /solr)

[solr] batch_size

The number of Solr documents to submit at once

[solr] retries

Optional, the number of retries for connecting to Solr (default is 3)

[solr] backoff_factor

Optional, the backoff factor of the waiting time between two retries for connecting to Solr (default is 1)

MusicBrainz Database Schema

Of course you’ll need a MusicBrainz database somewhere to read the data from. The active database schema sequence must be 30 (or any future schema version if still compatible). Follow announcements from the MetaBrainz blog.

Only Sir 4.y.z is able to read from database of schema sequence 30 (or any future schema if still compatible, but it reads and sends the data made available from schema sequence 30 only).

Web Service Compatibility

If you have applications that are already able to parse search results from search.musicbrainz.org in the mmd-schema XML or the derived JSON format, you can enable the wscompat setting in the configuration file. This will store an mmd-compatible XML document in a field called _store for each Solr document. Installing mb-solrquerywriter on your Solr server will then allow you to retrieve responses as mmd-compatible XML or the derived JSON.