gridappsd-python 2024.6.0__tar.gz → 2024.8.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/PKG-INFO +1 -1
  2. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/difference_builder.py +11 -7
  3. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/topics.py +24 -15
  4. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/pyproject.toml +1 -1
  5. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/README.md +0 -0
  6. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/__init__.py +0 -0
  7. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/__main__.py +0 -0
  8. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/app_registration.py +0 -0
  9. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/docker_handler.py +0 -0
  10. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/goss.py +0 -0
  11. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/gridappsd.py +0 -0
  12. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/houses.py +0 -0
  13. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/json_extension.py +0 -0
  14. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/loghandler.py +0 -0
  15. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/register_app.py +0 -0
  16. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/simulation.py +0 -0
  17. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/timeseries.py +0 -0
  18. {gridappsd_python-2024.6.0 → gridappsd_python-2024.8.1a1}/gridappsd/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gridappsd-python
3
- Version: 2024.6.0
3
+ Version: 2024.8.1a1
4
4
  Summary: A GridAPPS-D Python Adapter
5
5
  Home-page: https://gridappsd.readthedocs.io
6
6
  License: BSD-3-Clause
@@ -42,19 +42,17 @@ import calendar
42
42
  from uuid import uuid4
43
43
  import time
44
44
 
45
- import pytz
46
-
47
45
 
48
46
  class DifferenceBuilder(object):
49
47
  """ Automates the building of forward and reverse cim differences
50
48
 
51
49
  """
52
50
 
53
- def __init__(self, simulation_id):
51
+ def __init__(self, simulation_id: str | int | None = None):
54
52
 
55
53
  self._simulation_id = simulation_id
56
- self._forward = []
57
- self._reverse = []
54
+ self._forward: list[dict] = []
55
+ self._reverse: list[dict] = []
58
56
 
59
57
  def add_difference(self, object_id, attribute, forward_value, reverse_value):
60
58
  """ Add forward and reverse unit for an object attribute.
@@ -67,16 +65,22 @@ class DifferenceBuilder(object):
67
65
  self._reverse.append(reverse)
68
66
 
69
67
  def clear(self):
68
+ """ Clear the forward and reverse differences """
70
69
  self._forward = []
71
70
  self._reverse = []
72
71
 
73
72
  def get_message(self, epoch=None):
73
+ """ Get the message to send to the GOSS message bus
74
+
75
+ :param epoch: The epoch time to use for the message timestamp. If None, the current time (GMT) is used.
76
+ """
74
77
  if epoch is None:
75
78
  epoch = calendar.timegm(time.gmtime())
76
79
  msg = dict(command="update",
77
- input=dict(simulation_id=self._simulation_id,
78
- message=dict(timestamp=epoch,
80
+ input=dict(message=dict(timestamp=epoch,
79
81
  difference_mrid=str(uuid4()),
80
82
  reverse_differences=self._reverse,
81
83
  forward_differences=self._forward)))
84
+ if self._simulation_id is not None:
85
+ msg['input']['simulation_id'] = self._simulation_id
82
86
  return msg.copy()
@@ -80,7 +80,7 @@ def platform_log_topic():
80
80
  return "/topic/{}.{}".format(BASE_TOPIC_PREFIX, "platform.log")
81
81
 
82
82
 
83
- def service_input_topic(service_id, simulation_id):
83
+ def service_input_topic(service_id: str, simulation_id: int | str | None = None):
84
84
  """ Utility method for getting the input topic for a specific service.
85
85
 
86
86
  The service id should be the registered service with the platform. One
@@ -95,11 +95,14 @@ def service_input_topic(service_id, simulation_id):
95
95
  :return:
96
96
  """
97
97
  assert service_id, "service_id cannot be empty"
98
- assert simulation_id, "simulation_id cannot be empty"
99
- return "{}.{}.{}.input".format(BASE_SIMULATION_TOPIC, service_id, simulation_id)
100
98
 
99
+ if simulation_id:
100
+ return f"{BASE_SIMULATION_TOPIC}.{service_id}.{simulation_id}.input"
101
101
 
102
- def service_output_topic(service_id, simulation_id):
102
+ return f"{BASE_SIMULATION_TOPIC}.{service_id}.input"
103
+
104
+
105
+ def service_output_topic(service_id: str, simulation_id: int | str | None = None):
103
106
  """ Utility method for getting the output topic for a specific service.
104
107
 
105
108
  The service id should be the registered service with the platform. One
@@ -114,11 +117,14 @@ def service_output_topic(service_id, simulation_id):
114
117
  :return:str: Topic to subscribe to for service specific output.
115
118
  """
116
119
  assert service_id, "Service id cannot be empty"
117
- assert simulation_id, "Simulation id cannot be empty"
118
- return "{}.{}.{}.output".format(BASE_SIMULATION_TOPIC, service_id, simulation_id)
119
120
 
121
+ if simulation_id:
122
+ return f"{BASE_SIMULATION_TOPIC}.{service_id}.{simulation_id}.output"
123
+
124
+ return f"{BASE_SIMULATION_TOPIC}.{service_id}.output"
120
125
 
121
- def application_input_topic(application_id, simulation_id):
126
+
127
+ def application_input_topic(application_id: str, simulation_id: int | str | None = None):
122
128
  """ Utility method for getting the input topic for a specific application.
123
129
 
124
130
  The application_id should be the registered service with the platform. One
@@ -130,11 +136,14 @@ def application_input_topic(application_id, simulation_id):
130
136
  :return:str: Topic to publish to for a specific application.
131
137
  """
132
138
  assert application_id, "application_id cannot be empty"
133
- assert simulation_id, "simulation_id cannot be empty"
134
- return "{}.{}.{}.input".format(BASE_SIMULATION_TOPIC, application_id, simulation_id)
135
139
 
140
+ if simulation_id:
141
+ return f"{BASE_SIMULATION_TOPIC}.{application_id}.{simulation_id}.input"
142
+
143
+ return f"{BASE_TOPIC}.{application_id}.input"
136
144
 
137
- def application_output_topic(application_id, simulation_id):
145
+
146
+ def application_output_topic(application_id: str, simulation_id: int | str | None = None):
138
147
  """ Utility method for getting the output topic for a specific application.
139
148
 
140
149
  The application_id should be the registered service with the platform. One
@@ -146,11 +155,11 @@ def application_output_topic(application_id, simulation_id):
146
155
  :return: str: Topic to subscribe to for application specific output.
147
156
  """
148
157
  assert application_id, "application_id cannot be empty"
149
- #assert simulation_id, "simulation_id cannot be empty"
150
- if simulation_id is None:
151
- return "{}.{}.output".format(BASE_TOPIC, application_id)
152
- else:
153
- return "{}.{}.{}.output".format(BASE_SIMULATION_TOPIC, application_id, simulation_id)
158
+
159
+ if simulation_id:
160
+ return f"{BASE_SIMULATION_TOPIC}.{application_id}.{simulation_id}.output"
161
+
162
+ return f"{BASE_TOPIC}.{application_id}.output"
154
163
 
155
164
 
156
165
  def simulation_output_topic(simulation_id):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gridappsd-python"
3
- version = "2024.6.0"
3
+ version = "2024.8.1a1"
4
4
  description = "A GridAPPS-D Python Adapter"
5
5
  authors = [
6
6
  "C. Allwardt <3979063+craig8@users.noreply.github.com>",