Skip to content

Commit f9883da

Browse files
committed
bring back pandera schema
1 parent 2f49ffd commit f9883da

File tree

4 files changed

+44
-43
lines changed

4 files changed

+44
-43
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ ics
1010
babel
1111
loguru
1212
pdfkit
13+
pandera

tuttle/calendar.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import pandas
1010
import datetime
1111

12-
# from pandera.typing import DataFrame
13-
# from pandera import check_io
12+
from pandera.typing import DataFrame
13+
from pandera import check_io
1414
from pandas import DataFrame
1515

16-
# from . import schema
16+
from . import schema
1717

1818

1919
def parse_pyicloud_datetime(dt_list):
@@ -28,7 +28,7 @@ class Calendar:
2828
def __init__(self, name: str):
2929
self.name = name
3030

31-
# @check_io(out=schema.time_tracking)
31+
@check_io(out=schema.time_tracking)
3232
def to_data(self) -> DataFrame:
3333
"""Convert events to dataframe."""
3434
raise NotImplementedError("Abstract base class")
@@ -72,7 +72,7 @@ def to_raw_data(self) -> DataFrame:
7272
)
7373
return event_data_raw
7474

75-
# @check_io(out=schema.time_tracking)
75+
@check_io(out=schema.time_tracking)
7676
def to_data(self) -> DataFrame:
7777
"""Convert ics.Calendar to pandas.DataFrame"""
7878
event_data = pandas.DataFrame(
@@ -129,7 +129,7 @@ def to_raw_data(self) -> DataFrame:
129129
event_data_raw = pandas.DataFrame(all_events)
130130
return event_data_raw
131131

132-
# @check_io(out=schema.time_tracking)
132+
@check_io(out=schema.time_tracking)
133133
def to_data(self) -> DataFrame:
134134
"""Convert iCloud calendar events to time tracking data format."""
135135

tuttle/schema.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# """Pandera schemata."""
2-
# from pandera import (
3-
# SchemaModel,
4-
# DataFrameSchema,
5-
# Column,
6-
# Index,
7-
# DateTime,
8-
# Timedelta,
9-
# String,
10-
# )
1+
"""Pandera schemata."""
2+
from pandera import (
3+
SchemaModel,
4+
DataFrameSchema,
5+
Column,
6+
Index,
7+
DateTime,
8+
Timedelta,
9+
String,
10+
)
1111

1212

13-
# time_tracking = DataFrameSchema(
14-
# # TODO: fix datetime type
15-
# # index=Index(DateTime, name="begin", allow_duplicates=True),
16-
# columns={
17-
# # "begin": Column(Timestamp, nullable=True),
18-
# # "end": Column(DateTime, nullable=True),
19-
# "title": Column(String, nullable=True),
20-
# "tag": Column(String),
21-
# "description": Column(String, nullable=True),
22-
# "duration": Column(Timedelta),
23-
# },
24-
# )
13+
time_tracking = DataFrameSchema(
14+
# TODO: fix datetime type
15+
# index=Index(DateTime, name="begin", allow_duplicates=True),
16+
columns={
17+
# "begin": Column(Timestamp, nullable=True),
18+
# "end": Column(DateTime, nullable=True),
19+
"title": Column(String, nullable=True),
20+
"tag": Column(String),
21+
"description": Column(String, nullable=True),
22+
"duration": Column(Timedelta),
23+
},
24+
)
2525

26-
# time_planning = time_tracking # REVIEW: identical?
26+
time_planning = time_tracking # REVIEW: identical?

tuttle/timetracking.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
import pandas
1010

11-
# from pandera import check_io
12-
# from pandera.typing import DataFrame
11+
from pandera import check_io
12+
from pandera.typing import DataFrame
1313
from pandas import DataFrame
1414

1515

16-
# from . import schema
16+
from . import schema
1717
from .calendar import Calendar, ICloudCalendar, FileCalendar
1818
from .model import (
1919
TimeTrackingItem,
@@ -113,7 +113,7 @@ def export_timesheet(
113113
# IMPORT
114114

115115

116-
# @check_io(out=schema.time_tracking)
116+
@check_io(out=schema.time_tracking)
117117
def import_from_calendar(cal: Calendar) -> DataFrame:
118118
"""Convert the raw calendar to time tracking data table."""
119119
if issubclass(type(cal), ICloudCalendar):
@@ -135,9 +135,9 @@ class Toggl:
135135
description_col = "Description"
136136

137137

138-
# @check_io(
139-
# out=schema.time_tracking,
140-
# )
138+
@check_io(
139+
out=schema.time_tracking,
140+
)
141141
def import_from_spreadsheet(
142142
path,
143143
preset: str = None,
@@ -223,9 +223,9 @@ def total_time_tracked(by: str) -> DataFrame:
223223
raise ValueError()
224224

225225

226-
# @check_io(
227-
# time_tracking_data=schema.time_tracking,
228-
# )
226+
@check_io(
227+
time_tracking_data=schema.time_tracking,
228+
)
229229
def progress(
230230
project: Project,
231231
time_tracking_data: DataFrame,
@@ -242,9 +242,9 @@ def progress(
242242
return total_time.loc[tag]["duration"] / budget
243243

244244

245-
# @check_io(
246-
# out=schema.time_planning,
247-
# )
245+
@check_io(
246+
out=schema.time_planning,
247+
)
248248
def get_time_planning_data(
249249
source,
250250
from_date: datetime.date = None,
@@ -257,6 +257,6 @@ def get_time_planning_data(
257257
planning_data = cal.to_data()
258258
elif isinstance(source, pandas.DataFrame):
259259
planning_data = source
260-
# schema.time_tracking.validate(planning_data)
260+
schema.time_tracking.validate(planning_data)
261261
planning_data = planning_data[str(from_date) :]
262262
return planning_data

0 commit comments

Comments
 (0)