Skip to content

Commit

Permalink
refactor(Importer): refactor post_run internal steps
Browse files Browse the repository at this point in the history
  • Loading branch information
imhuwq committed Mar 12, 2024
1 parent 3ad9706 commit 10c1939
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deepdataspace/io/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ def post_run(self):
"""
A post-run hook for subclass importers.
"""
logger.info(f"Add cover to dataset [{self.dataset.name}]@[{self.dataset.id}]")
self.dataset.add_cover()
DataSet.update_one({"id": self.dataset.id}, {"status": DatasetStatus.Ready})
self.dataset = DataSet.find_one({"id": self.dataset.id})

logger.info(f"Add indices to dataset [{self.dataset.name}]@[{self.dataset.id}]")
dataset_id = self.dataset.id
Image(dataset_id).get_collection().create_index([
("objects.category_id", 1),
Expand All @@ -340,6 +340,10 @@ def post_run(self):
("idx", 1)
])

logger.info(f"Set status ready for dataset [{self.dataset.name}]@[{self.dataset.id}]")
DataSet.update_one({"id": self.dataset.id}, {"status": DatasetStatus.Ready})
self.dataset = DataSet.find_one({"id": self.dataset.id})

def on_error(self, err: Exception):
"""
A hook to handle error.
Expand Down

0 comments on commit 10c1939

Please sign in to comment.