objectstore: snapshot takes Object not path
Refactor the `ObjectStore.snapshot` method to take an `Object` not a plain filesystem tree, so the latter is more encapsulated from the ObjectStore user (e.g. the pipeline) and prepares a unified code-path for `snapshot` and `commit` in the future.
This commit is contained in:
parent
5deb1be514
commit
25b3807a5b
3 changed files with 10 additions and 10 deletions
|
|
@ -160,22 +160,22 @@ class ObjectStore:
|
|||
# left to do is to commit it to the object store
|
||||
self.commit(obj, object_id)
|
||||
|
||||
def snapshot(self, object_path: str, object_id: str) -> str:
|
||||
"""Commit `object_path` to store and ref it as `object_id`
|
||||
def snapshot(self, obj: str, object_id: str) -> str:
|
||||
"""Commit `obj` to store and ref it as `object_id`
|
||||
|
||||
Create a snapshot of `object_path` and store it via its
|
||||
content hash in the object directory; additionally
|
||||
Create a snapshot of the object `obj` and store it via
|
||||
its content hash in the object directory; additionally
|
||||
create a new reference to it via `object_id` in the
|
||||
reference directory.
|
||||
|
||||
Returns: The treesum of the snapshot
|
||||
"""
|
||||
# Make a new temporary directory and Object; initialize
|
||||
# the latter with the contents of `object_path` and commit
|
||||
# the latter with the contents of `obj.path` and commit
|
||||
# it to the store
|
||||
with Object(self) as obj:
|
||||
obj.init(object_path)
|
||||
return self.commit(obj, object_id)
|
||||
with Object(self) as tmp:
|
||||
tmp.init(obj.path)
|
||||
return self.commit(tmp, object_id)
|
||||
|
||||
def commit(self, obj: Object, object_id: str) -> str:
|
||||
"""Commits a Object to the object store
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ class Pipeline:
|
|||
var=store,
|
||||
secrets=secrets)
|
||||
if stage.checkpoint:
|
||||
object_store.snapshot(tree.path, stage.id)
|
||||
object_store.snapshot(tree, stage.id)
|
||||
results["stages"].append(r.as_dict())
|
||||
except BuildError as err:
|
||||
results["stages"].append(err.as_dict())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue