Skip to content

Commit

Permalink
feat(deepen): add get annotation status script (#186)
Browse files Browse the repository at this point in the history
* feat(deepen): add get_annotation_status

Signed-off-by: Shunsuke Miura <[email protected]>

* update

Signed-off-by: Shunsuke Miura <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Shunsuke Miura <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
miursh and pre-commit-ci[bot] authored Dec 30, 2024
1 parent 269f67e commit 06a3b53
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
44 changes: 44 additions & 0 deletions perception_dataset/deepen/get_annotation_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import argparse
from datetime import datetime

import yaml

from perception_dataset.deepen.import_labels import AnnotationNotFoundException, get_dataset_status
from perception_dataset.utils.logger import configure_logger

logger = configure_logger(modname=__name__)


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--config",
type=str,
default="config/import_labels.yaml",
)
args = parser.parse_args()

with open(args.config) as f:
config = yaml.safe_load(f)

dataset_id_dict = config["conversion"]["dataset_ids"]

date = datetime.now().strftime("%Y-%m-%d")
log_file = f"annotation_status_{date}.log"
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
for dataset_name, dataset_id in dataset_id_dict.items():
status_msg = ""
try:
status = get_dataset_status(dataset_id)
if status == "done":
status_msg = "Done"
elif status == "ready":
status_msg = "Under Review"
else:
status_msg = status
except AnnotationNotFoundException:
status_msg = "Error"

with open(log_file, "a") as log:
log.write(f"{status_msg}\n")
# log.write(f"{timestamp}, {dataset_name}, {dataset_id}, {status}\n")
8 changes: 5 additions & 3 deletions perception_dataset/deepen/import_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def __init__(


class AnnotationNotFoundException(Exception):
pass
def __init__(self, dataset_id: str, *args: Any) -> None:
self.dataset_id = dataset_id
super().__init__(f"Annotation not found for dataset_id: {dataset_id}")


def mark_as_done(dataset_id: str) -> None:
Expand All @@ -61,8 +63,8 @@ def get_dataset_status(dataset_id: str) -> str:
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
except requests.exceptions.RequestException as e:
raise SystemExit(e)
except requests.exceptions.RequestException:
raise AnnotationNotFoundException(dataset_id)

return response.json()["current_stage_status"]

Expand Down

0 comments on commit 06a3b53

Please sign in to comment.