Skip to content

Commit ae9610f

Browse files
committed
ISO date conversion fix
- Fix to ISO date conversion where string is already in ISO-format. - Ray dependency fix where checking for location of temporary directory.
1 parent c1a0b67 commit ae9610f

6 files changed

Lines changed: 33 additions & 8 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
- 1.2.1: Minor change in Ray dependency
2-
- 1.2.0: Upgrading Pydantic from version 1.8 to version 2.10
1+
- 1.2.2: Fix to date ISO conversion where date str already in ISO-format, plus Ray dependency fix.
2+
- 1.2.1: Minor change in Ray dependency.
3+
- 1.2.0: Upgrading Pydantic from version 1.8 to version 2.10.
34
- 1.1.3: Improving exception error messages to be more helpful.
45
- 1.1.2: Fixes for `CATEGORY` parser for ambiguous term names.
56
- 1.1.1: Fixes for action parser where field names contain ambiguous characters.

docs/changelog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ title: Change log
33
summary: Version history, including for legacy versions.
44
authors:
55
- Gavin Chait
6-
date: 2025-03-13
6+
date: 2025-09-11
77
tags: wrangling, crosswalks, versions
88
---
99
# Change log
1010

11+
## Version 1.2.2 (2025-09-11)
12+
13+
- Fix to ISO date conversion where string is already in ISO-format.
14+
- Ray dependency fix where checking for location of temporary directory.
15+
16+
## Version 1.2.1 (2025-07-19)
17+
18+
- Minor change in Ray dependency.
19+
1120
## Version 1.2.0 (2025-03-13)
1221

1322
- Upgrading Pydantic from version 1 to 2. This is not backwardly compatible.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "whyqd"
3-
version = "1.2.1"
3+
version = "1.2.2"
44
description = "data wrangling simplicity, complete audit transparency, and at speed"
55
authors = ["Gavin Chait <gchait@whythawk.com>"]
66
license = "BSD-3-Clause"

whyqd/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.1
1+
1.2.2

whyqd/config/ray_init.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
def clear_spillway() -> bool:
1111
# https://stackoverflow.com/a/56151260/295606
1212
# only do this if ray is not initialised, otherwise it'll crash. horribly.
13-
WHYQD_SPILLWAY = ray._common.utils.get_user_temp_dir()
13+
# WHYQD_SPILLWAY = ray._common.utils.get_user_temp_dir()
14+
WHYQD_SPILLWAY = ray._private.utils.get_user_temp_dir()
1415
if not Path(WHYQD_SPILLWAY).exists():
1516
return False
1617
for path in Path(WHYQD_SPILLWAY).iterdir():
@@ -50,8 +51,8 @@ def ray_start(**kwargs):
5051
kwargs["object_store_memory"] = settings.WHYQD_MEMORY
5152
if not kwargs.get("_temp_dir") and settings.WHYQD_SPILLWAY:
5253
# TODO: On some environments, I'm getting weird timeouts
53-
if not ray._common.utils.get_user_temp_dir().endswith(settings.WHYQD_SPILLWAY):
54-
kwargs["_temp_dir"] = f"{ray._common.utils.get_user_temp_dir()}{settings.WHYQD_SPILLWAY}"
54+
if not ray._private.utils.get_user_temp_dir().endswith(settings.WHYQD_SPILLWAY):
55+
kwargs["_temp_dir"] = f"{ray._private.utils.get_user_temp_dir()}{settings.WHYQD_SPILLWAY}"
5556
pass
5657
# if not kwargs.get("_system_config") and settings.WHYQD_SPILLWAY:
5758
# kwargs["_system_config"] = {

whyqd/parsers/datasource.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,17 @@ def check_date_format(self, *, date_type: str, date_value: str) -> bool:
625625
### PANDAS TYPE PARSERS
626626
###################################################################################################
627627

628+
def _date_is_isoformat(self, x: str) -> bool:
629+
"""
630+
Checks a string to see whether it can be coerced as an ISO-formatted date `YYYY-MM-DD`
631+
https://stackoverflow.com/a/61569783
632+
"""
633+
try:
634+
datetime.fromisoformat(x.replace('Z', '+00:00'))
635+
except (ValueError, TypeError):
636+
return False
637+
return True
638+
628639
def _parse_dates(self, x: Union[None, str], dayfirst: bool = True) -> Union[pd.NaT, date.isoformat]:
629640
"""
630641
This is the hard-won 'trust nobody', certainly not Americans, date parser. This requires that the user
@@ -652,6 +663,9 @@ def _parse_dates(self, x: Union[None, str], dayfirst: bool = True) -> Union[pd.N
652663
if isinstance(x, str) and len(x) <= 10 and ":" in x:
653664
# This specific variation of a date is interpreted as a time, so ...
654665
x = re.sub(r"[\\/,\.:;]", "-", x)
666+
# Check if already in ISO Format
667+
if self._date_is_isoformat(x):
668+
return str(x).strip()[:10]
655669
# Check if to_datetime can handle things
656670
if not pd.isnull(pd.to_datetime(x, errors="coerce", dayfirst=dayfirst)):
657671
return date.isoformat(pd.to_datetime(x, errors="coerce", dayfirst=dayfirst))

0 commit comments

Comments
 (0)