Skip to content

Commit

Permalink
Add data-init component
Browse files Browse the repository at this point in the history
  • Loading branch information
blythed committed Jul 4, 2024
1 parent 04f8570 commit 4f57a50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion superduperdb/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Component(Leaf):
set_post_init: t.ClassVar[t.Sequence] = ('version',)
changed: t.ClassVar[set] = set([])
plugins: t.Optional[t.List["Plugin"]] = None

upstream: t.Optional[t.List["Component"]] = None
artifacts: dc.InitVar[t.Optional[t.Dict]] = None

@property
Expand Down
10 changes: 10 additions & 0 deletions superduperdb/components/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,13 @@ def __str__(self):
return f'Dataset(identifier={self.identifier}, select={self.select})'

__repr__ = __str__


class DataInit(Component):
data: t.List[t.Dict]
table: str

def post_create(self, db: Datalayer) -> None:
super().post_create(db)
self.init()
db[self.table].insert(self.data).execute()

0 comments on commit 4f57a50

Please sign in to comment.