Skip to content

CH SDK compatiblity with Python 3.10 #565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/compute_horde_sdk_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
defaults:
run:
working-directory: ./compute_horde_sdk
Expand Down
2 changes: 1 addition & 1 deletion compute_horde/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion compute_horde_sdk/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

ROOT = Path(".")
MAIN_BRANCH_NAME = "master"
PYTHON_VERSIONS = ["3.11", "3.12"]
PYTHON_VERSIONS = ["3.10", "3.11", "3.12"]
PYTHON_VERSION = ["3.11"]

nox.options.default_venv_backend = "uv"
Expand Down
5 changes: 3 additions & 2 deletions compute_horde_sdk/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "compute-horde-sdk"
requires-python = ">=3.11,<3.13" # bittensor doesn't work on 3.13+
requires-python = ">=3.10,<3.13" # bittensor doesn't work on 3.13+
keywords = []
license = {text = "MIT"}
readme = "README.md"
Expand All @@ -13,6 +13,7 @@ classifiers = [
"Topic :: Software Development :: Libraries",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
Expand Down Expand Up @@ -73,7 +74,7 @@ test = [
"pytest-httpx>=0.35.0",
]
docs = [
"sphinx>=8.2.3",
"sphinx>=8.1.0",
"sphinx-multiversion>=0.2.4",
"sphinx-rtd-theme>=3.0.2",
]
Expand Down
10 changes: 9 additions & 1 deletion compute_horde_sdk/src/compute_horde_core/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import ipaddress
import logging
import tempfile
from datetime import UTC, datetime, timedelta
from datetime import datetime, timedelta
from pathlib import Path

import aiohttp
Expand All @@ -13,6 +13,14 @@
from cryptography.x509 import Certificate
from cryptography.x509.oid import NameOID


try:
from datetime import UTC
except ImportError:
# Backward compatible with python 3.10
from datetime import timezone
UTC = timezone.utc

logger = logging.getLogger(__name__)


Expand Down
9 changes: 8 additions & 1 deletion compute_horde_sdk/src/compute_horde_core/executor_class.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from enum import StrEnum
try:
from enum import StrEnum
except ImportError:
# Backward compatible with python 3.10
from enum import Enum

class StrEnum(str, Enum):
def __str__(self):
return str(self.value)

class ExecutorClass(StrEnum):
spin_up_4min__gpu_24gb = "spin_up-4min.gpu-24gb"
Expand Down
11 changes: 10 additions & 1 deletion compute_horde_sdk/src/compute_horde_core/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
import re
import time
import typing
from enum import StrEnum
from typing import ClassVar, Protocol

import bittensor_wallet
from pydantic import BaseModel, JsonValue, field_serializer, field_validator

from compute_horde_core.streaming import StreamingDetails

try:
from enum import StrEnum
except ImportError:
# Backward compatible with python 3.10
from enum import Enum

class StrEnum(str, Enum):
def __str__(self):
return str(self.value)


class SignatureScope(StrEnum):
SignedFields = "SignedFields"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from datetime import timedelta
from typing import TYPE_CHECKING, Any, Self
from typing import TYPE_CHECKING, Any

import httpx

Expand All @@ -14,6 +14,12 @@
if TYPE_CHECKING:
from .client import FallbackClient

try:
from typing import Self
except ImportError:
# Backward compatible with python 3.10
from typing_extensions import Self


JOB_REFRESH_INTERVAL = timedelta(seconds=3)

Expand Down
19 changes: 17 additions & 2 deletions compute_horde_sdk/src/compute_horde_sdk/_internal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@
from abc import ABC, abstractmethod
from collections.abc import Mapping
from dataclasses import dataclass, field
from enum import StrEnum
from typing import Literal, Self
from typing import Literal

import pydantic

from compute_horde_core import output_upload as compute_horde_output_upload
from compute_horde_core import volume as compute_horde_volume

try:
from typing import Self
except ImportError:
# Backward compatible with python 3.10
from typing_extensions import Self

try:
from enum import StrEnum
except ImportError:
# Backward compatible with python 3.10
from enum import Enum

class StrEnum(str, Enum):
def __str__(self):
return str(self.value)

VOLUME_MOUNT_PATH_PREFIX = "/volume/"
OUTPUT_MOUNT_PATH_PREFIX = "/output/"

Expand Down
8 changes: 7 additions & 1 deletion compute_horde_sdk/src/compute_horde_sdk/_internal/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import time
from collections.abc import AsyncIterator, Awaitable, Callable, Coroutine, Mapping, Sequence
from datetime import timedelta
from typing import Any, Self, TypeAlias
from typing import Any, TypeAlias
from urllib.parse import urljoin

import bittensor_wallet
Expand Down Expand Up @@ -36,6 +36,12 @@
OutputVolume,
)

try:
from typing import Self
except ImportError:
# Backward compatible with python 3.10
from typing_extensions import Self

logger = logging.getLogger(__name__)

JOB_REFRESH_INTERVAL = timedelta(seconds=3)
Expand Down
4 changes: 2 additions & 2 deletions compute_horde_sdk/tests/unit/api/test_sdk.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from datetime import UTC, datetime, timedelta
from datetime import datetime, timedelta, timezone
from typing import TYPE_CHECKING

import bittensor_wallet
Expand Down Expand Up @@ -667,7 +667,7 @@ class Stop(Exception): ...
def stop_callback(job):
jobs.append(jobs)
# stop after running for a while
if datetime.now(UTC) - INITIAL_FROZEN_TIME > timedelta(minutes=10):
if datetime.now(timezone.utc) - INITIAL_FROZEN_TIME > timedelta(minutes=10): # noqa: UP017
raise Stop

with pytest.raises(Stop):
Expand Down
2 changes: 1 addition & 1 deletion compute_horde_sdk/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import datetime

INITIAL_FROZEN_TIME = datetime.datetime(2025, 1, 1, tzinfo=datetime.UTC)
INITIAL_FROZEN_TIME = datetime.datetime(2025, 1, 1, tzinfo=datetime.timezone.utc) # noqa: UP017
Loading