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

Ensure MESSAGE.enforce() runs for MESSAGE_MACRO #613

Merged
merged 4 commits into from
May 25, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ jobs:
# Also install type stubs and full packages that provide type hints
run: |
pip install mypy genno sphinx types-pkg_resources types-requests types-PyYAML
mypy .
mypy --show-error-codes .
4 changes: 2 additions & 2 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Test MESSAGEix-GLOBIOM scenarios

on:
# Uncomment these two lines for debugging, but leave them commented on 'main'
# pull_request:
# branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# 05:00 UTC = 06:00 CET = 07:00 CEST
- cron: "0 5 * * *"
Expand Down
7 changes: 2 additions & 5 deletions message_ix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ def initialize(cls, scenario):
@staticmethod
def enforce(scenario):
"""Enforce data consistency in `scenario`."""
# Implemented in MESSAGE sub-class, below
# No-op; implemented in MESSAGE sub-class, below
# TODO make this an optional method of the ixmp.model.base.Model abstract class
pass

def __init__(self, name=None, **model_options):
# Update the default options with any user-provided options
Expand Down Expand Up @@ -410,8 +409,6 @@ def enforce(scenario):

if existing.equals(expected):
continue # Contents are as expected; do nothing
# else:
# scenario.add_set(set_name, expected)

# Not consistent; empty and then re-populate the set
with scenario.transact(f"Enforce consistency of {set_name} and {par_name}"):
Expand Down Expand Up @@ -452,7 +449,7 @@ def initialize(cls, scenario, with_data=False):
cls.initialize_items(scenario, items)


class MESSAGE_MACRO(MACRO):
class MESSAGE_MACRO(MESSAGE, MACRO):
"""Model class for MESSAGE_MACRO."""

name = "MESSAGE-MACRO"
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ module = [
]
ignore_missing_imports = true

# Workaround for iiasa/ixmp#449
# TODO remove once fixed upstream
[[tool.mypy.overrides]]
module = ["ixmp.core.scenario"]
ignore_errors = true

[tool.pytest.ini_options]
# Disable faulthandler plugin on Windows to prevent spurious console noise
addopts = """
Expand All @@ -112,4 +118,4 @@ addopts = """
markers = [
"nightly: Slow-running nightly tests of particular scenarios.",
"rmessageix: test of the message_ix R interface.",
]
]