Skip to content

Commit 01a51f2

Browse files
authored
Move Oldest supported Python version to 3.10 (#21)
* Move oldest supported Python up to 3.10 in the pyproject.toml and the CI tests. * Use TypeAlias instead of Union Type for Path we had this implementation previously but changed it to be compatible with Python 3.9. As we now move to >=3.10 we can use this more elegant solution. * Use slots for config dataclasses We had this implementation earlier but removed it to support Python 3.9. As we now move to Python 3.10 we can reintroduce them. * Use Pipes instead of Union for union types as we now move to Python 3.10 and pipes are easier to read.
1 parent 4c82355 commit 01a51f2

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.github/workflows/test-and-lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: Set up oldest supported Python on ${{ matrix.os }}
5454
uses: actions/setup-python@v5
5555
with:
56-
python-version: 3.9
56+
python-version: '3.10'
5757
- name: Run tests on oldest supported Python
5858
run: |
5959
python -m pip install -r requirements.txt

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "job-queue"
77
description = ""
88
version = "0.1.0"
99
readme = "README.md"
10-
requires-python = ">=3.9"
10+
requires-python = ">=3.10"
1111
dependencies = ["docker", "kubernetes", "ray[train]", "tensorflow"]
1212

1313
[project.scripts]

src/jobs/assembler/config.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@
88
from jobs.types import AnyPath
99

1010

11-
@dataclass(frozen=True)
11+
@dataclass(frozen=True, slots=True)
1212
class DependencySpec:
1313
apt: list[str]
1414
pip: list[str]
1515

1616

17-
@dataclass(frozen=True)
17+
@dataclass(frozen=True, slots=True)
1818
class VolumeSpec:
1919
host_path: str
2020
container_path: str
2121

2222

23-
@dataclass(frozen=True)
23+
@dataclass(frozen=True, slots=True)
2424
class FilesystemSpec:
2525
copy: list[dict[str, str]] = field(default_factory=list)
2626
add: list[dict[str, str]] = field(default_factory=list)
2727

2828

29-
@dataclass(frozen=True)
29+
@dataclass(frozen=True, slots=True)
3030
class ConfigSpec:
3131
env: list[dict[str, str]] = field(default_factory=list)
3232
arg: list[dict[str, str]] = field(default_factory=list)
3333
stopsignal: str | None = None
3434
shell: str | None = None
3535

3636

37-
@dataclass(frozen=True)
37+
@dataclass(frozen=True, slots=True)
3838
class MetaSpec:
3939
labels: list[dict[str, str]]
4040

4141

42-
@dataclass(frozen=True)
42+
@dataclass(frozen=True, slots=True)
4343
class UserSpec:
4444
name: str
4545

4646

47-
@dataclass(frozen=True)
47+
@dataclass(frozen=True, slots=True)
4848
class BuildSpec:
4949
base_image: str
5050
dependencies: DependencySpec | None = None
@@ -77,7 +77,7 @@ def _coerce_spec(val, spec):
7777
object.__setattr__(self, attr, coerced_value)
7878

7979

80-
@dataclass(frozen=True)
80+
@dataclass(frozen=True, slots=True)
8181
class Config:
8282
build: BuildSpec
8383

src/jobs/job.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
from dataclasses import dataclass
99
from pathlib import Path
10-
from typing import Any, Callable, TypedDict, Union
10+
from typing import Any, Callable, TypedDict
1111

1212
import docker.types
1313

@@ -33,9 +33,9 @@ class DockerResourceOptions(TypedDict):
3333
K8sResourceOptions = TypedDict(
3434
"K8sResourceOptions",
3535
{
36-
"cpu": Union[str, None],
37-
"memory": Union[str, None],
38-
"nvidia.com/gpu": Union[int, None],
36+
"cpu": str | None,
37+
"memory": str | None,
38+
"nvidia.com/gpu": int | None,
3939
},
4040
total=False,
4141
)

src/jobs/types.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import os
22
from enum import Enum
3-
from typing import Union
3+
from pathlib import Path
4+
from typing import TypeAlias
45

5-
AnyPath = Union[os.PathLike[str], str]
6+
AnyPath: TypeAlias = os.PathLike[str] | str | Path
67

78

89
class K8sResourceKind(Enum):

0 commit comments

Comments
 (0)