Skip to content

Commit

Permalink
Reftime handling when values are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithere committed Jan 10, 2024
1 parent 5094419 commit 413efc4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# CHANGELOG

## 0.3.36
- [x] update: Reftime handling works if reftime is malformed

## 0.3.35
- [x] add: validations for the input file for conversation tagging

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 = "skit-labels"
version = "0.3.35"
version = "0.3.36"
description = "Command line tool for interacting with labelled datasets at skit.ai."
authors = []
license = "MIT"
Expand Down
12 changes: 10 additions & 2 deletions skit_labels/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
)


def update_reftime(reftime, tz):
try:
reftime = to_datetime(reftime)
return reftime.astimezone(tz).isoformat()
except Exception as e:
print("Couldn't convert thr timezone for Reftime: " + str(reftime))
return reftime


def build_task(
d: Dict, task_type: str, data_id: Optional[str] = None, tz=pytz.UTC
) -> Task:
Expand All @@ -39,8 +48,7 @@ def build_task(
# Since the reftime from db is in UTC, we convert it to our timezone. This
# is needed as saying 12 pm means different things in different timezones
# and can't be translated without doing something stupid.
task.reftime = to_datetime(task.reftime)
task.reftime = task.reftime.astimezone(tz).isoformat()
task.reftime = update_reftime(task.reftime, tz)
elif task_type == "simulated_call":
task = SimulatedCallTask.from_dict(d)
elif task_type == "audio_segment":
Expand Down

0 comments on commit 413efc4

Please sign in to comment.