Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 36 additions & 26 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@ jobs:
with:
ref: ${{ needs.check.outputs.ref }}

- name: Cache static data
uses: actions/cache@v4
with:
path: message-static-data
key: static-data-${{ matrix.os }}

- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: |
${{ secrets.MESSAGE_STATIC_DATA_PRIVATE_KEY }}

- name: Check out message-static-data
uses: actions/checkout@v4
with:
repository: iiasa/message-static-data
path: message-static-data
ssh-key: ${{ secrets.MESSAGE_STATIC_DATA_PRIVATE_KEY }}
lfs: true
# Only check out the following directories, in order to limit bandwith usage:
sparse-checkout: |
iea/eei
ssp

pytest:
needs: [ check, warm-lfs-cache ]

Expand Down Expand Up @@ -110,22 +133,11 @@ jobs:
with:
ref: ${{ needs.check.outputs.ref }}

- uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: |
${{ secrets.MESSAGE_STATIC_DATA_PRIVATE_KEY }}

- name: Check out message-static-data
uses: actions/checkout@v4
- name: Restore message-static-data from cache
uses: actions/cache/restore@v4
with:
repository: iiasa/message-static-data
path: message-static-data
ssh-key: ${{ secrets.MESSAGE_STATIC_DATA_PRIVATE_KEY }}
lfs: true
# Only check out the following directories, in order to limit bandwith usage:
sparse-checkout: |
iea/eei
ssp
key: static-data-${{ matrix.os }}

- name: Set up uv, Python
uses: astral-sh/setup-uv@v5
Expand Down Expand Up @@ -210,15 +222,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.check.outputs.ref }}
- uses: astral-sh/setup-uv@v5
with:
cache-dependency-glob: "**/pyproject.toml"
python-version: ${{ env.python-version }}
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.UV_PYTHON }}|${{ hashFiles('.pre-commit-config.yaml') }}
lookup-only: ${{ github.event_name == 'schedule' }} # Set 'true' to recreate cache
- run: uvx pre-commit run --all-files --color=always --show-diff-on-failure
with: { ref: "${{ needs.check.outputs.ref }}" }
- uses: astral-sh/setup-uv@v6
with: { enable-cache: true, python-version: "${{ env.python-version }}" }
- name: Clear and re-create the pre-commit environments
run: uvx pre-commit clean
if: github.event_name == 'schedule' # Comment this line to force clear
- run: |
uvx --with=pre-commit-uv \
pre-commit run \
--all-files --color=always --show-diff-on-failure --verbose
5 changes: 4 additions & 1 deletion message_ix_models/model/transport/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@
),
"gh-337": pytest.mark.xfail(
reason="Temporary, for https://github.com/iiasa/message-ix-models/pull/337."
" These tests fail as a result of "
" These tests fail as a result of "
"https://github.com/iiasa/message_ix/pull/924 and require updates to "
"constraint parameter values."
),
"gh-339": pytest.mark.xfail(
reason="Temporary, for https://github.com/iiasa/message-ix-models/pull/339."
),
},
testing.MARK,
)
Expand Down
3 changes: 2 additions & 1 deletion message_ix_models/tests/model/transport/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def quiet_genno(caplog):
@mark.parametrize(
"build",
(
True, # Run .transport.build.main()
pytest.param(True, marks=MARK["gh-339"]), # Run .transport.build.main()
False, # Use data from an Excel export
),
)
Expand Down Expand Up @@ -143,6 +143,7 @@ def test_simulated_solution(request, test_context, build, regions="R12", years="


@build.get_computer.minimum_version
@MARK["gh-339"]
@mark.usefixtures("quiet_genno")
@pytest.mark.parametrize(
"plot_name",
Expand Down
3 changes: 3 additions & 0 deletions message_ix_models/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
MutableParameterData = MutableMapping[str, pd.DataFrame]


# For sdmx1


class AnnotableArtefactArgs(TypedDict, total=False):
annotations: list[sdmx.model.common.BaseAnnotation]

Expand Down
13 changes: 10 additions & 3 deletions message_ix_models/util/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dataclasses import dataclass, field, fields, is_dataclass, replace
from hashlib import blake2s
from pathlib import Path
from typing import TYPE_CHECKING, Any, Hashable, Optional, Union
from typing import TYPE_CHECKING, Any, Hashable, Optional, Union, cast

import ixmp

Expand All @@ -14,6 +14,7 @@

if TYPE_CHECKING:
import message_ix
from ixmp.types import PlatformArgs

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -180,8 +181,11 @@ class Config:
#: Like :attr:`url`, used by e.g. :meth:`.clone_to_dest`.
dest: Optional[str] = None

# NB the below works around python/mypy#5723
#: Like :attr:`platform_info`, used by e.g. :meth:`.clone_to_dest`.
dest_platform: MutableMapping[str, str] = field(default_factory=dict)
dest_platform: "PlatformArgs" = field(
default_factory=lambda: cast("PlatformArgs", dict())
)

#: Like :attr:`scenario_info`, used by e.g. :meth:`.clone_to_dest`.
dest_scenario: MutableMapping[str, str] = field(default_factory=dict)
Expand All @@ -196,9 +200,12 @@ class Config:
#: configuration file.
local_data: Path = field(default_factory=_local_data_factory)

# NB the below works around python/mypy#5723
#: Keyword arguments—especially `name`—for the :class:`ixmp.Platform` constructor,
#: from the :program:`--platform` or :program:`--url` CLI option.
platform_info: MutableMapping[str, str] = field(default_factory=dict)
platform_info: "PlatformArgs" = field(
default_factory=lambda: cast("PlatformArgs", dict())
)

# Private reference to an ixmp.Platform
_mp: Optional["ixmp.Platform"] = None
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ migrate = [
]
report = ["plotnine", "xlsxwriter"]
tests = [
# For nbclient, thus nbformat
"ixmp[tests]",
"ixmp[tests]", # TODO Remove once message_ix[tests] depends on ixmp[tests]
"message-ix[tests]",
"message_ix_models[report,transport]",
"pytest",
"pytest-cov",
Expand Down