Skip to content

Commit

Permalink
Support for python3.12
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 640159257
  • Loading branch information
marcenacp authored and The TensorFlow Datasets Authors committed Jun 4, 2024
1 parent 7c0f397 commit aa6205f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
num-shards: ${{ fromJson(needs.shards-job.outputs.num-shards) }}
shard-id: ${{ fromJson(needs.shards-job.outputs.shard-ids) }}
# TF suppported versions: https://www.tensorflow.org/install/pip#software_requirements
python-version: ['3.10', '3.11']
python-version: ['3.10', '3.11', '3.12']
os-version: [ubuntu-latest]

steps:
Expand Down
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
'array_record>=0.5.0;platform_system=="Linux"',
'click',
'dm-tree',
'etils[enp,epath,epy,etree]>=1.6.0',
'etils[enp,epath,epy,etree]>=1.6.0;python_version<"3.11"',
'etils[enp,epath,epy,etree]>=1.9.1;python_version>="3.11"',
'immutabledict',
'numpy',
'promise',
Expand Down Expand Up @@ -99,7 +100,7 @@
# 'tensorflow-docs @ git+https://github.com/tensorflow/docs#egg=tensorflow-docs', # pylint: disable=line-too-long
# Required by scripts/documentation/
'pyyaml',
'tensorflow-io[tensorflow]',
'tensorflow-io[tensorflow];python_version<"3.12"',
]

# Additional deps for formatting
Expand Down
4 changes: 4 additions & 0 deletions tensorflow_datasets/core/features/audio_feature_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def test_wav_file(self, dtype, lazy_decode, num_channels):
@parameterized.product(lazy_decode=[True, False], num_channels=[1, 2, 8])
def test_flac_file(self, lazy_decode, num_channels):
if lazy_decode:
try:
import tensorflow_io # pylint: disable=g-import-not-at-top, unused-import
except ImportError:
self.skipTest('`tensorflow_io` dependency is not available')
if 'dev' in tf.__version__:
self.skipTest('`tensorflow_io` is not compatible with `tf-nightly`')

Expand Down
21 changes: 17 additions & 4 deletions tensorflow_datasets/core/github_api/github_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import pathlib
import posixpath
import sys
from typing import Iterator, Mapping, MutableMapping, Optional, Set, Tuple

from etils import epath
Expand Down Expand Up @@ -217,10 +218,22 @@ class GithubPath(pathlib.PurePosixPath):
```
"""

def __new__(cls, *parts: epath.PathLike) -> 'GithubPath':
full_path = '/'.join(os.fspath(p) for p in parts)
_parse_github_path(full_path)
return super().__new__(cls, full_path.replace(_URI_PREFIX, '/github/', 1))
if sys.version_info < (3, 12):

def __new__(cls, *parts: epath.PathLike) -> 'GithubPath':
full_path = '/'.join(os.fspath(p) for p in parts)
_parse_github_path(full_path)
return super().__new__(cls, full_path.replace(_URI_PREFIX, '/github/', 1))

else:

def __init__(self, *parts: epath.PathLike):
full_path = '/'.join(os.fspath(p) for p in parts)
if full_path.startswith(_URI_PREFIX):
# If we already converted the prefix github:// -> /github, we don't do
# the check again.
_parse_github_path(full_path)
super().__init__(full_path.replace(_URI_PREFIX, '/github/', 1))

@functools.cached_property
def _path_str(self) -> str:
Expand Down

0 comments on commit aa6205f

Please sign in to comment.