-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from NREL/feature/version_demo
Feature/version demo
- Loading branch information
Showing
3 changed files
with
133,134 additions
and
5,416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.