Skip to content

Commit

Permalink
Use CaseGroup/CaseName to refer to hydsim cases (#399)
Browse files Browse the repository at this point in the history
`CaseGroup/CaseName` is established syntax used in various UIs, Optimal
Gateway, and Automation Framework. As discussed in
Volue/energy-sim#742 (comment).

There's an argument for more user friendly error handling here, but I
think this is API compatible with a future improvement, and I want to
get this API break done ASAP. For now you'll get a `ValueError` if the
split doesn't split.

Closes #398.
  • Loading branch information
erny-powel authored Jan 22, 2024
1 parent ea7e2df commit b55501e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/volue/mesh/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ def update_rating_curve_versions(
def run_simulation(
self,
model: str,
case_group: str,
case: str,
start_time: datetime,
end_time: datetime,
Expand All @@ -390,7 +389,9 @@ def run_simulation(
if start_time is None or end_time is None:
raise TypeError("start_time and end_time must both have a value")

simulation = f"Model/{model}/{case_group}.has_OptimisationCases/{case}.has_OptimisationParameters/Optimal.has_HydroSimulation/HydroSimulation"
case_group, case_name = case.split("/", maxsplit=1)

simulation = f"Model/{model}/{case_group}.has_OptimisationCases/{case_name}.has_OptimisationParameters/Optimal.has_HydroSimulation/HydroSimulation"

request = core_pb2.SimulationRequest(
session_id=_to_proto_guid(self.session_id),
Expand Down
2 changes: 1 addition & 1 deletion src/volue/mesh/examples/run_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def main(address, port, root_pem_certificate):

try:
for response in session.run_simulation(
"Mesh", "Cases", "Demo", start_time, end_time, None, 0, False
"Mesh", "Cases/Demo", start_time, end_time, None, 0, False
):
pass
print("done")
Expand Down

0 comments on commit b55501e

Please sign in to comment.