Skip to content

Commit

Permalink
Add support for Python 3.11 and deprecate Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
karan6181 committed Jan 30, 2024
1 parent 36059a9 commit 5b553ac
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
install_version:
- ""
steps:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 💾 Installation
StreamingDataset installs via pip. Installing StreamingDataset in a virtual environment is recommended to avoid any dependency conflicts. StreamingDataset has been tested on Python 3.8, 3.9, and 3.10.
StreamingDataset installs via pip. Installing StreamingDataset in a virtual environment is recommended to avoid any dependency conflicts. StreamingDataset has been tested on Python 3.9, 3.10, and 3.11.

## Create a virtual environment
1. Create and navigate to your project directory:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

classifiers = [
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]

install_requires = [
Expand Down Expand Up @@ -141,5 +141,5 @@
classifiers=classifiers,
install_requires=install_requires,
extras_require=extra_deps,
python_requires='>=3.8',
python_requires='>=3.9',
)
10 changes: 2 additions & 8 deletions streaming/base/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,8 @@ def __init__(self, sample_ids: NDArray[np.int64]) -> None:
# at shutdown to prevent a deadlock.
# In python version >=3.9 this can be accomplished via
# threading._register_atexit but not with the atexit module.
# In older python versions, the atexit module can be used, and
# threading._register_atexit does not exist.
if sys.version_info[1] <= 8: # check if python version <=3.8
import atexit
atexit.register(self.non_blocking_exit)
else:
from threading import _register_atexit # pyright: ignore
_register_atexit(self.non_blocking_exit)
from threading import _register_atexit # pyright: ignore
_register_atexit(self.non_blocking_exit)

def non_blocking_exit(self) -> None:
"""Signal threads to exit without blocking.
Expand Down
5 changes: 1 addition & 4 deletions streaming/base/format/base/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,7 @@ def finish(self) -> None:
def cancel_future_jobs(self) -> None:
"""Shutting down the executor and cancel all the pending jobs."""
# Beginning python v3.9, ThreadPoolExecutor.shutdown() has a new parameter `cancel_futures`
if sys.version_info[1] <= 8: # check if python version <=3.8
self.executor.shutdown(wait=False)
else:
self.executor.shutdown(wait=False, cancel_futures=True)
self.executor.shutdown(wait=False, cancel_futures=True)
if self.remote and not self.keep_local:
shutil.rmtree(self.local, ignore_errors=True)

Expand Down

0 comments on commit 5b553ac

Please sign in to comment.