Skip to content

Commit

Permalink
deploy: 0264e37
Browse files Browse the repository at this point in the history
  • Loading branch information
furkan-bilgin committed Dec 4, 2024
1 parent 77a99fe commit c4f69dd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
14 changes: 13 additions & 1 deletion daq/jobs/handle_stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,16 @@ <h2 class="section-title" id="header-classes">Classes</h2>

# Combine remote stats from all supervisors
remote_stats_combined = defaultdict(lambda: SupervisorRemoteStats())
for _, remote_stats_dict in self._remote_stats.items():
if (
self._supervisor_config
and self._supervisor_config.supervisor_id in self._remote_stats
):
for supervisor_id, remote_stats in self._remote_stats[
self._supervisor_config.supervisor_id
].items():
remote_stats_combined[supervisor_id] = remote_stats

for remote_stats_dict in self._remote_stats.values():
# For each remote stats dict, combine the values
for (
supervisor_id,
Expand All @@ -165,7 +174,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
remote_stats_dict_serialized = msgspec.structs.asdict(
remote_stats_dict_serialized_item
)
# Set each value
for item, value in remote_stats_dict_serialized.items():
if value == 0 or not value:
continue
setattr(remote_stats_combined[supervisor_id], item, value)

for supervisor_id, remote_stats in remote_stats_combined.items():
Expand Down
17 changes: 13 additions & 4 deletions daq/jobs/remote.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,23 @@ <h2 id="attributes">Attributes</h2>
if message.remote_config.remote_disable:
return True

self._send_remote_message(message)
return True

def _send_remote_message(self, message: DAQJobMessage):
if self._zmq_pub is None:
return

remote_topic = message.remote_config.remote_topic or DEFAULT_REMOTE_TOPIC
remote_topic = remote_topic.encode()
remote_topic_bytes = remote_topic.encode()
packed_message = self._pack_message(message)
self._zmq_pub.send_multipart([remote_topic, packed_message])
self._zmq_pub.send_multipart([remote_topic_bytes, packed_message])

# Update remote stats
if self._supervisor_config:
self._remote_stats[
self._supervisor_config.supervisor_id
].update_message_out_stats(len(packed_message) + len(remote_topic))
].update_message_out_stats(len(packed_message) + len(remote_topic_bytes))

self._logger.debug(
f&#34;Sent message &#39;{type(message).__name__}&#39; to topic &#39;{remote_topic}&#39;&#34;
Expand Down Expand Up @@ -319,7 +326,9 @@ <h2 id="attributes">Attributes</h2>
return res

def _send_remote_stats_message(self):
self._put_message_out(DAQJobMessageStatsRemote(dict(self._remote_stats)))
msg = DAQJobMessageStatsRemote(dict(self._remote_stats))
self._send_remote_message(msg)
self._put_message_out(msg)

def __del__(self):
&#34;&#34;&#34;
Expand Down

0 comments on commit c4f69dd

Please sign in to comment.