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_datatomessage_ix_models.Code and data for individual projects will be moved from
message_datatomessage_ix_modelsat a suitable point during the process of publication. (This point may vary from project to project.)message_datamay be renamed.
This page gives some practices and tips for using the two packages together.
- Always import via
message_ix_models The package installs
MessageDataFinderinto Python’s import system (importlib), which changes its default behaviour as follows: ifA module
message_ix_models.model.model_nameormessage_ix_models.project.project_nameis imported, andThis module does not actually exist in
message_ix_models,Then the code will instead file the respective modules
message_data.model.model_nameormessage_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_datatomessage_ix_models.- Use the mix-models command-line interface (CLI)
All CLI commands and subcommands defined in
message_dataare also made available through themessage_ix_modelsCLI, 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_datainmessage_ix_models The open-source code should not depend on any private code. If this appears necessary, the code in
message_datacan probably be moved tomessage_ix_models.- Use
message_ix_models.toolsandutilinmessage_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.