Skip to content

Commit

Permalink
AnyLogic: patch cloud client
Browse files Browse the repository at this point in the history
AnyLogic: patch cloud client
  • Loading branch information
thesethtruth authored Apr 26, 2023
2 parents 23c1d1f + 5cfb8b6 commit 5ad23b8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/holon/services/cloudclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from anylogiccloudclient.client.cloud_client import CloudClient as ALCloudClient
from anylogiccloudclient.client.cloud_client import Inputs
from anylogiccloudclient.client.single_run_outputs import SingleRunOutputs
from anylogiccloudclient.data.model import Model

from holon.models.config import AnylogicCloudInput
from holon.models.scenario import Scenario
Expand All @@ -25,7 +26,7 @@ def __init__(
# value attributes
self.url = config.url
self.scenario = scenario
self.client = ALCloudClient(config.api_key, config.url)
self.client = PatchedAnyLogicCloudClient(config.api_key, config.url)

# method attributes
self.model_version = self._get_model_version(
Expand Down Expand Up @@ -93,3 +94,18 @@ def outputs(self, anylogic_outputs: SingleRunOutputs):
co.internal_key: json.loads(anylogic_outputs.value(co.anylogic_key))
for co in self.config.anylogic_cloud_output.all()
}


class PatchedAnyLogicCloudClient(ALCloudClient):
"""Patched version of the AnyLogic Cloud Client.
On April 25th 2023 AnyLogic published a different variant of the v8.5.0 client.
The method get_model_by_name was changed from GET to POST
and the "name" parameter was moved from the path to the request body.
This did not work with our private cloud.
"""

def get_model_by_name(self, name: str) -> Model:
response = self._http_client.api_request("models/name/" + name)
model = Model.from_json(response)
return model

0 comments on commit 5ad23b8

Please sign in to comment.