Skip to content

Commit

Permalink
fixing issue with deserializating logprob
Browse files Browse the repository at this point in the history
  • Loading branch information
sidnarayanan committed Dec 30, 2024
1 parent d63c2d0 commit ff5d6f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ldp/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
from collections.abc import Callable, Hashable, Iterable
from contextlib import suppress
from typing import Any, ClassVar, Self, cast
from uuid import UUID

Expand Down Expand Up @@ -121,7 +122,12 @@ def from_jsonl(cls, filename: str | os.PathLike) -> Self:
reader = iter(f)
traj = cls(traj_id=json.loads(next(reader)))
for json_line in reader:
traj.steps.append(Transition(**json.loads(json_line)))
data = json.loads(json_line)
# logprob may have been serialized, but cnanot be passed to
# OpResult, so remove it here.
with suppress(KeyError):
data["action"].pop("logprob")
traj.steps.append(Transition(**data))
return traj

def compute_discounted_returns(self, discount: float = 1.0) -> list[float]:
Expand Down

0 comments on commit ff5d6f9

Please sign in to comment.