compute-horde-sdk 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compute_horde_sdk-0.0.0/LICENSE +21 -0
- compute_horde_sdk-0.0.0/PKG-INFO +160 -0
- compute_horde_sdk-0.0.0/README.md +141 -0
- compute_horde_sdk-0.0.0/pyproject.toml +156 -0
- compute_horde_sdk-0.0.0/src/compute_horde_core/__init__.py +0 -0
- compute_horde_sdk-0.0.0/src/compute_horde_core/executor_class.py +7 -0
- compute_horde_sdk-0.0.0/src/compute_horde_core/output_upload.py +83 -0
- compute_horde_sdk-0.0.0/src/compute_horde_core/signature.py +302 -0
- compute_horde_sdk-0.0.0/src/compute_horde_core/volume.py +88 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/__init__.py +0 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/_internal/__init__.py +5 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/_internal/exceptions.py +10 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/_internal/models.py +193 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/_internal/sdk.py +345 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/py.typed +0 -0
- compute_horde_sdk-0.0.0/src/compute_horde_sdk/v1/__init__.py +21 -0
- compute_horde_sdk-0.0.0/tests/__init__.py +0 -0
- compute_horde_sdk-0.0.0/tests/conftest.py +15 -0
- compute_horde_sdk-0.0.0/tests/unit/__init__.py +3 -0
- compute_horde_sdk-0.0.0/tests/unit/api/__init__.py +5 -0
- compute_horde_sdk-0.0.0/tests/unit/api/test_sdk.py +436 -0
- compute_horde_sdk-0.0.0/tests/unit/api/test_setup.py +16 -0
- compute_horde_sdk-0.0.0/tests/unit/internal/__init__.py +5 -0
- compute_horde_sdk-0.0.0/tests/unit/internal/test_setup.py +19 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 backend-developers-ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: compute-horde-sdk
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Author-Email: Reef Technologies <opensource@reef.pl>
|
|
5
|
+
License: MIT
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Project-URL: Source, https://github.com/backend-developers-ltd/compute-horde-sdk
|
|
13
|
+
Project-URL: Issue Tracker, https://github.com/backend-developers-ltd/compute-horde-sdk/issues
|
|
14
|
+
Requires-Python: <3.13,>=3.11
|
|
15
|
+
Requires-Dist: pydantic<3,>=2.10
|
|
16
|
+
Requires-Dist: httpx>=0.26.0
|
|
17
|
+
Requires-Dist: bittensor<9.1,>=9.0.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# compute_horde_sdk
|
|
21
|
+
[](https://github.com/backend-developers-ltd/compute-horde-sdk/actions?query=workflow%3A%22Continuous+Integration%22) [](https://pypi.python.org/pypi/compute_horde_sdk) [](https://pypi.python.org/pypi/compute_horde_sdk) [](https://pypi.python.org/pypi/compute_horde_sdk)
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
pip install compute-horde-sdk
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
> [!IMPORTANT]
|
|
32
|
+
> This package uses [ApiVer](#versioning), make sure to import `compute_horde_sdk.v1`.
|
|
33
|
+
|
|
34
|
+
Simple example:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import asyncio
|
|
38
|
+
import bittensor
|
|
39
|
+
from compute_horde_sdk.v1 import ComputeHordeClient, ExecutorClass
|
|
40
|
+
|
|
41
|
+
wallet = bittensor.wallet(name="...", hotkey="...")
|
|
42
|
+
|
|
43
|
+
compute_horde_client = ComputeHordeClient(
|
|
44
|
+
hotkey=wallet.hotkey,
|
|
45
|
+
compute_horde_validator_hotkey="...", # In the common case it's going to be the same as the ss58 address of the hotkey above.
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
async def main():
|
|
49
|
+
# Create a job to run on the Compute Horde.
|
|
50
|
+
job = await compute_horde_client.create_job(
|
|
51
|
+
executor_class=ExecutorClass.always_on__llm__a6000,
|
|
52
|
+
job_namespace="SN123.0",
|
|
53
|
+
docker_image="my-username/my-image:latest",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
await job.wait(timeout=10 * 60)
|
|
57
|
+
|
|
58
|
+
print(job.status) # Should be "Completed".
|
|
59
|
+
|
|
60
|
+
asyncio.run(main())
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Advanced example:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import asyncio
|
|
67
|
+
import bittensor
|
|
68
|
+
from compute_horde_sdk.v1 import ComputeHordeClient, ExecutorClass, InlineInputVolume, HuggingfaceInputVolume, HTTPInputVolume, HTTPOutputVolume
|
|
69
|
+
|
|
70
|
+
wallet = bittensor.wallet(name="...", hotkey="...")
|
|
71
|
+
|
|
72
|
+
compute_horde_client = ComputeHordeClient(
|
|
73
|
+
hotkey=wallet.hotkey,
|
|
74
|
+
compute_horde_validator_hotkey="...", # In the common case it's going to be the same as the ss58 address of the hotkey above.
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
async def main():
|
|
78
|
+
# Create a job to run on the Compute Horde.
|
|
79
|
+
job = await compute_horde_client.create_job(
|
|
80
|
+
executor_class=ExecutorClass.always_on__llm__a6000,
|
|
81
|
+
job_namespace="SN123.0",
|
|
82
|
+
docker_image="my-username/my-image:latest",
|
|
83
|
+
args=["main.py", "--block", "10000"],
|
|
84
|
+
env={"HF_HUB_ENABLE_HF_TRANSFER": "1"},
|
|
85
|
+
artifacts_dir="/artifacts",
|
|
86
|
+
input_volumes={
|
|
87
|
+
"/volume/models/model01": HuggingfaceInputVolume(
|
|
88
|
+
repo_id="my-username/my-model",
|
|
89
|
+
),
|
|
90
|
+
"/volume/data/version.txt": InlineInputVolume(
|
|
91
|
+
contents="dmVyc2lvbj0y",
|
|
92
|
+
),
|
|
93
|
+
"/volume/data/dataset.json": HTTPInputVolume(
|
|
94
|
+
url="https://my-dataset-bucket.s3.amazonaws.com/sample-dataset/data.json",
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
output_volumes={
|
|
98
|
+
"/output/image.png": HTTPOutputVolume(
|
|
99
|
+
http_method="PUT",
|
|
100
|
+
url="https://my-image-bucket.s3.amazonaws.com/images/image.png",
|
|
101
|
+
),
|
|
102
|
+
},
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
await job.wait(timeout=10 * 60)
|
|
106
|
+
|
|
107
|
+
print(job.status) # Should be "Completed".
|
|
108
|
+
print(job.result)
|
|
109
|
+
|
|
110
|
+
asyncio.run(main())
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Get job by UUID:
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
job = await client.get_job("7b522daa-e807-4094-8d96-99b9a863f960")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Iterate over all of your jobs:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
async for job in client.iter_jobs():
|
|
124
|
+
process(job)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Versioning
|
|
128
|
+
|
|
129
|
+
This package uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
130
|
+
TL;DR you are safe to use [compatible release version specifier](https://packaging.python.org/en/latest/specifications/version-specifiers/#compatible-release) `~=MAJOR.MINOR` in your `pyproject.toml` or `requirements.txt`.
|
|
131
|
+
|
|
132
|
+
Additionally, this package uses [ApiVer](https://www.youtube.com/watch?v=FgcoAKchPjk) to further reduce the risk of breaking changes.
|
|
133
|
+
This means, the public API of this package is explicitly versioned, e.g. `compute_horde_sdk.v1`, and will not change in a backwards-incompatible way even when `compute_horde_sdk.v2` is released.
|
|
134
|
+
|
|
135
|
+
Internal packages, i.e. prefixed by `compute_horde_sdk._` do not share these guarantees and may change in a backwards-incompatible way at any time even in patch releases.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
Pre-requisites:
|
|
142
|
+
- [pdm](https://pdm.fming.dev/)
|
|
143
|
+
- [nox](https://nox.thea.codes/en/stable/)
|
|
144
|
+
- [docker](https://www.docker.com/) and [docker compose plugin](https://docs.docker.com/compose/)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
Ideally, you should run `nox -t format lint` before every commit to ensure that the code is properly formatted and linted.
|
|
148
|
+
Before submitting a PR, make sure that tests pass as well, you can do so using:
|
|
149
|
+
```
|
|
150
|
+
nox -t check # equivalent to `nox -t format lint test`
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If you wish to install dependencies into `.venv` so your IDE can pick them up, you can do so using:
|
|
154
|
+
```
|
|
155
|
+
pdm install --dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Release process
|
|
159
|
+
|
|
160
|
+
Run `nox -s make_release -- X.Y.Z` where `X.Y.Z` is the version you're releasing and follow the printed instructions.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# compute_horde_sdk
|
|
2
|
+
[](https://github.com/backend-developers-ltd/compute-horde-sdk/actions?query=workflow%3A%22Continuous+Integration%22) [](https://pypi.python.org/pypi/compute_horde_sdk) [](https://pypi.python.org/pypi/compute_horde_sdk) [](https://pypi.python.org/pypi/compute_horde_sdk)
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
```
|
|
7
|
+
pip install compute-horde-sdk
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
> [!IMPORTANT]
|
|
13
|
+
> This package uses [ApiVer](#versioning), make sure to import `compute_horde_sdk.v1`.
|
|
14
|
+
|
|
15
|
+
Simple example:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import asyncio
|
|
19
|
+
import bittensor
|
|
20
|
+
from compute_horde_sdk.v1 import ComputeHordeClient, ExecutorClass
|
|
21
|
+
|
|
22
|
+
wallet = bittensor.wallet(name="...", hotkey="...")
|
|
23
|
+
|
|
24
|
+
compute_horde_client = ComputeHordeClient(
|
|
25
|
+
hotkey=wallet.hotkey,
|
|
26
|
+
compute_horde_validator_hotkey="...", # In the common case it's going to be the same as the ss58 address of the hotkey above.
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
async def main():
|
|
30
|
+
# Create a job to run on the Compute Horde.
|
|
31
|
+
job = await compute_horde_client.create_job(
|
|
32
|
+
executor_class=ExecutorClass.always_on__llm__a6000,
|
|
33
|
+
job_namespace="SN123.0",
|
|
34
|
+
docker_image="my-username/my-image:latest",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
await job.wait(timeout=10 * 60)
|
|
38
|
+
|
|
39
|
+
print(job.status) # Should be "Completed".
|
|
40
|
+
|
|
41
|
+
asyncio.run(main())
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Advanced example:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
import asyncio
|
|
48
|
+
import bittensor
|
|
49
|
+
from compute_horde_sdk.v1 import ComputeHordeClient, ExecutorClass, InlineInputVolume, HuggingfaceInputVolume, HTTPInputVolume, HTTPOutputVolume
|
|
50
|
+
|
|
51
|
+
wallet = bittensor.wallet(name="...", hotkey="...")
|
|
52
|
+
|
|
53
|
+
compute_horde_client = ComputeHordeClient(
|
|
54
|
+
hotkey=wallet.hotkey,
|
|
55
|
+
compute_horde_validator_hotkey="...", # In the common case it's going to be the same as the ss58 address of the hotkey above.
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
async def main():
|
|
59
|
+
# Create a job to run on the Compute Horde.
|
|
60
|
+
job = await compute_horde_client.create_job(
|
|
61
|
+
executor_class=ExecutorClass.always_on__llm__a6000,
|
|
62
|
+
job_namespace="SN123.0",
|
|
63
|
+
docker_image="my-username/my-image:latest",
|
|
64
|
+
args=["main.py", "--block", "10000"],
|
|
65
|
+
env={"HF_HUB_ENABLE_HF_TRANSFER": "1"},
|
|
66
|
+
artifacts_dir="/artifacts",
|
|
67
|
+
input_volumes={
|
|
68
|
+
"/volume/models/model01": HuggingfaceInputVolume(
|
|
69
|
+
repo_id="my-username/my-model",
|
|
70
|
+
),
|
|
71
|
+
"/volume/data/version.txt": InlineInputVolume(
|
|
72
|
+
contents="dmVyc2lvbj0y",
|
|
73
|
+
),
|
|
74
|
+
"/volume/data/dataset.json": HTTPInputVolume(
|
|
75
|
+
url="https://my-dataset-bucket.s3.amazonaws.com/sample-dataset/data.json",
|
|
76
|
+
),
|
|
77
|
+
},
|
|
78
|
+
output_volumes={
|
|
79
|
+
"/output/image.png": HTTPOutputVolume(
|
|
80
|
+
http_method="PUT",
|
|
81
|
+
url="https://my-image-bucket.s3.amazonaws.com/images/image.png",
|
|
82
|
+
),
|
|
83
|
+
},
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
await job.wait(timeout=10 * 60)
|
|
87
|
+
|
|
88
|
+
print(job.status) # Should be "Completed".
|
|
89
|
+
print(job.result)
|
|
90
|
+
|
|
91
|
+
asyncio.run(main())
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Get job by UUID:
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
job = await client.get_job("7b522daa-e807-4094-8d96-99b9a863f960")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Iterate over all of your jobs:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
async for job in client.iter_jobs():
|
|
105
|
+
process(job)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Versioning
|
|
109
|
+
|
|
110
|
+
This package uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
111
|
+
TL;DR you are safe to use [compatible release version specifier](https://packaging.python.org/en/latest/specifications/version-specifiers/#compatible-release) `~=MAJOR.MINOR` in your `pyproject.toml` or `requirements.txt`.
|
|
112
|
+
|
|
113
|
+
Additionally, this package uses [ApiVer](https://www.youtube.com/watch?v=FgcoAKchPjk) to further reduce the risk of breaking changes.
|
|
114
|
+
This means, the public API of this package is explicitly versioned, e.g. `compute_horde_sdk.v1`, and will not change in a backwards-incompatible way even when `compute_horde_sdk.v2` is released.
|
|
115
|
+
|
|
116
|
+
Internal packages, i.e. prefixed by `compute_horde_sdk._` do not share these guarantees and may change in a backwards-incompatible way at any time even in patch releases.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
Pre-requisites:
|
|
123
|
+
- [pdm](https://pdm.fming.dev/)
|
|
124
|
+
- [nox](https://nox.thea.codes/en/stable/)
|
|
125
|
+
- [docker](https://www.docker.com/) and [docker compose plugin](https://docs.docker.com/compose/)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
Ideally, you should run `nox -t format lint` before every commit to ensure that the code is properly formatted and linted.
|
|
129
|
+
Before submitting a PR, make sure that tests pass as well, you can do so using:
|
|
130
|
+
```
|
|
131
|
+
nox -t check # equivalent to `nox -t format lint test`
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
If you wish to install dependencies into `.venv` so your IDE can pick them up, you can do so using:
|
|
135
|
+
```
|
|
136
|
+
pdm install --dev
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Release process
|
|
140
|
+
|
|
141
|
+
Run `nox -s make_release -- X.Y.Z` where `X.Y.Z` is the version you're releasing and follow the printed instructions.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "compute-horde-sdk"
|
|
3
|
+
requires-python = ">=3.11,<3.13"
|
|
4
|
+
keywords = []
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Reef Technologies", email = "opensource@reef.pl" },
|
|
8
|
+
]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Intended Audience :: Developers",
|
|
11
|
+
"Topic :: Software Development :: Libraries",
|
|
12
|
+
"License :: OSI Approved :: MIT License",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Programming Language :: Python :: 3.11",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
]
|
|
17
|
+
dynamic = []
|
|
18
|
+
dependencies = [
|
|
19
|
+
"pydantic<3,>=2.10",
|
|
20
|
+
"httpx>=0.26.0",
|
|
21
|
+
"bittensor>=9.0.0,<9.1",
|
|
22
|
+
]
|
|
23
|
+
version = "0.0.0"
|
|
24
|
+
|
|
25
|
+
[project.license]
|
|
26
|
+
text = "MIT"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Source = "https://github.com/backend-developers-ltd/compute-horde-sdk"
|
|
30
|
+
"Issue Tracker" = "https://github.com/backend-developers-ltd/compute-horde-sdk/issues"
|
|
31
|
+
|
|
32
|
+
[build-system]
|
|
33
|
+
requires = [
|
|
34
|
+
"pdm-backend==2.4.3",
|
|
35
|
+
]
|
|
36
|
+
build-backend = "pdm.backend"
|
|
37
|
+
|
|
38
|
+
[tool.uv]
|
|
39
|
+
override-dependencies = [
|
|
40
|
+
"bt-decode>=0.5.0a2",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[tool.pdm]
|
|
44
|
+
distribution = true
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
pythonpath = [
|
|
48
|
+
".",
|
|
49
|
+
]
|
|
50
|
+
target_package_name = "compute_horde_sdk"
|
|
51
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
52
|
+
|
|
53
|
+
[tool.ruff]
|
|
54
|
+
line-length = 120
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = [
|
|
58
|
+
"D",
|
|
59
|
+
"E",
|
|
60
|
+
"F",
|
|
61
|
+
"I",
|
|
62
|
+
"UP",
|
|
63
|
+
"TC005",
|
|
64
|
+
]
|
|
65
|
+
ignore = [
|
|
66
|
+
"D100",
|
|
67
|
+
"D105",
|
|
68
|
+
"D107",
|
|
69
|
+
"D200",
|
|
70
|
+
"D202",
|
|
71
|
+
"D203",
|
|
72
|
+
"D205",
|
|
73
|
+
"D212",
|
|
74
|
+
"D400",
|
|
75
|
+
"D401",
|
|
76
|
+
"D415",
|
|
77
|
+
"D101",
|
|
78
|
+
"D102",
|
|
79
|
+
"D103",
|
|
80
|
+
"D104",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint.per-file-ignores]
|
|
84
|
+
"__init__.py" = [
|
|
85
|
+
"F401",
|
|
86
|
+
]
|
|
87
|
+
"test/**" = [
|
|
88
|
+
"D",
|
|
89
|
+
"F403",
|
|
90
|
+
"F405",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[tool.codespell]
|
|
94
|
+
skip = "*.min.js,pdm.lock"
|
|
95
|
+
ignore-words-list = "datas"
|
|
96
|
+
|
|
97
|
+
[tool.towncrier]
|
|
98
|
+
directory = "changelog.d"
|
|
99
|
+
filename = "CHANGELOG.md"
|
|
100
|
+
start_string = "<!-- towncrier release notes start -->\n"
|
|
101
|
+
underlines = [
|
|
102
|
+
"",
|
|
103
|
+
"",
|
|
104
|
+
"",
|
|
105
|
+
]
|
|
106
|
+
title_format = "## [{version}](https://github.com/backend-developers-ltd/compute-horde-sdk/releases/tag/v{version}) - {project_date}"
|
|
107
|
+
issue_format = "[#{issue}](https://github.com/backend-developers-ltd/compute-horde-sdk/issues/{issue})"
|
|
108
|
+
type = [
|
|
109
|
+
{ directory = "removed", name = "Removed", showcontent = true },
|
|
110
|
+
{ directory = "changed", name = "Changed", showcontent = true },
|
|
111
|
+
{ directory = "fixed", name = "Fixed", showcontent = true },
|
|
112
|
+
{ directory = "deprecated", name = "Deprecated", showcontent = true },
|
|
113
|
+
{ directory = "added", name = "Added", showcontent = true },
|
|
114
|
+
{ directory = "doc", name = "Doc", showcontent = true },
|
|
115
|
+
{ directory = "infrastructure", name = "Infrastructure", showcontent = true },
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[tool.mypy.overrides]]
|
|
119
|
+
module = [
|
|
120
|
+
"bittensor",
|
|
121
|
+
"nox",
|
|
122
|
+
"pytest",
|
|
123
|
+
"tests.*",
|
|
124
|
+
]
|
|
125
|
+
ignore_missing_imports = true
|
|
126
|
+
|
|
127
|
+
[dependency-groups]
|
|
128
|
+
format = [
|
|
129
|
+
"ruff",
|
|
130
|
+
]
|
|
131
|
+
lint = [
|
|
132
|
+
"ruff",
|
|
133
|
+
"codespell[toml]",
|
|
134
|
+
]
|
|
135
|
+
release = [
|
|
136
|
+
"towncrier>=23.11.0,<24",
|
|
137
|
+
]
|
|
138
|
+
type_check = [
|
|
139
|
+
"django-stubs[compatible-mypy]",
|
|
140
|
+
"djangorestframework-stubs[compatible-mypy]>=3.15.1",
|
|
141
|
+
"mypy",
|
|
142
|
+
"types-freezegun",
|
|
143
|
+
"types-python-dateutil",
|
|
144
|
+
"types-requests",
|
|
145
|
+
]
|
|
146
|
+
test = [
|
|
147
|
+
"pytest>=8.2.1",
|
|
148
|
+
"pytest-asyncio>=0.24.0",
|
|
149
|
+
"responses>=0.25.0",
|
|
150
|
+
"freezegun>=1.5.1",
|
|
151
|
+
"faker>=33.1.0",
|
|
152
|
+
"pytest-django>=4.9.0",
|
|
153
|
+
"pytest-apiver",
|
|
154
|
+
"pytest-xdist",
|
|
155
|
+
"pytest-httpx>=0.35.0",
|
|
156
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
import re
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Annotated, Literal
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
|
|
7
|
+
import pydantic
|
|
8
|
+
from pydantic import Field
|
|
9
|
+
|
|
10
|
+
SAFE_DOMAIN_REGEX = re.compile(r".*")
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class OutputUploadType(str, enum.Enum):
|
|
14
|
+
zip_and_http_post = "zip_and_http_post"
|
|
15
|
+
zip_and_http_put = "zip_and_http_put"
|
|
16
|
+
multi_upload = "multi_upload"
|
|
17
|
+
single_file_post = "single_file_post"
|
|
18
|
+
single_file_put = "single_file_put"
|
|
19
|
+
|
|
20
|
+
# default __str__ method returns "OutputUploadType.inline", we want just "inline"
|
|
21
|
+
def __str__(self):
|
|
22
|
+
return str.__str__(self)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class ZipAndHttpPostUpload(pydantic.BaseModel):
|
|
26
|
+
output_upload_type: Literal[OutputUploadType.zip_and_http_post] = OutputUploadType.zip_and_http_post
|
|
27
|
+
url: str
|
|
28
|
+
form_fields: Mapping[str, str] | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class ZipAndHttpPutUpload(pydantic.BaseModel):
|
|
32
|
+
output_upload_type: Literal[OutputUploadType.zip_and_http_put] = OutputUploadType.zip_and_http_put
|
|
33
|
+
url: str
|
|
34
|
+
# TODO: PUT implementation does not support it - find out why and clean up
|
|
35
|
+
# form_fields: Mapping[str, str] | None = None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SingleFilePostUpload(pydantic.BaseModel):
|
|
39
|
+
output_upload_type: Literal[OutputUploadType.single_file_post] = OutputUploadType.single_file_post
|
|
40
|
+
url: str
|
|
41
|
+
form_fields: Mapping[str, str] | None = None
|
|
42
|
+
relative_path: str
|
|
43
|
+
signed_headers: Mapping[str, str] | None = None
|
|
44
|
+
|
|
45
|
+
def is_safe(self) -> bool:
|
|
46
|
+
domain = urlparse(self.url).netloc
|
|
47
|
+
if SAFE_DOMAIN_REGEX.fullmatch(domain):
|
|
48
|
+
return True
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class SingleFilePutUpload(pydantic.BaseModel):
|
|
53
|
+
output_upload_type: Literal[OutputUploadType.single_file_put] = OutputUploadType.single_file_put
|
|
54
|
+
url: str
|
|
55
|
+
# TODO: PUT implementation does not support it - find out why and clean up
|
|
56
|
+
# form_fields: Mapping[str, str] | None = None
|
|
57
|
+
relative_path: str
|
|
58
|
+
signed_headers: Mapping[str, str] | None = None
|
|
59
|
+
|
|
60
|
+
def is_safe(self) -> bool:
|
|
61
|
+
domain = urlparse(self.url).netloc
|
|
62
|
+
if SAFE_DOMAIN_REGEX.fullmatch(domain):
|
|
63
|
+
return True
|
|
64
|
+
return False
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
SingleFileUpload = Annotated[
|
|
68
|
+
SingleFilePostUpload | SingleFilePutUpload,
|
|
69
|
+
Field(discriminator="output_upload_type"),
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class MultiUpload(pydantic.BaseModel):
|
|
74
|
+
output_upload_type: Literal[OutputUploadType.multi_upload] = OutputUploadType.multi_upload
|
|
75
|
+
uploads: list[SingleFileUpload]
|
|
76
|
+
# allow custom uploads for stdout and stderr
|
|
77
|
+
system_output: ZipAndHttpPostUpload | ZipAndHttpPutUpload | None = None
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
OutputUpload = Annotated[
|
|
81
|
+
SingleFilePostUpload | SingleFilePutUpload | ZipAndHttpPostUpload | ZipAndHttpPutUpload | MultiUpload,
|
|
82
|
+
Field(discriminator="output_upload_type"),
|
|
83
|
+
]
|