arkhai-kit-site 0.3.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.
- arkhai_kit_site-0.3.0/.gitignore +232 -0
- arkhai_kit_site-0.3.0/Makefile +9 -0
- arkhai_kit_site-0.3.0/PKG-INFO +10 -0
- arkhai_kit_site-0.3.0/pyproject.toml +32 -0
- arkhai_kit_site-0.3.0/src/market_site/__init__.py +36 -0
- arkhai_kit_site-0.3.0/src/market_site/authority.py +233 -0
- arkhai_kit_site-0.3.0/src/market_site/db.py +191 -0
- arkhai_kit_site-0.3.0/src/market_site/http_models.py +180 -0
- arkhai_kit_site-0.3.0/src/market_site/ledger.py +2162 -0
- arkhai_kit_site-0.3.0/src/market_site/projections.py +190 -0
- arkhai_kit_site-0.3.0/src/market_site/router.py +360 -0
- arkhai_kit_site-0.3.0/tests/unit/test_authority.py +129 -0
- arkhai_kit_site-0.3.0/tests/unit/test_dict_resource_satisfies_claim.py +137 -0
- arkhai_kit_site-0.3.0/tests/unit/test_import_boundaries.py +33 -0
- arkhai_kit_site-0.3.0/tests/unit/test_ledger.py +1348 -0
- arkhai_kit_site-0.3.0/tests/unit/test_projection_router.py +154 -0
- arkhai_kit_site-0.3.0/tests/unit/test_projections.py +240 -0
- arkhai_kit_site-0.3.0/tests/unit/test_resource_satisfies_requirement.py +134 -0
- arkhai_kit_site-0.3.0/tests/unit/test_settlement_assignment.py +155 -0
- arkhai_kit_site-0.3.0/uv.lock +489 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
.vscode/
|
|
2
|
+
|
|
3
|
+
# Project-local scratch files, private notes, and generated diagnostics.
|
|
4
|
+
.scm-local/
|
|
5
|
+
|
|
6
|
+
# Visible transfer staging for snap-confined tools such as Multipass.
|
|
7
|
+
scm-clean-room-transfer/
|
|
8
|
+
|
|
9
|
+
# Legacy local rehearsal params (private keys, RPC URLs, etc.).
|
|
10
|
+
.rehearsal-params.local.md
|
|
11
|
+
.rehearsal-params.local.*
|
|
12
|
+
|
|
13
|
+
### Python ###
|
|
14
|
+
# Byte-compiled / optimized / DLL files
|
|
15
|
+
__pycache__/
|
|
16
|
+
*.py[cod]
|
|
17
|
+
*$py.class
|
|
18
|
+
|
|
19
|
+
# C extensions
|
|
20
|
+
*.so
|
|
21
|
+
|
|
22
|
+
# Distribution / packaging
|
|
23
|
+
.Python
|
|
24
|
+
build/
|
|
25
|
+
develop-eggs/
|
|
26
|
+
dist/
|
|
27
|
+
downloads/
|
|
28
|
+
eggs/
|
|
29
|
+
.eggs/
|
|
30
|
+
lib/
|
|
31
|
+
lib64/
|
|
32
|
+
parts/
|
|
33
|
+
sdist/
|
|
34
|
+
var/
|
|
35
|
+
wheels/
|
|
36
|
+
share/python-wheels/
|
|
37
|
+
*.egg-info/
|
|
38
|
+
.installed.cfg
|
|
39
|
+
*.egg
|
|
40
|
+
MANIFEST
|
|
41
|
+
|
|
42
|
+
# PyInstaller
|
|
43
|
+
# Usually these files are written by a python script from a template
|
|
44
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
45
|
+
*.manifest
|
|
46
|
+
*.spec
|
|
47
|
+
|
|
48
|
+
# Installer logs
|
|
49
|
+
pip-log.txt
|
|
50
|
+
pip-delete-this-directory.txt
|
|
51
|
+
|
|
52
|
+
# Unit test / coverage reports
|
|
53
|
+
htmlcov/
|
|
54
|
+
.tox/
|
|
55
|
+
.nox/
|
|
56
|
+
.coverage
|
|
57
|
+
.coverage.*
|
|
58
|
+
.cache
|
|
59
|
+
nosetests.xml
|
|
60
|
+
coverage.xml
|
|
61
|
+
*.cover
|
|
62
|
+
*.py,cover
|
|
63
|
+
.hypothesis/
|
|
64
|
+
.pytest_cache/
|
|
65
|
+
cover/
|
|
66
|
+
|
|
67
|
+
# Translations
|
|
68
|
+
*.mo
|
|
69
|
+
*.pot
|
|
70
|
+
|
|
71
|
+
# Django stuff:
|
|
72
|
+
*.log
|
|
73
|
+
*.log.[0-9]*
|
|
74
|
+
local_settings.py
|
|
75
|
+
db.sqlite3
|
|
76
|
+
db.sqlite3-journal
|
|
77
|
+
|
|
78
|
+
# Flask stuff:
|
|
79
|
+
instance/
|
|
80
|
+
.webassets-cache
|
|
81
|
+
|
|
82
|
+
# Scrapy stuff:
|
|
83
|
+
.scrapy
|
|
84
|
+
|
|
85
|
+
# Sphinx documentation
|
|
86
|
+
docs/_build/
|
|
87
|
+
|
|
88
|
+
# PyBuilder
|
|
89
|
+
.pybuilder/
|
|
90
|
+
target/
|
|
91
|
+
|
|
92
|
+
# Jupyter Notebook
|
|
93
|
+
.ipynb_checkpoints
|
|
94
|
+
|
|
95
|
+
# IPython
|
|
96
|
+
profile_default/
|
|
97
|
+
ipython_config.py
|
|
98
|
+
|
|
99
|
+
# pyenv
|
|
100
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
101
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
102
|
+
# .python-version
|
|
103
|
+
|
|
104
|
+
# pipenv
|
|
105
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
106
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
107
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
108
|
+
# install all needed dependencies.
|
|
109
|
+
#Pipfile.lock
|
|
110
|
+
|
|
111
|
+
# poetry
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
113
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
114
|
+
# commonly ignored for libraries.
|
|
115
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
116
|
+
#poetry.lock
|
|
117
|
+
|
|
118
|
+
# pdm
|
|
119
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
120
|
+
#pdm.lock
|
|
121
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
122
|
+
# in version control.
|
|
123
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
124
|
+
.pdm.toml
|
|
125
|
+
|
|
126
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
127
|
+
__pypackages__/
|
|
128
|
+
|
|
129
|
+
# Celery stuff
|
|
130
|
+
celerybeat-schedule
|
|
131
|
+
celerybeat.pid
|
|
132
|
+
|
|
133
|
+
# SageMath parsed files
|
|
134
|
+
*.sage.py
|
|
135
|
+
|
|
136
|
+
# Environments
|
|
137
|
+
.env
|
|
138
|
+
.env.*
|
|
139
|
+
.venv
|
|
140
|
+
env/
|
|
141
|
+
venv/
|
|
142
|
+
ENV/
|
|
143
|
+
env.bak/
|
|
144
|
+
venv.bak/
|
|
145
|
+
|
|
146
|
+
# Spyder project settings
|
|
147
|
+
.spyderproject
|
|
148
|
+
.spyproject
|
|
149
|
+
|
|
150
|
+
# Rope project settings
|
|
151
|
+
.ropeproject
|
|
152
|
+
|
|
153
|
+
# mkdocs documentation
|
|
154
|
+
/site
|
|
155
|
+
|
|
156
|
+
# mypy
|
|
157
|
+
.mypy_cache/
|
|
158
|
+
.dmypy.json
|
|
159
|
+
dmypy.json
|
|
160
|
+
|
|
161
|
+
# Pyre type checker
|
|
162
|
+
.pyre/
|
|
163
|
+
|
|
164
|
+
# pytype static type analyzer
|
|
165
|
+
.pytype/
|
|
166
|
+
|
|
167
|
+
# Cython debug symbols
|
|
168
|
+
cython_debug/
|
|
169
|
+
|
|
170
|
+
# PyCharm
|
|
171
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
172
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
173
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
174
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
175
|
+
#.idea/
|
|
176
|
+
|
|
177
|
+
### Python Patch ###
|
|
178
|
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
|
179
|
+
poetry.toml
|
|
180
|
+
|
|
181
|
+
# ruff
|
|
182
|
+
.ruff_cache/
|
|
183
|
+
|
|
184
|
+
# LSP config files
|
|
185
|
+
pyrightconfig.json
|
|
186
|
+
|
|
187
|
+
# Infra
|
|
188
|
+
infra/*/*.tfvars
|
|
189
|
+
infra/*/*.tfstate
|
|
190
|
+
infra/*/*.tfstate.backup
|
|
191
|
+
infra/*/.terraform*
|
|
192
|
+
infra/*/*.plan
|
|
193
|
+
*.db
|
|
194
|
+
# PufferRL Experiments
|
|
195
|
+
experiments/
|
|
196
|
+
wandb/
|
|
197
|
+
!.env.sample
|
|
198
|
+
!.env.docker-compose
|
|
199
|
+
!.env.*.docker-compose
|
|
200
|
+
!.env.*.docker-compose
|
|
201
|
+
!.env.docker-compose
|
|
202
|
+
.cursor/
|
|
203
|
+
|
|
204
|
+
# Cloud Function
|
|
205
|
+
node_modules
|
|
206
|
+
|
|
207
|
+
# Puffer artifacts — ignore any resources/ dir or symlink at any depth
|
|
208
|
+
**/resources
|
|
209
|
+
pr-message-puffer.md
|
|
210
|
+
dev-env/state/state.json
|
|
211
|
+
shared-env/*
|
|
212
|
+
helm/Chart.lock
|
|
213
|
+
helm/charts/*.tgz
|
|
214
|
+
helm/.port-forward.pids
|
|
215
|
+
provisioning-service/settings.local.toml
|
|
216
|
+
provisioning-service/src/config/config-local.yml
|
|
217
|
+
.snapshot/*
|
|
218
|
+
|
|
219
|
+
# Per-env deployment scratch dirs (carry keys + per-env configs)
|
|
220
|
+
deploy-base-sepolia/
|
|
221
|
+
|
|
222
|
+
# Claude Code per-project state; shared skills are repository-owned.
|
|
223
|
+
.claude/*
|
|
224
|
+
!.claude/skills/
|
|
225
|
+
!.claude/skills/**
|
|
226
|
+
|
|
227
|
+
# Local assistant session exports
|
|
228
|
+
omp-session-*.html
|
|
229
|
+
pi-session-*.html
|
|
230
|
+
|
|
231
|
+
# Local-only mise overrides (machine-specific paths).
|
|
232
|
+
mise.local.toml
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: arkhai-kit-site
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Site-authority scaffold: capacity ledger, tables, and HTTP surface
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: arkhai-kit-resource-pools>=0.2.0
|
|
8
|
+
Requires-Dist: fastapi>=0.115.0
|
|
9
|
+
Requires-Dist: pydantic>=2.7
|
|
10
|
+
Requires-Dist: sqlalchemy>=2.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "arkhai-kit-site"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
license = "MIT"
|
|
5
|
+
description = "Site-authority scaffold: capacity ledger, tables, and HTTP surface"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"arkhai-kit-resource-pools>=0.2.0",
|
|
9
|
+
"fastapi>=0.115.0",
|
|
10
|
+
"pydantic>=2.7",
|
|
11
|
+
"sqlalchemy>=2.0",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["hatchling"]
|
|
16
|
+
build-backend = "hatchling.build"
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.wheel]
|
|
19
|
+
packages = ["src/market_site"]
|
|
20
|
+
|
|
21
|
+
[tool.uv]
|
|
22
|
+
find-links = ["../../.dist"]
|
|
23
|
+
|
|
24
|
+
[tool.pytest.ini_options]
|
|
25
|
+
pythonpath = ["src"]
|
|
26
|
+
testpaths = ["tests/unit"]
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"httpx2",
|
|
31
|
+
"pytest>=8.3.4,<9.0.0",
|
|
32
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Site-authority scaffold: capacity ledger, tables, and HTTP surface.
|
|
2
|
+
|
|
3
|
+
The shared half of a site-authority service
|
|
4
|
+
(docs/development/ARCHITECTURE.md, "Capacity and the Site Authority"):
|
|
5
|
+
the unit-counted resource ledger, reservation holds with their lease
|
|
6
|
+
tail, the anonymous versioned capacity-event feed, and the
|
|
7
|
+
``/capacity`` router mirroring the ``SiteCapacityAuthority`` contract. A
|
|
8
|
+
hosting service (the VM provisioning service; the API-credits service)
|
|
9
|
+
mounts the tables on its engine and the router on its app.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from .authority import ( # noqa: F401
|
|
13
|
+
LedgerSiteAuthority,
|
|
14
|
+
SiteAuthorityLedger,
|
|
15
|
+
SiteAuthorityPort,
|
|
16
|
+
)
|
|
17
|
+
from .db import ( # noqa: F401
|
|
18
|
+
HELD_RESERVATION_STATES,
|
|
19
|
+
ReservationState,
|
|
20
|
+
Base,
|
|
21
|
+
CapacityEvent,
|
|
22
|
+
CapacityReservation,
|
|
23
|
+
)
|
|
24
|
+
from .ledger import ( # noqa: F401
|
|
25
|
+
CapacityConflictError,
|
|
26
|
+
EXECUTOR_KIND_CLAIM_KEY,
|
|
27
|
+
CapacityLedgerService,
|
|
28
|
+
dict_resource_satisfies_claim,
|
|
29
|
+
parse_utc,
|
|
30
|
+
ResourceFeasibilityView,
|
|
31
|
+
resource_feasibility_view,
|
|
32
|
+
resource_satisfies_requirement,
|
|
33
|
+
SettlementAbandonmentHook,
|
|
34
|
+
UndeclaredOfferingModeError,
|
|
35
|
+
)
|
|
36
|
+
from .router import make_capacity_router # noqa: F401
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"""Executor-neutral site authority port and ledger adapter."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Any, Protocol
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SiteAuthorityPort(Protocol):
|
|
10
|
+
"""Reservation lifecycle facts consumed by compute orchestration."""
|
|
11
|
+
|
|
12
|
+
def list_reservations(self, *, state: str | None = None) -> list[dict[str, Any]]: ...
|
|
13
|
+
|
|
14
|
+
def list_time_bounded_reservations_due(self, now: datetime) -> list[dict[str, Any]]: ...
|
|
15
|
+
|
|
16
|
+
def get_reservation(self, capacity_reservation_id: str) -> dict[str, Any] | None: ...
|
|
17
|
+
|
|
18
|
+
def get_reservation_by_escrow(self, escrow_uid: str) -> dict[str, Any] | None: ...
|
|
19
|
+
|
|
20
|
+
def attach_lease_reservation(
|
|
21
|
+
self,
|
|
22
|
+
*,
|
|
23
|
+
capacity_reservation_id: str | None = None,
|
|
24
|
+
escrow_uid: str | None = None,
|
|
25
|
+
executor_kind: str | None = None,
|
|
26
|
+
executor_target: str | None = None,
|
|
27
|
+
executor_ref: dict[str, Any] | None = None,
|
|
28
|
+
lease_start_utc: str | None = None,
|
|
29
|
+
lease_end_utc: str | None = None,
|
|
30
|
+
create_job_id: str | None = None,
|
|
31
|
+
) -> dict[str, Any] | None: ...
|
|
32
|
+
|
|
33
|
+
def update_reservation_fields(
|
|
34
|
+
self,
|
|
35
|
+
capacity_reservation_id: str,
|
|
36
|
+
*,
|
|
37
|
+
executor_kind: str | None = None,
|
|
38
|
+
executor_target: str | None = None,
|
|
39
|
+
executor_ref: dict[str, Any] | None = None,
|
|
40
|
+
lease_start_utc: str | None = None,
|
|
41
|
+
lease_end_utc: str | None = None,
|
|
42
|
+
release_job_id: str | None = None,
|
|
43
|
+
create_job_id: str | None = None,
|
|
44
|
+
) -> dict[str, Any] | None: ...
|
|
45
|
+
|
|
46
|
+
def begin_release(
|
|
47
|
+
self, capacity_reservation_id: str, *, release_job_id: str
|
|
48
|
+
) -> dict[str, Any] | None: ...
|
|
49
|
+
|
|
50
|
+
def record_release_failure(
|
|
51
|
+
self,
|
|
52
|
+
capacity_reservation_id: str,
|
|
53
|
+
*,
|
|
54
|
+
reason: str,
|
|
55
|
+
message: str | None = None,
|
|
56
|
+
) -> dict[str, Any] | None: ...
|
|
57
|
+
|
|
58
|
+
def record_release_success(
|
|
59
|
+
self,
|
|
60
|
+
capacity_reservation_id: str,
|
|
61
|
+
*,
|
|
62
|
+
forced: bool = False,
|
|
63
|
+
reason: str | None = None,
|
|
64
|
+
message: str | None = None,
|
|
65
|
+
) -> dict[str, Any] | None: ...
|
|
66
|
+
|
|
67
|
+
def record_unmanaged(
|
|
68
|
+
self, capacity_reservation_id: str, *, reason: str, message: str | None = None
|
|
69
|
+
) -> dict[str, Any] | None: ...
|
|
70
|
+
|
|
71
|
+
def capacity_events_after(
|
|
72
|
+
self, after_version: int, *, limit: int = 500
|
|
73
|
+
) -> tuple[list[dict[str, Any]], int]: ...
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class SiteAuthorityLedger(Protocol):
|
|
77
|
+
"""Persistence operations supplied by the site ledger."""
|
|
78
|
+
|
|
79
|
+
def list_reservations(self, *, state: str | None = None) -> list[dict[str, Any]]: ...
|
|
80
|
+
|
|
81
|
+
def list_lease_due(self, now: datetime) -> list[dict[str, Any]]: ...
|
|
82
|
+
|
|
83
|
+
def get_reservation(self, capacity_reservation_id: str) -> dict[str, Any] | None: ...
|
|
84
|
+
|
|
85
|
+
def get_reservation_by_escrow(self, escrow_uid: str) -> dict[str, Any] | None: ...
|
|
86
|
+
|
|
87
|
+
def attach_lease(self, **fields: Any) -> dict[str, Any] | None: ...
|
|
88
|
+
|
|
89
|
+
def update_lease_fields(
|
|
90
|
+
self, capacity_reservation_id: str, **fields: Any
|
|
91
|
+
) -> dict[str, Any] | None: ...
|
|
92
|
+
|
|
93
|
+
def begin_releasing(
|
|
94
|
+
self, capacity_reservation_id: str, *, release_job_id: str | None = None
|
|
95
|
+
) -> dict[str, Any] | None: ...
|
|
96
|
+
|
|
97
|
+
def update_reservation_state(
|
|
98
|
+
self,
|
|
99
|
+
capacity_reservation_id: str,
|
|
100
|
+
*,
|
|
101
|
+
state: str,
|
|
102
|
+
failure_reason: str | None = None,
|
|
103
|
+
failure_message: str | None = None,
|
|
104
|
+
) -> dict[str, Any] | None: ...
|
|
105
|
+
|
|
106
|
+
def release(
|
|
107
|
+
self,
|
|
108
|
+
*,
|
|
109
|
+
capacity_reservation_id: str,
|
|
110
|
+
state: str = "released",
|
|
111
|
+
failure_reason: str | None = None,
|
|
112
|
+
failure_message: str | None = None,
|
|
113
|
+
) -> dict[str, Any] | None: ...
|
|
114
|
+
|
|
115
|
+
def events_after(
|
|
116
|
+
self, after_version: int, *, limit: int = 500
|
|
117
|
+
) -> tuple[list[dict[str, Any]], int]: ...
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class LedgerSiteAuthority:
|
|
121
|
+
"""Adapt the transactional site ledger to :class:`SiteAuthorityPort`."""
|
|
122
|
+
|
|
123
|
+
def __init__(self, ledger: SiteAuthorityLedger) -> None:
|
|
124
|
+
self._ledger = ledger
|
|
125
|
+
|
|
126
|
+
def list_reservations(self, *, state: str | None = None) -> list[dict[str, Any]]:
|
|
127
|
+
return self._ledger.list_reservations(state=state)
|
|
128
|
+
|
|
129
|
+
def list_time_bounded_reservations_due(self, now: datetime) -> list[dict[str, Any]]:
|
|
130
|
+
return self._ledger.list_lease_due(now)
|
|
131
|
+
|
|
132
|
+
def get_reservation(self, capacity_reservation_id: str) -> dict[str, Any] | None:
|
|
133
|
+
return self._ledger.get_reservation(capacity_reservation_id)
|
|
134
|
+
|
|
135
|
+
def get_reservation_by_escrow(self, escrow_uid: str) -> dict[str, Any] | None:
|
|
136
|
+
return self._ledger.get_reservation_by_escrow(escrow_uid)
|
|
137
|
+
|
|
138
|
+
def attach_lease_reservation(
|
|
139
|
+
self,
|
|
140
|
+
*,
|
|
141
|
+
capacity_reservation_id: str | None = None,
|
|
142
|
+
escrow_uid: str | None = None,
|
|
143
|
+
executor_kind: str | None = None,
|
|
144
|
+
executor_target: str | None = None,
|
|
145
|
+
executor_ref: dict[str, Any] | None = None,
|
|
146
|
+
lease_start_utc: str | None = None,
|
|
147
|
+
lease_end_utc: str | None = None,
|
|
148
|
+
create_job_id: str | None = None,
|
|
149
|
+
) -> dict[str, Any] | None:
|
|
150
|
+
return self._ledger.attach_lease(
|
|
151
|
+
capacity_reservation_id=capacity_reservation_id,
|
|
152
|
+
escrow_uid=escrow_uid,
|
|
153
|
+
executor_kind=executor_kind,
|
|
154
|
+
executor_target=executor_target,
|
|
155
|
+
executor_ref=executor_ref,
|
|
156
|
+
lease_start_utc=lease_start_utc,
|
|
157
|
+
lease_end_utc=lease_end_utc,
|
|
158
|
+
create_job_id=create_job_id,
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
def update_reservation_fields(
|
|
162
|
+
self,
|
|
163
|
+
capacity_reservation_id: str,
|
|
164
|
+
*,
|
|
165
|
+
executor_kind: str | None = None,
|
|
166
|
+
executor_target: str | None = None,
|
|
167
|
+
executor_ref: dict[str, Any] | None = None,
|
|
168
|
+
lease_start_utc: str | None = None,
|
|
169
|
+
lease_end_utc: str | None = None,
|
|
170
|
+
release_job_id: str | None = None,
|
|
171
|
+
create_job_id: str | None = None,
|
|
172
|
+
) -> dict[str, Any] | None:
|
|
173
|
+
return self._ledger.update_lease_fields(
|
|
174
|
+
capacity_reservation_id,
|
|
175
|
+
executor_kind=executor_kind,
|
|
176
|
+
executor_target=executor_target,
|
|
177
|
+
executor_ref=executor_ref,
|
|
178
|
+
lease_start_utc=lease_start_utc,
|
|
179
|
+
lease_end_utc=lease_end_utc,
|
|
180
|
+
release_job_id=release_job_id,
|
|
181
|
+
create_job_id=create_job_id,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
def begin_release(
|
|
185
|
+
self, capacity_reservation_id: str, *, release_job_id: str
|
|
186
|
+
) -> dict[str, Any] | None:
|
|
187
|
+
return self._ledger.begin_releasing(
|
|
188
|
+
capacity_reservation_id, release_job_id=release_job_id
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
def record_release_failure(
|
|
192
|
+
self,
|
|
193
|
+
capacity_reservation_id: str,
|
|
194
|
+
*,
|
|
195
|
+
reason: str,
|
|
196
|
+
message: str | None = None,
|
|
197
|
+
) -> dict[str, Any] | None:
|
|
198
|
+
return self._ledger.update_reservation_state(
|
|
199
|
+
capacity_reservation_id,
|
|
200
|
+
state="release_failed",
|
|
201
|
+
failure_reason=reason,
|
|
202
|
+
failure_message=message,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
def record_release_success(
|
|
206
|
+
self,
|
|
207
|
+
capacity_reservation_id: str,
|
|
208
|
+
*,
|
|
209
|
+
forced: bool = False,
|
|
210
|
+
reason: str | None = None,
|
|
211
|
+
message: str | None = None,
|
|
212
|
+
) -> dict[str, Any] | None:
|
|
213
|
+
return self._ledger.release(
|
|
214
|
+
capacity_reservation_id=capacity_reservation_id,
|
|
215
|
+
state="force_released" if forced else "released",
|
|
216
|
+
failure_reason=reason,
|
|
217
|
+
failure_message=message,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
def record_unmanaged(
|
|
221
|
+
self, capacity_reservation_id: str, *, reason: str, message: str | None = None
|
|
222
|
+
) -> dict[str, Any] | None:
|
|
223
|
+
return self._ledger.update_reservation_state(
|
|
224
|
+
capacity_reservation_id,
|
|
225
|
+
state="unmanaged",
|
|
226
|
+
failure_reason=reason,
|
|
227
|
+
failure_message=message,
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
def capacity_events_after(
|
|
231
|
+
self, after_version: int, *, limit: int = 500
|
|
232
|
+
) -> tuple[list[dict[str, Any]], int]:
|
|
233
|
+
return self._ledger.events_after(after_version, limit=limit)
|