Migrating from message_data

message_ix_models coexists with the private repository/package currently named message_data. The latter is the location for code related to new research that has not yet been completed and published, data that must remain closed-source permanently, etc.

Over time:

  • All other code will be migrated from message_data to message_ix_models.

  • Code and data for individual projects will be moved from message_data to message_ix_models at a suitable point during the process of publication. (This point may vary from project to project.)

  • message_data may be renamed.

This page gives some practices and tips for using the two packages together.

Always import via message_ix_models

The package installs MessageDataFinder into Python’s import system (importlib), which changes its default behaviour as follows: if

  1. A module message_ix_models.model.model_name or message_ix_models.project.project_name is imported, and

  2. This module does not actually exist in message_ix_models,

  3. Then the code will instead file the respective modules message_data.model.model_name or message_data.project.project_name.

Even when using code that currently or temporarily lives in message_data, access it like this:

# Code in message_data/model/mymodelvariant.py
from message_ix_models.model import mymodelvariant

mymodelvariant.build(...)

This code is future-proof: it will not need adjustment if/when “mymodelvariant” is eventually moved from message_data to message_ix_models.

Use the mix-models command-line interface (CLI)

All CLI commands and subcommands defined in message_data are also made available through the message_ix_models CLI, the executable mix-models.

Use this program in documentation examples and in scripts. In a similar manner to the point above, these documents and scripts will remain correct if/when code is moved.

Don’t import from message_data in message_ix_models

The open-source code should not depend on any private code. If this appears necessary, the code in message_data can probably be moved to message_ix_models.

Use message_ix_models.tools and util in message_data

The former have stricter quality standards and are more transparent, which is better for reproducibility.

At some points, similar code may appear in both packages as it is being migrated. In such cases, always import and use the code in message_ix_models, making any adjustments that are necessary.