Skip to content

Commit cda151d

Browse files
committed
Add .edits.PASTA exogenous data source
1 parent 5270640 commit cda151d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

message_ix_models/project/edits/__init__.py

+16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from sdmx.model.common import Codelist
1111
from sdmx.model.v21 import DataStructureDefinition
1212

13+
from message_ix_models.tools.exo_data import ExoDataSource
1314
from message_ix_models.util import local_data_path
1415

1516
if TYPE_CHECKING:
@@ -156,6 +157,21 @@ def _transform(value: Any) -> str:
156157
}
157158

158159

160+
class PASTA(ExoDataSource):
161+
"""Retrieve and process PASTA data for use in MESSAGEix-Transport."""
162+
163+
id = "PASTA"
164+
165+
def __init__(self, source, source_kw):
166+
if not source == self.id:
167+
raise ValueError(source)
168+
169+
self.raise_on_extra_kw(source_kw)
170+
171+
def __call__(self):
172+
raise NotImplementedError
173+
174+
159175
def gen_demand(context: "Context") -> None:
160176
"""Generate MESSAGEix-Transport demand data from PASTA.
161177

message_ix_models/tests/project/test_edits.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from message_ix_models.project.edits import gen_demand, pasta_native_to_sdmx
5+
from message_ix_models.project.edits import PASTA, gen_demand, pasta_native_to_sdmx
66
from message_ix_models.util import package_data_path
77

88

@@ -15,6 +15,11 @@ def test_pasta_data(test_context):
1515
copyfile(package_data_path("test", *parts), target)
1616

1717

18+
class TestPASTA:
19+
def test_init(self) -> None:
20+
PASTA("PASTA", {})
21+
22+
1823
def test_pasta_native_to_sdmx(test_context, test_pasta_data):
1924
pasta_native_to_sdmx()
2025

0 commit comments

Comments
 (0)