Skip to content

Commit aa6205f

Browse files
marcenacpThe TensorFlow Datasets Authors
authored andcommitted
Support for python3.12
PiperOrigin-RevId: 640159257
1 parent 7c0f397 commit aa6205f

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
num-shards: ${{ fromJson(needs.shards-job.outputs.num-shards) }}
8585
shard-id: ${{ fromJson(needs.shards-job.outputs.shard-ids) }}
8686
# TF suppported versions: https://www.tensorflow.org/install/pip#software_requirements
87-
python-version: ['3.10', '3.11']
87+
python-version: ['3.10', '3.11', '3.12']
8888
os-version: [ubuntu-latest]
8989

9090
steps:

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
'array_record>=0.5.0;platform_system=="Linux"',
6666
'click',
6767
'dm-tree',
68-
'etils[enp,epath,epy,etree]>=1.6.0',
68+
'etils[enp,epath,epy,etree]>=1.6.0;python_version<"3.11"',
69+
'etils[enp,epath,epy,etree]>=1.9.1;python_version>="3.11"',
6970
'immutabledict',
7071
'numpy',
7172
'promise',
@@ -99,7 +100,7 @@
99100
# 'tensorflow-docs @ git+https://github.com/tensorflow/docs#egg=tensorflow-docs', # pylint: disable=line-too-long
100101
# Required by scripts/documentation/
101102
'pyyaml',
102-
'tensorflow-io[tensorflow]',
103+
'tensorflow-io[tensorflow];python_version<"3.12"',
103104
]
104105

105106
# Additional deps for formatting

tensorflow_datasets/core/features/audio_feature_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def test_wav_file(self, dtype, lazy_decode, num_channels):
110110
@parameterized.product(lazy_decode=[True, False], num_channels=[1, 2, 8])
111111
def test_flac_file(self, lazy_decode, num_channels):
112112
if lazy_decode:
113+
try:
114+
import tensorflow_io # pylint: disable=g-import-not-at-top, unused-import
115+
except ImportError:
116+
self.skipTest('`tensorflow_io` dependency is not available')
113117
if 'dev' in tf.__version__:
114118
self.skipTest('`tensorflow_io` is not compatible with `tf-nightly`')
115119

tensorflow_datasets/core/github_api/github_path.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import os
2121
import pathlib
2222
import posixpath
23+
import sys
2324
from typing import Iterator, Mapping, MutableMapping, Optional, Set, Tuple
2425

2526
from etils import epath
@@ -217,10 +218,22 @@ class GithubPath(pathlib.PurePosixPath):
217218
```
218219
"""
219220

220-
def __new__(cls, *parts: epath.PathLike) -> 'GithubPath':
221-
full_path = '/'.join(os.fspath(p) for p in parts)
222-
_parse_github_path(full_path)
223-
return super().__new__(cls, full_path.replace(_URI_PREFIX, '/github/', 1))
221+
if sys.version_info < (3, 12):
222+
223+
def __new__(cls, *parts: epath.PathLike) -> 'GithubPath':
224+
full_path = '/'.join(os.fspath(p) for p in parts)
225+
_parse_github_path(full_path)
226+
return super().__new__(cls, full_path.replace(_URI_PREFIX, '/github/', 1))
227+
228+
else:
229+
230+
def __init__(self, *parts: epath.PathLike):
231+
full_path = '/'.join(os.fspath(p) for p in parts)
232+
if full_path.startswith(_URI_PREFIX):
233+
# If we already converted the prefix github:// -> /github, we don't do
234+
# the check again.
235+
_parse_github_path(full_path)
236+
super().__init__(full_path.replace(_URI_PREFIX, '/github/', 1))
224237

225238
@functools.cached_property
226239
def _path_str(self) -> str:

0 commit comments

Comments
 (0)