Skip to content

Commit

Permalink
Merge pull request #52 from NREL/feature/version_demo
Browse files Browse the repository at this point in the history
Feature/version demo
  • Loading branch information
calbaker authored Apr 12, 2024
2 parents 3e9bdc9 + 3209e43 commit 87ac72c
Show file tree
Hide file tree
Showing 3 changed files with 133,134 additions and 5,416 deletions.
32 changes: 32 additions & 0 deletions python/altrios/demos/version_migration_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Demonstrates how to convert data between previous and current ALTRIOS release compatibility.
"""
# %%

import json
from typing import Tuple

import altrios as alt

def migrate_network() -> Tuple[alt.Network, alt.Network]:
old_network_path = alt.resources_root() / "networks/Taconite_v0.1.6.yaml"
new_network_path = alt.resources_root() / "networks/Taconite.yaml"

network_from_old = alt.Network.from_file(old_network_path)
network_from_new = alt.Network.from_file(new_network_path)

# `network_from_old` could be used to overwrite the file in the new format with
# ```
# network_from_old.to_file(
# alt.resources_root() / "networks/Taconite.yaml"
# )
# ```

# TODO: change this to direct comparison after figuring out how to enable that via pyo3
assert json.loads(network_from_new.to_json()
) == json.loads(network_from_old.to_json())

return (network_from_old, network_from_new)

network_from_old, network_from_new = migrate_network()
Loading

0 comments on commit 87ac72c

Please sign in to comment.