Skip to content

[RFC/Design]: Support for multiple datastores #652

Description

@leifdenby

I have been thinking about how to generalise #635 to allow for using sources of data that would describe say multiple point-wise observations and/or regular gridded data. Although I am not suggesting that we alter #635 as-is, with which the will be support for a datastore (which used both for input and output of the model) and datastore_boundary (only used for input), I thought it might be useful to think about how that work could be evolved on down the line. With #625 Neural-LAM configuration will assume a fixed set of datastore roles, such as a main datastore and optionally a boundary datastore. This does not scale well to configurations that combine multiple data sources, for example regional reanalysis, global boundary data, synoptic observations, or satellite-derived inputs.

The aim is to replace role-specific datastore config keys with a single datastores mapping. Each datastore should be named by the user and explicitly declare how it is used by the model.

Proposal

Introduce a datastores dictionary in NeuralLAMConfig, keyed by datastore name. Each entry should contain the datastore selection fields plus a new use section defining which data categories are used as model inputs and outputs.

Suggested config shape:

datastores:
  danra:
    use:
      input: [state, static, forcing]
      output: [state]
    kind: mdp
    config_path: danra.datastore.yaml

  era5:
    use:
      input: [state, forcing]
      output: []
    kind: mdp
    config_path: era5.datastore.yaml

Suggested dataclasses:

@dataclasses.dataclass
class DatastoreUse:
    input: list[str]
    output: list[str]
@dataclasses.dataclass
class DatastoreSelection:
    use: DatastoreUse
    kind: str
    config_path: str
@dataclasses.dataclass
class NeuralLAMConfig(dataclass_wizard.JSONWizard, dataclass_wizard.YAMLWizard):
    datastores: Dict[str, DatastoreSelection]
    training: TrainingConfig = dataclasses.field(default_factory=TrainingConfig)

Motivation

This makes datastore roles explicit and extensible. The datastore name describes the data source, while use describes how the data source contributes to the model, and the graph connectivity that will be required to be made.

This supports configurations such as:

# LAM trained on regional reanalysis with global boundary data
datastores:
  danra:
    use:
      input: [state, static, forcing]
      output: [state]
    kind: mdp
    config_path: danra.datastore.yaml

  era5:
    use:
      input: [state, forcing]
      output: []
    kind: mdp
    config_path: era5.datastore.yaml
# LAM trained with regional reanalysis, global reanalysis, and synoptic observations
datastores:
  danra:
    use:
      input: [state, static, forcing]
      output: [state]
    kind: mdp
    config_path: danra.datastore.yaml

  synop:
    use:
      input: [forcing]
      output: []
    kind: mdp
    config_path: synop.datastore.yaml

  era5:
    use:
      input: [state, forcing]
      output: []
    kind: mdp
    config_path: era5.datastore.yaml
# Global reanalysis with satellite-derived inputs
datastores:
  era5:
    use:
      input: [state, static, forcing]
      output: [state]
    kind: mdp
    config_path: era5.datastore.yaml

  amsua:
    use:
      input: [forcing]
      output: []
    kind: mdp
    config_path: amsua.datastore.yaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions