When using the example from the docstring of .project.ssp.data.SSPUpdate:
...
Example
-------
>>> keys = SSPUpdate.add_tasks(
... computer,
... context,
... release="3.1",
... ssp_id="3",
... measure="GDP"
... model="IIASA GDP 2023",
... )
>>> result = computer.get(keys[0])
"""
the process errors out with:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Cell In[286], line 4
1 c = Computer()
3 context = Context()
----> 4 keys = SSPUpdate.add_tasks(
5 c,
6 context,
7 release="3.1",
8 ssp_id="2",
9 measure="GDP",
10 model="OECD ENV-Growth 2023", # "IIASA GDP 2023"
11 )
13 pd.Series(
14 c.get("gdp:n-y:message_ix_models.project.ssp.data.SSPUpdate+hist")
15 ).index.get_level_values("y").unique()
File ~/PycharmProjects/message-ix-models/message_ix_models/tools/exo_data.py:186, in ExoDataSource.add_tasks(cls, c, context, strict, *args, **kwargs)
146 """Add tasks to `c` to provide and transform the data.
147
148 The first returned key is :attr:`.key`, and will trigger the following tasks:
(...)
183 tuple of .Key
184 """
185 # Create an instance of `cls`
--> 186 source = cls(*args, **kwargs)
188 # Identify a context
189 context = context or c.graph.get("context")
File ~/PycharmProjects/message-ix-models/message_ix_models/project/ssp/data.py:253, in SSPUpdate.__init__(self, *args, **kwargs)
252 def __init__(self, *args, **kwargs) -> None:
--> 253 opt = self.options = self.Options.from_args(self, *args, **kwargs)
254 opt.handle_source("ICONICS:SSP(2024)")
256 # Identify input data path
File ~/PycharmProjects/message-ix-models/message_ix_models/tools/exo_data.py:94, in BaseOptions.from_args(cls, source_id, *args, **kwargs)
91 raise ValueError(f"source_id == {source_id!r} != {kwargs['source']!r}")
92 return cls(**kwargs["source_kw"])
---> 94 assert 0 == len(args)
95 return cls(**kwargs)
AssertionError:
This seems to be caused by providing context as a non-keyword argument.
.tools.exo_data.ExoDataSource.add_tasks() expects *args before context.
See function signature:
@classmethod
def add_tasks(
cls,
c: "Computer",
*args,
context: "Context | None" = None,
strict: bool = True,
**kwargs,
) -> tuple:
How to resolve this:
Update docstring usage example to:
...
Example
-------
>>> keys = SSPUpdate.add_tasks(
... computer,
... context=context,
... release="3.1",
... ssp_id="3",
... measure="GDP"
... model="IIASA GDP 2023",
... )
>>> result = computer.get(keys[0])
"""
MRE:
from message_ix_models.project.ssp.data import SSPUpdate
from message_ix_models import Context
from genno import Computer
c = Computer()
context = Context()
keys = SSPUpdate.add_tasks(
c,
context,
release="3.1",
ssp_id="2",
measure="GDP",
model="OECD ENV-Growth 2023",
)
When using the example from the docstring of
.project.ssp.data.SSPUpdate:the process errors out with:
This seems to be caused by providing
contextas a non-keyword argument..tools.exo_data.ExoDataSource.add_tasks()expects*argsbeforecontext.See function signature:
How to resolve this:
Update docstring usage example to:
MRE: