Skip to content

Commit 6e3da24

Browse files
committed
Deprecate Python 3.7, switch to Python 3.11 in CI (#621)
* Deprecate Python 3.7, switch to Python 3.11 in CI * Update Sphinx * Set Sphinx language to "en" * Increase the timeout for codecov (cherry picked from commit 213bff9)
1 parent 35565c6 commit 6e3da24

13 files changed

+23
-34
lines changed

.github/workflows/check-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v3
2121
- uses: actions/setup-python@v3
2222
with:
23-
python-version: 3.8
23+
python-version: 3.11
2424
- uses: isort/isort-action@master
2525
with:
2626
isortVersion: "5.10.1"

.github/workflows/run-benchmarks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v3
1717
with:
18-
python-version: 3.9
18+
python-version: 3.11
1919
- name: Cache dependencies
2020
uses: actions/cache@v3
2121
with:
2222
path: ~/.cache/pip
23-
key: Key-v1-3.9-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
23+
key: Key-v1-3.11-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip

.github/workflows/run-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
14+
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
1515
timeout-minutes: 15
1616
steps:
1717
- uses: actions/checkout@v3
@@ -52,12 +52,12 @@ jobs:
5252
- name: Set up Python
5353
uses: actions/setup-python@v3
5454
with:
55-
python-version: '3.8'
55+
python-version: '3.11'
5656
- name: Cache dependencies
5757
uses: actions/cache@v3
5858
with:
5959
path: ~/.cache/pip
60-
key: Key-v1-3.8-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
60+
key: Key-v1-3.11-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
6161
- name: Install dependencies
6262
run: |
6363
python -m pip install --upgrade pip setuptools wheel
@@ -74,18 +74,18 @@ jobs:
7474
codecov_in_develop_mode:
7575

7676
runs-on: ubuntu-latest
77-
timeout-minutes: 15
77+
timeout-minutes: 20
7878
steps:
7979
- uses: actions/checkout@v3
8080
- name: Set up Python
8181
uses: actions/setup-python@v3
8282
with:
83-
python-version: '3.8'
83+
python-version: '3.11'
8484
- name: Cache dependencies
8585
uses: actions/cache@v3
8686
with:
8787
path: ~/.cache/pip
88-
key: Key-v1-3.8-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
88+
key: Key-v1-3.11-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}
8989
- name: Install dependencies
9090
run: |
9191
python -m pip install --upgrade pip setuptools wheel

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ python:
1313
build:
1414
os: ubuntu-22.04
1515
tools:
16-
python: "3.7"
16+
python: "3.11"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ feel free to submit a pull request that adds your project to this list.
4040

4141
## Installation
4242

43-
Before installing, make sure that your environment has Python 3.7+
43+
Before installing, make sure that your environment has Python 3.8+
4444
and [PyTorch](https://pytorch.org/get-started/locally/#start-locally) 1.9.0 or newer. They can be installed either
4545
natively or with [Anaconda](https://www.anaconda.com/products/individual).
4646

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
#
7474
# This is also used if you do content translation via gettext catalogs.
7575
# Usually you set "language" from the command line for these cases.
76-
language = None
76+
language = "en"
7777

7878
# List of patterns, relative to source directory, that match files and
7979
# directories to ignore when looking for source files.

docs/user/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This tutorial will teach you how to install `hivemind`, host your own experts an
44

55
## Installation
66

7-
Just `pip install hivemind` to get the latest release (requires Python 3.7 or newer).
7+
Just `pip install hivemind` to get the latest release (requires Python 3.8 or newer).
88

99
You can also install the bleeding edge version from GitHub:
1010

hivemind/averaging/matchmaking.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from __future__ import annotations
44

55
import asyncio
6-
import concurrent.futures
76
import contextlib
87
import random
98
from math import isfinite
@@ -168,8 +167,8 @@ async def _request_join_potential_leaders(self, step: StepControl) -> GroupInfo:
168167
elif len(self.current_followers) > 0:
169168
await self.leader_disband_group()
170169
continue
171-
except (concurrent.futures.CancelledError, asyncio.CancelledError):
172-
break # note: this is a compatibility layer for python3.7
170+
except asyncio.CancelledError:
171+
break
173172
except Exception as e:
174173
if not self.assembled_group.done():
175174
self.assembled_group.set_exception(e)
@@ -321,8 +320,8 @@ async def rpc_join_group(
321320
ordered_peer_ids=[item.to_bytes() for item in group_info.peer_ids],
322321
gathered=group_info.gathered,
323322
)
324-
except (concurrent.futures.CancelledError, asyncio.CancelledError):
325-
return # note: this is a compatibility layer for python3.7
323+
except asyncio.CancelledError:
324+
return
326325
except Exception as e:
327326
logger.exception(e)
328327
yield averaging_pb2.MessageFromLeader(code=averaging_pb2.INTERNAL_ERROR)

hivemind/utils/asyncio.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ async def await_cancelled(awaitable: Awaitable) -> bool:
8484
try:
8585
await awaitable
8686
return False
87-
except (asyncio.CancelledError, concurrent.futures.CancelledError):
88-
# In Python 3.7, awaiting a cancelled asyncio.Future raises concurrent.futures.CancelledError
89-
# instead of asyncio.CancelledError
87+
except asyncio.CancelledError:
9088
return True
9189
except BaseException:
9290
logger.exception(f"Exception in {awaitable}:")

hivemind/utils/mpfuture.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import threading
88
import uuid
9+
from concurrent.futures import InvalidStateError
910
from contextlib import nullcontext
1011
from enum import Enum, auto
1112
from multiprocessing.reduction import ForkingPickler
@@ -26,15 +27,6 @@
2627
ALL_STATES = base.PENDING, base.RUNNING, base.FINISHED, base.CANCELLED, base.CANCELLED_AND_NOTIFIED
2728
TERMINAL_STATES = {base.FINISHED, base.CANCELLED, base.CANCELLED_AND_NOTIFIED}
2829

29-
try:
30-
from concurrent.futures import InvalidStateError
31-
except ImportError:
32-
# Python 3.7 doesn't raise concurrent.futures.InvalidStateError for repeating set_result/set_exception calls and
33-
# doesn't even define this error. In this module, we simulate the Python 3.8+ behavior,
34-
# defining and raising this error if necessary.
35-
class InvalidStateError(Exception):
36-
"""Raised when attempting to change state of a future in a terminal state (e.g. finished)"""
37-
3830

3931
class SharedBytes:
4032
"""

requirements-docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
recommonmark==0.5.0
22
sphinx_rtd_theme==0.4.3
33
docutils==0.16
4-
sphinx==4.2.0
4+
sphinx==5.0.0

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,10 @@ def run(self):
183183
"Intended Audience :: Science/Research",
184184
"License :: OSI Approved :: MIT License",
185185
"Programming Language :: Python :: 3",
186-
"Programming Language :: Python :: 3.7",
187186
"Programming Language :: Python :: 3.8",
188187
"Programming Language :: Python :: 3.9",
188+
"Programming Language :: Python :: 3.10",
189+
"Programming Language :: Python :: 3.11",
189190
"Topic :: Scientific/Engineering",
190191
"Topic :: Scientific/Engineering :: Mathematics",
191192
"Topic :: Scientific/Engineering :: Artificial Intelligence",

tests/test_util_modules.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ async def coro():
528528
async with enter_asynchronously(lock2):
529529
await asyncio.sleep(1e-2)
530530

531-
num_coros = max(100, mp.cpu_count() * 5 + 1)
532-
# note: if we deprecate py3.7, this can be reduced to max(33, cpu + 5); see https://bugs.python.org/issue35279
531+
num_coros = max(33, mp.cpu_count() * 5 + 1)
533532
await asyncio.wait({asyncio.create_task(coro()) for _ in range(num_coros)})
534533

535534

0 commit comments

Comments
 (0)