Skip to content

Commit c1ad2ba

Browse files
Bug fix: make last modification timestamp of parallel file reading time zone aware (fixes TypeError: can't compare offset-naive and offset-aware datetimes error)
1 parent 6c6fb3b commit c1ad2ba

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.5.0 (2019-07-07)
4+
5+
- Bug fix: make last modification timestamp of parallel file reading time zone aware (fixes `TypeError: can't compare offset-naive and offset-aware datetimes` error)
6+
7+
38
## 2.4.0 - 2.4.2 (2019-07-04)
49

510
- Add travis integration and PyPi upload

data_integration/parallel_tasks/files.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import enum
23
import glob
34
import json
45
import math
@@ -7,12 +8,11 @@
78
import re
89
from html import escape
910

10-
import enum
11-
1211
import mara_db.config
1312
import mara_db.dbs
1413
import mara_db.postgresql
1514
from mara_page import _, html
15+
1616
from .. import config, pipelines
1717
from ..commands import python, sql, files
1818
from ..incremental_processing import file_dependencies as _file_dependencies
@@ -130,7 +130,7 @@ def update_file_dependencies():
130130
sql_statements = []
131131
for date in files_per_day.keys():
132132
sql_statements.append(f'CREATE TABLE IF NOT EXISTS {self.target_table}_{date.strftime("%Y%m%d")}'
133-
+ f' PARTITION OF {self.target_table} FOR VALUES IN ({date.strftime("%Y%m%d")});')
133+
+ f' PARTITION OF {self.target_table} FOR VALUES IN ({date.strftime("%Y%m%d")});')
134134

135135
if self.truncate_partitions:
136136
sql_statements.append(f'TRUNCATE {self.target_table}_{date.strftime("%Y%m%d")};')
@@ -167,7 +167,8 @@ def read_command(self) -> pipelines.Command:
167167
raise NotImplementedError
168168

169169
def _last_modification_timestamp(self, file_name):
170-
return datetime.datetime.fromtimestamp(os.path.getmtime(pathlib.Path(config.data_dir()) / file_name))
170+
return datetime.datetime.fromtimestamp(
171+
os.path.getmtime(pathlib.Path(config.data_dir()) / file_name)).astimezone()
171172

172173

173174
class ParallelReadFile(_ParallelRead):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def get_long_description():
77

88
setup(
99
name='data-integration',
10-
version='2.4.2',
10+
version='2.5.0',
1111

1212
description='Opinionated lightweight ETL pipeline framework',
1313

0 commit comments

Comments
 (0)