Skip to content

Commit 7f4d82c

Browse files
committed
Endpoint working for now, time to work on frontend viz
1 parent 4f67dc7 commit 7f4d82c

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

bridger/logging_utils/cache_entry_database.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,6 @@ def __init__(self, cache_entries: list[CacheEntry]):
1111
print(f"Initializing CacheEntryDatabase with {len(cache_entries)} entries")
1212
start_time = time.time()
1313

14-
# Debug info about the entries
15-
if cache_entries:
16-
print(f"First entry type: {type(cache_entries[0])}")
17-
print(f"First entry attributes: {dir(cache_entries[0])}")
18-
try:
19-
print(
20-
f"First entry state shape: {cache_entries[0].state_representative.shape}"
21-
)
22-
except Exception as e:
23-
print(f"Error getting state shape: {e}")
24-
2514
self.cache_entries = cache_entries
2615
end_time = time.time()
2716
print(
@@ -49,8 +38,11 @@ def get_top_n_by_sort_key(self, sort_key: "SortKey", n: int):
4938
print(f"Getting top {n} entries by {sort_key.key}")
5039
start_time = time.time()
5140
try:
52-
sorted_entries = self.sort_by_key(sort_key())
53-
result = sorted_entries[:n]
41+
self.sort_by_key(sort_key)
42+
result = [
43+
cache_entry.state_representative.tolist()
44+
for cache_entry in self.cache_entries[:n].copy()
45+
]
5446
end_time = time.time()
5547
print(f"Retrieved top {n} entries in {end_time - start_time:.2f} seconds")
5648
return result
@@ -94,4 +86,4 @@ def __init__(self):
9486

9587
class SampleCountSortKey(SortKey):
9688
def __init__(self):
97-
super().__init__("sample_count")
89+
super().__init__("sampled_count")

bridger/logging_utils/object_log_readers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def read_object_log(log_filepath: str):
3030
with open(log_filepath, "rb") as f:
3131
while True:
3232
try:
33-
print(f"This is the type: {type(f)}")
3433
buffer = pickle.load(f)
3534

3635
for element in buffer:
@@ -298,7 +297,6 @@ def __init__(self, dirname: str):
298297
for entry in _read_object_log(
299298
os.path.dirname(dirname), log_entry.STATE_NORMALIZED_LOG_ENTRY
300299
):
301-
print(f"")
302300
self._states[entry.id] = entry.object
303301

304302
# Store visited states sorted by visit count.

tools/web/sibyl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def go_explore_plot_data():
9292

9393
return {
9494
"states": [
95-
cache_entry.state_representative
95+
cache_entry.state_representative.tolist()
9696
for cache_entry in _CACHE_ENTRY_DATABASE.cache_entries
9797
],
9898
"trajectory_length": _CACHE_ENTRY_DATABASE.get_top_n_by_sort_key(
@@ -104,7 +104,7 @@ def go_explore_plot_data():
104104
"steps_since_led_to_something_new_reset_count": _CACHE_ENTRY_DATABASE.get_top_n_by_sort_key(
105105
StepsSinceLedToSomethingNewResetCountSortKey(), n
106106
),
107-
"sample_count": _CACHE_ENTRY_DATABASE.get_top_n_by_sort_key(
107+
"sampled_count": _CACHE_ENTRY_DATABASE.get_top_n_by_sort_key(
108108
SampleCountSortKey(), n
109109
),
110110
"visit_count": _CACHE_ENTRY_DATABASE.get_top_n_by_sort_key(

0 commit comments

Comments
 (0)