Skip to content

Commit

Permalink
Make layout json lines shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Jun 14, 2024
1 parent 6e38be6 commit 1e6e400
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re
import time
from typing import Any, Dict, Sequence, Set, Tuple

Expand Down Expand Up @@ -325,6 +326,6 @@ def set_layout(self, value):
else:
self._json_layout.pop(name, "")
if self._json_layout != old_json_layout:
self._client.set_table(
"*METADATA", "LAYOUT", [json.dumps(self._json_layout)]
)
# Custom encoding so the lines aren't too long and there aren't too many of them
lines = re.split(r'(?<=,) (?!"y")', json.dumps(self._json_layout))
self._client.set_table("*METADATA", "LAYOUT", lines)
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ def test_layout(self):
[
(
"*METADATA.LAYOUT",
'{"COUNTER": {"x": 1.2, "y": 2.3}, "HDF": {"x": 3.5, "y": 4.1}}',
[
'{"COUNTER": {"x": 1.2, "y": 2.3},',
'"HDF": {"x": 3.5, "y": 4.1}}',
],
)
]
)
Expand All @@ -287,8 +290,8 @@ def test_layout(self):
"*METADATA",
"LAYOUT",
[
'{"COUNTER": {"x": 1.2, "y": 2.3},'
' "HDF": {"x": 3.5, "y": 4.1},'
' "TTLIN1": {"x": 0.0, "y": 5.6}}'
'{"COUNTER": {"x": 1.2, "y": 2.3},',
'"HDF": {"x": 3.5, "y": 4.1},',
'"TTLIN1": {"x": 0.0, "y": 5.6}}',
],
)

0 comments on commit 1e6e400

Please sign in to comment.