Skip to content

Commit 92d6169

Browse files
Linchintswastgcf-owl-bot[bot]renovate-botparthea
authored
chore: migrate code from googleapis/python-db-dtypes-pandas (GoogleCloudPlatform#13776)
* feat: add `time` and `date` dtypes Migrated from BigQuery googleapis/python-bigquery#972 * chore: add license headers to __init__.py files * chore: fail samples nox session if python version is missing (GoogleCloudPlatform#17) * chore(python): Add kokoro configs for python 3.10 samples testing (GoogleCloudPlatform#26) * feat: rename dbtime and dbdate dtypes to avoid future conflicts with pandas (GoogleCloudPlatform#32) * docs: add how-to guide and include API reference (GoogleCloudPlatform#33) * docs: add how-to guide and include API reference * fix indentation * fix types in sample * fix types in sample * chore(samples): Add check for tests in directory (GoogleCloudPlatform#54) Source-Link: googleapis/synthtool@52aef91 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(python): Noxfile recognizes that tests can live in a folder (GoogleCloudPlatform#58) Source-Link: googleapis/synthtool@4760d8d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update all dependencies (GoogleCloudPlatform#68) * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update setup.py Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Tim Swast <swast@google.com> * chore: Adding support for pytest-xdist and pytest-parallel (GoogleCloudPlatform#76) Source-Link: googleapis/synthtool@82f5cb2 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5d8da01438ece4021d135433f2cf3227aa39ef0eaccc941d62aa35e6902832ae Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update dependency pytest to v7.1.0 (GoogleCloudPlatform#80) * chore(deps): update dependency pytest to v7.1.1 (GoogleCloudPlatform#83) * chore(python): use black==22.3.0 (GoogleCloudPlatform#96) Source-Link: googleapis/synthtool@6fab84a Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe * chore(python): add nox session to sort python imports (GoogleCloudPlatform#102) Source-Link: googleapis/synthtool@1b71c10 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update dependency pytest to v7.1.2 (GoogleCloudPlatform#105) * fix: require python 3.7+ (GoogleCloudPlatform#125) * chore(python): drop python 3.6 Source-Link: googleapis/synthtool@4f89b13 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e7bb19d47c13839fe8c147e50e02e8b6cf5da8edd1af8b82208cd6f66cc2829c * require python 3.7+ in setup.py * remove python 3.6 sample configs * update product documentation in .repo-metadata.json * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * exclude templated readme * require python 3.7+ in setup.py * remove python 3.6 from noxfile * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update README Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore(deps): update dependency pytest to v7.1.3 (GoogleCloudPlatform#144) * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore: detect samples tests in nested directories (GoogleCloudPlatform#146) Source-Link: googleapis/synthtool@50db768 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:e09366bdf0fd9c8976592988390b24d53583dd9f002d476934da43725adbb978 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update dependency pytest to v7.2.0 (GoogleCloudPlatform#151) * chore(python): drop flake8-import-order in samples noxfile (GoogleCloudPlatform#156) Source-Link: googleapis/synthtool@6ed3a83 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3abfa0f1886adaf0b83f07cb117b24a639ea1cb9cffe56d43280b977033563eb Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(python): add support for python 3.11 (GoogleCloudPlatform#168) Source-Link: googleapis/synthtool@7197a00 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update dependency pytest to v7.2.1 (GoogleCloudPlatform#170) * chore(deps): update dependency pytest to v7.2.1 * use python 3.11 in prerelease github action workflow * use python 3.11 in compliance github action workflow --------- Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore(deps): update dependency pytest to v7.2.2 (GoogleCloudPlatform#174) * chore(deps): update dependency pytest to v7.3.1 (GoogleCloudPlatform#184) * chore(deps): update dependency pytest to v7.3.2 (GoogleCloudPlatform#188) Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore(deps): update dependency pytest to v7.4.0 (GoogleCloudPlatform#191) Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore(deps): update all dependencies (GoogleCloudPlatform#209) * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update all dependencies (GoogleCloudPlatform#221) * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * feat: Add support for Python 3.12 (GoogleCloudPlatform#223) * chore(python): Add Python 3.12 Source-Link: googleapis/synthtool@af16e6d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:bacc3af03bff793a03add584537b36b5644342931ad989e3ba1171d3bd5399f5 * add constraints file for python 3.12 * remove constraints file for python 3.6 * Add trove classifiers for python 3.11 / 3.12 * update prerelease and compliance workflows to use python 3.12 --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> * chore(deps): update dependency pytest to v7.4.4 (GoogleCloudPlatform#235) Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * chore(deps): update dependency pytest to v8 (GoogleCloudPlatform#239) * chore(deps): update dependency pytest to v8 * pin pytest == 7.4.4 for python 3.7 --------- Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * chore(deps): update dependency pytest to v8.0.1 (GoogleCloudPlatform#243) * chore(deps): update dependency pytest to v8.0.1 * pin pytest version for python==3.7 --------- Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * chore(deps): update dependency pytest to v8.0.2 (GoogleCloudPlatform#247) * chore(deps): update dependency pytest to v8.0.2 * pin pytest==7.4.4 for python 3.7 --------- Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * chore(deps): update dependency pytest to v8.1.1 (GoogleCloudPlatform#251) * chore(deps): update dependency pytest to v8.1.1 * pin pytest==7.4.4 for python 3.7 --------- Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * testing: use arbitrary equality for pinned pytest version (GoogleCloudPlatform#262) * chore: format code files with nox (GoogleCloudPlatform#281) * chore(deps): update all dependencies (GoogleCloudPlatform#290) * chore(deps): update all dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * build: use multiScm for Kokoro release builds (GoogleCloudPlatform#294) Source-Link: googleapis/synthtool@0da1658 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5cddfe2fb5019bbf78335bc55f15bc13e18354a56b3ff46e1834f8e540807f05 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * deps!: Drop support for Python 3.7 and 3.8 (AI Experiment) (GoogleCloudPlatform#337) * feat: Drop support for Python 3.7 and 3.8 Removes support for Python 3.7 and 3.8, establishing Python 3.9 as the new minimum supported version. This change involves: - Updating `python_requires` and classifiers in `setup.py`. - Modifying Python versions in `noxfile.py` (default, unit tests, system tests) and ensuring constraint file logic remains correct. - Updating the GitHub Actions workflow (`unittest.yml`) matrix, runner, and coverage job version. - Deleting constraint files for Python 3.7 and 3.8 (`testing/constraints-3.7.txt`, `testing/constraints-3.8.txt`). - Removing Kokoro sample configuration directories (`.kokoro/samples/python3.7/`, `.kokoro/samples/python3.8/`). - Updating supported version mentions in `README.rst`. - Removing 3.7 and 3.8 from the `ALL_VERSIONS` list in `samples/snippets/noxfile.py`. * Updates python version in lint.yml * Updates owlbot, removing reference to 3.8 * Updates CONTRIBUTING.rst * updates pytest warnings * Removes test_samples-impl ref to older virtualenv package * Removes references to pandas older than 1.5.0 * Removes pandas older than 1.5 and misc changes * updates pandas in setup.py * more updates related to pandas * still broken * Updates FutureWarning tests to account for unittest coverage * Updates json array type tests to account for unittest coverage * updates python version checks to ensure coverage * update json test for unittest coverage * Update pandas_backports unittests to ensure coverage * Updates per review comments * moves class from version specific compliance file to generic file * Removes weird cut and paste error * fix linting errors * updates import statement to ensure import of JSONArrowType * Revise required github status checks * update linting * temporarily marking a class as no cover * more updates * marked several snippets as pragma no cover * updates linting * Updates constraints and setup.py * migrates class from one time compliance file to another * updating pyarrow version * Updates linting * removes determine all and module reload tests * updates re: ndarrybackedextensionarray * testing blacken as part of owlbot processing using 3.8 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates blacken to 3.10 * update python version in lint.yml * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates owlbot.py * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates owlbot.py * testing lint.yml * testing linting issue * testing linting issue * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updates lint_setup session * Update noxfile.py --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * test: updates python versions and sets owlbot excludes (GoogleCloudPlatform#367) * chore(deps): update all dependencies * updates to prevent changes to docs and lint.ymls * updates lint python version to 3.10 * remove comments, update lint python version * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Mend Renovate <bot@renovateapp.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(deps): update dependency pytest to v8.4.1 (GoogleCloudPlatform#368) * chore(deps): update all dependencies * Update docs.yml * Update lint.yml --------- Co-authored-by: Lingqing Gan <lingqing.gan@gmail.com> * chore(deps): update all dependencies (GoogleCloudPlatform#373) * feat: Add support for Python 3.14 (GoogleCloudPlatform#380) This PR adds Python 3.14 as a supported version, and fixed tests for the new version This PR also adds a dependency bound to pandas, as the [upcoming 3.0.0 version is incompatible](https://github.com/googleapis/python-db-dtypes-pandas/issues/381) * correct header * add noxconfig.py * delete noxfile.py * add * lint --------- Co-authored-by: Tim Swast <swast@google.com> Co-authored-by: gcf-owl-bot[bot] <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: WhiteSource Renovate <bot@renovateapp.com> Co-authored-by: Anthonios Partheniou <partheniou@google.com> Co-authored-by: Chelsea Lin <124939984+chelsea-lin@users.noreply.github.com> Co-authored-by: Chalmer Lowe <chalmer.lowe@gmail.com> Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Daniel Sanche <sanche@google.com>
1 parent f71b420 commit 92d6169

File tree

8 files changed

+212
-0
lines changed

8 files changed

+212
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

bigquery/python-db-dtypes-pandas/pytest.ini

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Default TEST_CONFIG_OVERRIDE for python repos.
16+
17+
# You can copy this file into your directory, then it will be imported from
18+
# the noxfile.py.
19+
20+
# The source of truth:
21+
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py
22+
23+
TEST_CONFIG_OVERRIDE = {
24+
# You can opt out from the test for specific Python versions.
25+
"ignored_versions": ["2.7", "3.7", "3.8"],
26+
# Old samples are opted out of enforcing Python type hints
27+
# All new samples should feature them
28+
"enforce_type_hints": True,
29+
# An envvar key for determining the project id to use. Change it
30+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
31+
# build specific Cloud project. You can also use your own string
32+
# to use your own Cloud project.
33+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
34+
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
35+
# If you need to use a specific version of pip,
36+
# change pip_version_override to the string representation
37+
# of the version number, for example, "20.2.4"
38+
"pip_version_override": None,
39+
# A dictionary you want to inject into your test. Don't put any
40+
# secrets here. These values will override predefined values.
41+
"envs": {},
42+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
def pandas_date_and_time():
17+
# [START bigquery_pandas_date_create]
18+
19+
import datetime
20+
21+
import pandas as pd
22+
23+
import db_dtypes # noqa import to register dtypes
24+
25+
dates = pd.Series([datetime.date(2021, 9, 17), "2021-9-18"], dtype="dbdate")
26+
27+
# [END bigquery_pandas_date_create]
28+
# [START bigquery_pandas_date_as_datetime]
29+
30+
datetimes = dates.astype("datetime64")
31+
32+
# [END bigquery_pandas_date_as_datetime]
33+
# [START bigquery_pandas_date_sub]
34+
35+
dates2 = pd.Series(["2021-1-1", "2021-1-2"], dtype="dbdate")
36+
diffs = dates - dates2
37+
38+
# [END bigquery_pandas_date_sub]
39+
# [START bigquery_pandas_date_add_offset]
40+
41+
do = pd.DateOffset(days=1)
42+
after = dates + do
43+
before = dates - do
44+
45+
# [END bigquery_pandas_date_add_offset]
46+
# [START bigquery_pandas_time_create]
47+
48+
times = pd.Series([datetime.time(1, 2, 3, 456789), "12:00:00.6"], dtype="dbtime")
49+
50+
# [END bigquery_pandas_time_create]
51+
# [START bigquery_pandas_time_as_timedelta]
52+
53+
timedeltas = times.astype("timedelta64")
54+
55+
# [END bigquery_pandas_time_as_timedelta]
56+
57+
# Combine datetime64 and timedelta64 to confirm adding dates and times are
58+
# equivalent.
59+
combined0 = datetimes + timedeltas
60+
61+
# [START bigquery_pandas_combine_date_time]
62+
63+
combined = dates + times
64+
65+
# [END bigquery_pandas_combine_date_time]
66+
67+
return (
68+
dates,
69+
datetimes,
70+
dates2,
71+
diffs,
72+
do,
73+
after,
74+
before,
75+
times,
76+
timedeltas,
77+
combined,
78+
combined0,
79+
)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import datetime
16+
17+
import numpy as np
18+
from pandas import Timestamp
19+
20+
21+
def test_pandas_date_and_time():
22+
from .pandas_date_and_time import pandas_date_and_time
23+
24+
(
25+
dates,
26+
_,
27+
dates2,
28+
diffs,
29+
do,
30+
after,
31+
before,
32+
times,
33+
_,
34+
combined,
35+
combined0,
36+
) = pandas_date_and_time()
37+
38+
assert str(dates.dtype) == "dbdate"
39+
assert list(dates) == [datetime.date(2021, 9, 17), datetime.date(2021, 9, 18)]
40+
41+
assert np.array_equal(
42+
diffs,
43+
dates.astype("datetime64") - dates2.astype("datetime64"),
44+
)
45+
46+
assert np.array_equal(after, dates.astype("object") + do)
47+
assert np.array_equal(before, dates.astype("object") - do)
48+
49+
assert str(times.dtype) == "dbtime"
50+
assert list(times) == [
51+
datetime.time(1, 2, 3, 456789),
52+
datetime.time(12, 0, 0, 600000),
53+
]
54+
55+
for c in combined0, combined:
56+
assert str(c.dtype) == "datetime64[ns]"
57+
assert list(c) == [
58+
Timestamp("2021-09-17 01:02:03.456789"),
59+
Timestamp("2021-09-18 12:00:00.600000"),
60+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest==8.4.2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
db-dtypes
2+
numpy
3+
pandas
4+
pyarrow

0 commit comments

Comments
 (0)