Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmonize handling of codelists #274

Open
khaeru opened this issue Mar 5, 2020 · 1 comment
Open

Harmonize handling of codelists #274

khaeru opened this issue Mar 5, 2020 · 1 comment
Labels
enh New features & functionality

Comments

@khaeru
Copy link
Member

khaeru commented Mar 5, 2020

At the 2020-03-04 MESSAGE meeting, we discussed that several items in the ixmp data model are actually instances of a common concept. Namely:

Using the terminology of SDMX: these are 5 different codelists; lists of codes. Some are hierarchical (e.g. ‘node’); others are not. Some have only their short string ID; others also have a name (e.g. ‘node’), description, or annotation.

Currently, the ixmp.backend.base.Backend API has a proliferation of methods, each with slightly different semantics, for dealing with each of these. The proliferation of different types of objects in the data model makes it more costly to develop other, entirely open source Backends as alternatives to JDBCBackend, as targeted in #278

We should:

  • Simplify the Backend interface (see here) by handling codes and lists of codes in a consistent way. These changes are invisible to the user; they just affect how a Platform talks to a Backend.
    • Add methods:

      • get_codes(codelist)
      • set_code(codelist, id, name=None, description=None, **attrs)
      • delete_code(codelist, id)

      Valid values will be:

      • for the codelist argument: 'node', 'timeslice' (or 'time_slice'?), 'unit', etc.
      • for attrs:
        • codelist='node': 'parent', 'hierarchy', 'mapped_to'.
        • codelist='timeslice': 'category', 'duration'.
        • codelist='unit': none.
    • Delete methods: get_nodes, get_timeslices, get_units, set_node, set_timeslice, set_unit, add_model_name, get_model_names, add_scenario_name, get_scenario_names.

  • Update JDBCBackend:
    • Dispatch to whatever methods in the Java code of ixmp_source implement the Backend methods for the different codelists.
    • Calls like delete_code(...) will raise NotImplementedError where the functionality is lacking.
  • Add to the Platform (without removing any existing behaviour):
    • an attribute like codelist, so that:
      • mp.codelist['region'] is the same as mp.get_regions(), etc.
    • A method add_code(...) with the same signature as Backend.set_code().

This should be addressed after #264 is completed and merged.

@khaeru khaeru added the enh New features & functionality label Mar 5, 2020
@khaeru khaeru added this to the post-3.0 milestone Mar 21, 2020
@khaeru khaeru modified the milestones: post-3.0, 3.1 Jun 7, 2020
@khaeru
Copy link
Member Author

khaeru commented Aug 17, 2020

@khaeru khaeru modified the milestones: 3.1, 3.2 Aug 25, 2020
@khaeru khaeru removed this from the 3.2 milestone Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh New features & functionality
Projects
None yet
Development

No branches or pull requests

1 participant