Skip to content

Commit

Permalink
Better versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeee committed Jul 18, 2024
1 parent 48613c3 commit c19d068
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
11 changes: 9 additions & 2 deletions buildstockbatch/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,14 +819,21 @@ def validate_resstock_or_comstock_version(project_file):
raise ValidationError(val_err)
wg_version = cfg["workflow_generator"].get("version", "latest")
wg_type = cfg["workflow_generator"].get("type")
res_version = workflow_generator.version2info[wg_type][wg_version]["resstock_version"]
min_res_version = workflow_generator.version2info[wg_type][wg_version]["minimum_resstock_version"]
max_res_version = workflow_generator.version2info[wg_type][wg_version]["maximum_resstock_version"]
ResStockVersion = semver.Version.parse(versions["ResStock"])
if ResStockVersion < semver.Version.parse(res_version):
if ResStockVersion < semver.Version.parse(min_res_version):
val_err = (
f"ResStock version {ResStockVersion} or above is required"
f" for ResStock workflow generator version {wg_version}."
)
raise ValidationError(val_err)
if max_res_version and ResStockVersion > semver.Version.parse(max_res_version):
val_err = (
f"ResStock version {ResStockVersion} or below is required"
f" for ResStock workflow generator version {wg_version}."
)
raise ValidationError(val_err)

return True

Expand Down
35 changes: 32 additions & 3 deletions buildstockbatch/test/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,11 @@ def test_validate_workflow_gen_version_pass(mocker):
"buildstockbatch.base.workflow_generator.version2info",
{
"residential_hpxml": {
"latest": {"version": "2024.07.19", "resstock_version": "0.0.0"},
"latest": {
"version": "2024.07.19",
"minimum_resstock_version": "0.0.0",
"maximum_resstock_version": None,
},
}
},
)
Expand All @@ -407,14 +411,39 @@ def test_validate_workflow_gen_version_pass(mocker):


@resstock_required
def test_validate_workflow_gen_version_fail(mocker):
def test_validate_workflow_gen_version_fail_min(mocker):
# Set the version to a 'really old' one so we trigger the version check error
mocker.patch("buildstockbatch.base.bsb_version", "3000.0.0")
mocker.patch(
"buildstockbatch.base.workflow_generator.version2info",
{
"residential_hpxml": {
"latest": {"version": "2024.07.19", "resstock_version": "3000.0.0"},
"latest": {
"version": "2024.07.19",
"minimum_resstock_version": "3000.0.0",
"maximum_resstock_version": None,
},
}
},
)
proj_filename = resstock_directory / "project_national" / "national_upgrades.yml"
with pytest.raises(ValidationError):
BuildStockBatchBase.validate_resstock_or_comstock_version(str(proj_filename))


@resstock_required
def test_validate_workflow_gen_version_fail_max(mocker):
# Set the version to a 'really old' one so we trigger the version check error
mocker.patch("buildstockbatch.base.bsb_version", "3000.0.0")
mocker.patch(
"buildstockbatch.base.workflow_generator.version2info",
{
"residential_hpxml": {
"latest": {
"version": "2024.07.19",
"minimum_resstock_version": "0.0.0",
"maximum_resstock_version": "0.0.0",
},
}
},
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
__version__ = "2024.07.19"
version_info = {
"version": __version__,
"resstock_version": "3.2.0",
"minimum_resstock_version": "3.2.0",
"maximum_resstock_version": None,
"version_description": """
Version information for the residential workflow generator.
This version is compatible with ResStock v3.4.0.
This version is compatible with ResStock v3.2.0 and later.
In this version, the UpgradeCosts measure is converted to a regular measure
and is run early in the workflow.
""",
Expand Down
6 changes: 3 additions & 3 deletions docs/workflow_generators/residential_hpxml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Arguments
Build Existing Model Defaults
.............................

.. include:: ../../buildstockbatch/workflow_generator/residential/residential_hpxml_defaults.py
.. include:: ../../buildstockbatch/workflow_generator/residential/latest/residential_hpxml_defaults.py
:code: python
:start-after: BuildExistingModel": {
:end-before: }
Expand All @@ -156,7 +156,7 @@ Build Existing Model Defaults
Simulation Output Report Defaults
..................................

.. include:: ../../buildstockbatch/workflow_generator/residential/residential_hpxml_defaults.py
.. include:: ../../buildstockbatch/workflow_generator/residential/latest/residential_hpxml_defaults.py
:code: python
:start-after: ReportSimulationOutput": {
:end-before: }
Expand All @@ -166,7 +166,7 @@ Simulation Output Report Defaults
Server Directory Cleanup Defaults
.................................

.. include:: ../../buildstockbatch/workflow_generator/residential/residential_hpxml_defaults.py
.. include:: ../../buildstockbatch/workflow_generator/residential/latest/residential_hpxml_defaults.py
:code: python
:start-after: ServerDirectoryCleanup": {
:end-before: }

0 comments on commit c19d068

Please sign in to comment.