Skip to content

Commit

Permalink
Fix/add persist log (#192)
Browse files Browse the repository at this point in the history
* feat: add log when persist model

* build: update version to 2.1.2
  • Loading branch information
phamhoangtuan authored Jun 29, 2023
1 parent 892a8dc commit 312a6eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions h1st/model/repository/model_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ def persist(self, model, version=None):
# assert isinstance(model, Model)
# TODO: use version format: v_20200714-1203
version = version or str(ulid.new())
logger.info(f"Persisting model {model} version {version}")

try:
# serialize a model to a temporary folder and then clean up later
Expand All @@ -420,21 +421,25 @@ def persist(self, model, version=None):

self._serder.serialize(model, serialized_dir)
_tar_create(tar_file, serialized_dir)
logger.info(f'Created tar file {tar_file} at {serialized_dir} for model {model} version {version}')

with open(tar_file, mode="rb") as f:
self._storage.set_bytes(
self._get_key(model, version),
f.read(),
)
logger.info(f'Set bytes {self._get_key(model, version)} to storage from {tar_file} - {serialized_dir}')

self._storage.set_obj(
self._get_key(model, "latest"),
version,
)
logger.info(f'Set obj {self._get_key(model, "latest")} to storage from {tar_file} - {serialized_dir}')

model.version = version
finally:
dir_util.remove_tree(tmpdir)
logger.info(f'Removed temp dir {tmpdir}')

return version

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "h1st"
version = "2.1.1"
version = "2.1.2"
description = "Human-First AI (H1st)"
authors = ["Aitomatic, Inc. <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 312a6eb

Please sign in to comment.