Skip to content

Commit

Permalink
Fix pyodide missing tzdata (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
haakonvt authored May 31, 2024
1 parent 32448e7 commit 684d200
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.46.1] - 2024-05-31
### Fixed
- Pyodide issue related to missing tzdata package.

## [7.46.0] - 2024-05-31
### Added
- `RawRowsAPI.insert_dataframe` now has a new `dropna` setting (defaulting to True, as this would otherwise raise later).
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.46.0"
__version__ = "7.46.1"
__api_subversion__ = "20230101"
9 changes: 8 additions & 1 deletion cognite/client/utils/_time.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import calendar
import functools
import math
import numbers
import re
Expand All @@ -24,7 +25,6 @@

import pandas

UTC = ZoneInfo("UTC") # type: ignore [abstract]
UNIT_IN_MS_WITHOUT_WEEK = {"s": 1000, "m": 60000, "h": 3600000, "d": 86400000}
UNIT_IN_MS = {**UNIT_IN_MS_WITHOUT_WEEK, "w": 604800000}
VARIABLE_LENGTH_UNITS = {"month", "quarter", "year"}
Expand Down Expand Up @@ -73,6 +73,11 @@
}


@functools.lru_cache(1)
def get_zoneinfo_utc() -> ZoneInfo:
return ZoneInfo("UTC") # type: ignore [abstract]


def parse_str_timezone_offset(tz: str) -> timezone:
"""
This function attempts to accept and convert all valid fixed-offset timezone input that the API
Expand Down Expand Up @@ -582,6 +587,7 @@ def to_fixed_utc_intervals(start: datetime, end: datetime, granularity: str) ->
def _to_fixed_utc_intervals_variable_unit_length(
start: datetime, end: datetime, multiplier: int, unit: str, granularity: str
) -> list[dict[str, datetime | str]]:
UTC = get_zoneinfo_utc()
freq = to_pandas_freq(f"{multiplier}{unit}", start)
index = pandas_date_range_tz(start, end, freq)
return [
Expand All @@ -598,6 +604,7 @@ def _to_fixed_utc_intervals_fixed_unit_length(
start: datetime, end: datetime, multiplier: int, unit: str, granularity: str
) -> list[dict[str, datetime | str]]:
pd = local_import("pandas")
UTC = get_zoneinfo_utc()

index = pandas_date_range_tz(start, end, to_pandas_freq(f"{multiplier}{unit}", start))
utc_offsets = pd.Series([t.utcoffset() for t in index], index=index)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.46.0"
version = "7.46.1"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down

0 comments on commit 684d200

Please sign in to comment.