Skip to content

Commit

Permalink
21862: Updates to use new load/store API changes in Amalgam
Browse files Browse the repository at this point in the history
  • Loading branch information
howsohazard committed Oct 16, 2024
1 parent 81e4a4c commit 0d79078
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
18 changes: 5 additions & 13 deletions howso/direct/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _auto_persist_trainee(self, trainee_id: str):
if trainee.persistence == 'always':
self.amlg.store_entity(
handle=trainee_id,
amlg_path=self.resolve_trainee_filepath(trainee_id)
file_path=self.resolve_trainee_filepath(trainee_id)
)
except KeyError:
# Trainee not cached, ignore
Expand All @@ -429,11 +429,7 @@ def _initialize_trainee(self, trainee_id: str):
"""Create a new Amalgam entity."""
status = self.amlg.load_entity(
handle=trainee_id,
amlg_path=str(self._howso_absolute_path),
persist=False,
load_contained=True,
escape_filename=False,
escape_contained_filenames=False
file_path=str(self._howso_absolute_path)
)
if not status.loaded:
raise HowsoError(
Expand Down Expand Up @@ -1281,11 +1277,7 @@ def acquire_trainee_resources(
f'Trainee not found. No Trainee file exists at: "{filepath}"', code="not_found")
status = self.amlg.load_entity(
handle=trainee_id,
amlg_path=filepath,
persist=False,
load_contained=True,
escape_filename=False,
escape_contained_filenames=False,
file_path=filepath
)
if not status.loaded:
raise HowsoError(
Expand Down Expand Up @@ -1320,7 +1312,7 @@ def release_trainee_resources(self, trainee_id: str):
# Persist on unload
self.amlg.store_entity(
handle=trainee_id,
amlg_path=self.resolve_trainee_filepath(trainee_id)
file_path=self.resolve_trainee_filepath(trainee_id)
)
elif trainee.persistence == "never":
raise HowsoError(
Expand Down Expand Up @@ -1363,7 +1355,7 @@ def persist_trainee(self, trainee_id: str):

self.amlg.store_entity(
handle=trainee_id,
amlg_path=self.resolve_trainee_filepath(trainee_id)
file_path=self.resolve_trainee_filepath(trainee_id)
)

def begin_session(self, name: str | None = "default", metadata: t.Optional[Mapping] = None) -> Session:
Expand Down
8 changes: 2 additions & 6 deletions howso/engine/trainee.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def save(self, file_path: t.Optional[PathLike] = None):
if self.id:
self.client.amlg.store_entity(
handle=self.id,
amlg_path=self.client.resolve_trainee_filepath(file_name, filepath=file_path)
file_path=self.client.resolve_trainee_filepath(file_name, filepath=file_path)
)
else:
raise ValueError("Trainee ID is needed for saving.")
Expand Down Expand Up @@ -3939,11 +3939,7 @@ def load_trainee(

status = client.amlg.load_entity(
handle=trainee_id,
amlg_path=str(file_path),
persist=False,
load_contained=True,
escape_filename=False,
escape_contained_filenames=False,
file_path=str(file_path)
)
if not status.loaded:
raise HowsoError(f"Trainee from file '{file_path}' not found.")
Expand Down

0 comments on commit 0d79078

Please sign in to comment.