fleetml 0.6.0__py3-none-any.whl
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.
- fleetml/__init__.py +44 -0
- fleetml/client.py +377 -0
- fleetml/errors.py +19 -0
- fleetml/py.typed +0 -0
- fleetml/types.py +336 -0
- fleetml-0.6.0.dist-info/METADATA +65 -0
- fleetml-0.6.0.dist-info/RECORD +10 -0
- fleetml-0.6.0.dist-info/WHEEL +4 -0
- fleetml-0.6.0.dist-info/licenses/LICENSE +190 -0
- fleetml-0.6.0.dist-info/licenses/NOTICE +29 -0
fleetml/__init__.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""FleetML client: push models and run rollouts on a FleetML server from Python.
|
|
2
|
+
|
|
3
|
+
The library speaks the server's REST API, the same API the ``fleetml`` CLI uses,
|
|
4
|
+
with the same words: projects, models, versions, push, enrollment keys,
|
|
5
|
+
deployments, devices, telemetry, experiments and drift.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from fleetml.client import TERMINAL_DEPLOYMENT_STATUSES, FleetML
|
|
9
|
+
from fleetml.errors import FleetMLError
|
|
10
|
+
from fleetml.types import (
|
|
11
|
+
ArmResult,
|
|
12
|
+
Deployment,
|
|
13
|
+
Device,
|
|
14
|
+
DriftResult,
|
|
15
|
+
EnrollmentKey,
|
|
16
|
+
Experiment,
|
|
17
|
+
ExperimentResults,
|
|
18
|
+
Model,
|
|
19
|
+
Project,
|
|
20
|
+
TelemetrySummary,
|
|
21
|
+
Version,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# The package version: the single place it is set (pyproject.toml reads it),
|
|
25
|
+
# equal to the FleetML release it ships with.
|
|
26
|
+
__version__ = "0.6.0"
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"TERMINAL_DEPLOYMENT_STATUSES",
|
|
30
|
+
"ArmResult",
|
|
31
|
+
"Deployment",
|
|
32
|
+
"Device",
|
|
33
|
+
"DriftResult",
|
|
34
|
+
"EnrollmentKey",
|
|
35
|
+
"Experiment",
|
|
36
|
+
"ExperimentResults",
|
|
37
|
+
"FleetML",
|
|
38
|
+
"FleetMLError",
|
|
39
|
+
"Model",
|
|
40
|
+
"Project",
|
|
41
|
+
"TelemetrySummary",
|
|
42
|
+
"Version",
|
|
43
|
+
"__version__",
|
|
44
|
+
]
|
fleetml/client.py
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
"""The FleetML client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import contextlib
|
|
6
|
+
import hashlib
|
|
7
|
+
import os
|
|
8
|
+
import time
|
|
9
|
+
from typing import Any, Collection, Dict, List, Mapping, Optional, Sequence, Union
|
|
10
|
+
|
|
11
|
+
import httpx
|
|
12
|
+
|
|
13
|
+
from fleetml.errors import FleetMLError
|
|
14
|
+
from fleetml.types import (
|
|
15
|
+
Deployment,
|
|
16
|
+
Device,
|
|
17
|
+
DriftResult,
|
|
18
|
+
EnrollmentKey,
|
|
19
|
+
Experiment,
|
|
20
|
+
ExperimentResults,
|
|
21
|
+
Model,
|
|
22
|
+
Project,
|
|
23
|
+
TelemetrySummary,
|
|
24
|
+
Version,
|
|
25
|
+
from_list,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
DEFAULT_SERVER = "http://localhost:18080"
|
|
29
|
+
|
|
30
|
+
#: Deployment statuses after which a deployment no longer changes by itself.
|
|
31
|
+
TERMINAL_DEPLOYMENT_STATUSES = frozenset({"COMPLETE", "ROLLED_BACK", "CANCELLED", "FAILED"})
|
|
32
|
+
|
|
33
|
+
Json = Dict[str, Any]
|
|
34
|
+
PathLike = Union[str, "os.PathLike[str]"]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class FleetML:
|
|
38
|
+
"""A client for a FleetML server's REST API.
|
|
39
|
+
|
|
40
|
+
``server`` defaults to ``FLEETML_SERVER``, then ``http://localhost:18080``;
|
|
41
|
+
``api_key`` (an admin API key, sent as ``Authorization: Bearer``) defaults
|
|
42
|
+
to ``FLEETML_API_KEY``. Every call raises :class:`FleetMLError` when the
|
|
43
|
+
server refuses it or cannot be reached. Use it as a context manager, or
|
|
44
|
+
call :meth:`close`.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
server: Optional[str] = None,
|
|
50
|
+
api_key: Optional[str] = None,
|
|
51
|
+
*,
|
|
52
|
+
timeout: float = 30.0,
|
|
53
|
+
transport: Optional[httpx.BaseTransport] = None,
|
|
54
|
+
) -> None:
|
|
55
|
+
self.server = (server or os.environ.get("FLEETML_SERVER") or DEFAULT_SERVER).rstrip("/")
|
|
56
|
+
self._api_key = api_key if api_key is not None else os.environ.get("FLEETML_API_KEY", "")
|
|
57
|
+
self._http = httpx.Client(timeout=timeout, transport=transport)
|
|
58
|
+
self.projects = Projects(self)
|
|
59
|
+
self.models = Models(self)
|
|
60
|
+
self.versions = Versions(self)
|
|
61
|
+
self.enrollment_keys = EnrollmentKeys(self)
|
|
62
|
+
self.deployments = Deployments(self)
|
|
63
|
+
self.devices = Devices(self)
|
|
64
|
+
self.telemetry = Telemetry(self)
|
|
65
|
+
self.experiments = Experiments(self)
|
|
66
|
+
self.drift = Drift(self)
|
|
67
|
+
|
|
68
|
+
def close(self) -> None:
|
|
69
|
+
self._http.close()
|
|
70
|
+
|
|
71
|
+
def __enter__(self) -> FleetML:
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
def __exit__(self, *_: object) -> None:
|
|
75
|
+
self.close()
|
|
76
|
+
|
|
77
|
+
def __repr__(self) -> str:
|
|
78
|
+
return f"FleetML(server={self.server!r})"
|
|
79
|
+
|
|
80
|
+
def _request(
|
|
81
|
+
self,
|
|
82
|
+
method: str,
|
|
83
|
+
path: str,
|
|
84
|
+
body: Optional[Mapping[str, Any]] = None,
|
|
85
|
+
params: Optional[Mapping[str, Any]] = None,
|
|
86
|
+
) -> Any:
|
|
87
|
+
"""Calls ``/api/v1`` + path and returns the response's ``data``."""
|
|
88
|
+
headers = {"Authorization": f"Bearer {self._api_key}"} if self._api_key else {}
|
|
89
|
+
try:
|
|
90
|
+
resp = self._http.request(method, f"{self.server}/api/v1{path}", json=body, params=params, headers=headers)
|
|
91
|
+
except httpx.HTTPError as e:
|
|
92
|
+
raise FleetMLError(0, "UNAVAILABLE", f"server unavailable: {e}") from e
|
|
93
|
+
if resp.status_code == 204:
|
|
94
|
+
return None
|
|
95
|
+
try:
|
|
96
|
+
payload = resp.json()
|
|
97
|
+
except ValueError:
|
|
98
|
+
payload = None
|
|
99
|
+
if not isinstance(payload, dict):
|
|
100
|
+
if resp.is_error:
|
|
101
|
+
raise FleetMLError(resp.status_code, "HTTP_ERROR", resp.text[:500] or resp.reason_phrase)
|
|
102
|
+
raise FleetMLError(resp.status_code, "INVALID_RESPONSE", resp.text[:500])
|
|
103
|
+
err = payload.get("error")
|
|
104
|
+
if isinstance(err, dict) or resp.is_error:
|
|
105
|
+
err = err if isinstance(err, dict) else {}
|
|
106
|
+
code = str(err.get("code") or "HTTP_ERROR")
|
|
107
|
+
message = str(err.get("message") or resp.reason_phrase)
|
|
108
|
+
if resp.status_code == 401:
|
|
109
|
+
message += " (pass api_key= or set FLEETML_API_KEY to an admin API key)"
|
|
110
|
+
raise FleetMLError(resp.status_code, code, message)
|
|
111
|
+
return payload.get("data")
|
|
112
|
+
|
|
113
|
+
@staticmethod
|
|
114
|
+
def _page(limit: Optional[int], offset: Optional[int]) -> Json:
|
|
115
|
+
return {k: v for k, v in (("limit", limit), ("offset", offset)) if v is not None}
|
|
116
|
+
|
|
117
|
+
def push(
|
|
118
|
+
self,
|
|
119
|
+
path: PathLike,
|
|
120
|
+
project: str,
|
|
121
|
+
model: str,
|
|
122
|
+
version: str,
|
|
123
|
+
quantization: str = "INT8",
|
|
124
|
+
target_runtime: str = "TFLITE",
|
|
125
|
+
task: str = "CLASSIFICATION",
|
|
126
|
+
promote: bool = False,
|
|
127
|
+
) -> Version:
|
|
128
|
+
"""Uploads a model file as a variant of ``model`` ``version`` in
|
|
129
|
+
``project``, like ``fleetml push``: it creates the model (with
|
|
130
|
+
``target_runtime`` as its framework and ``task``) and the version if
|
|
131
|
+
they do not exist, declares the variant with the file's size and
|
|
132
|
+
sha256, uploads the file to the presigned URL (without the API key),
|
|
133
|
+
and asks the server to verify it. With ``promote`` the version is then
|
|
134
|
+
moved to STAGED and ACTIVE. Returns the version.
|
|
135
|
+
"""
|
|
136
|
+
size = os.path.getsize(path)
|
|
137
|
+
digest = hashlib.sha256()
|
|
138
|
+
with open(path, "rb") as f:
|
|
139
|
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
|
140
|
+
digest.update(chunk)
|
|
141
|
+
|
|
142
|
+
try:
|
|
143
|
+
model_obj = self.models.create(project, model, framework=target_runtime, task=task)
|
|
144
|
+
except FleetMLError as create_err:
|
|
145
|
+
found = [m for m in self.models.list(project) if m.name == model]
|
|
146
|
+
if not found:
|
|
147
|
+
raise create_err
|
|
148
|
+
model_obj = found[0]
|
|
149
|
+
|
|
150
|
+
try:
|
|
151
|
+
version_obj = self.versions.create(model_obj.id, version)
|
|
152
|
+
except FleetMLError as create_err:
|
|
153
|
+
found_v = [v for v in self.versions.list(model_obj.id) if v.version == version]
|
|
154
|
+
if not found_v:
|
|
155
|
+
raise create_err
|
|
156
|
+
version_obj = found_v[0]
|
|
157
|
+
|
|
158
|
+
created = self._request(
|
|
159
|
+
"POST",
|
|
160
|
+
f"/versions/{version_obj.id}/variants",
|
|
161
|
+
{
|
|
162
|
+
"quantization": quantization,
|
|
163
|
+
"target_runtime": target_runtime,
|
|
164
|
+
"blob_size_bytes": size,
|
|
165
|
+
"blob_sha256": digest.hexdigest(),
|
|
166
|
+
},
|
|
167
|
+
)
|
|
168
|
+
upload_url = str(created["upload_url"])
|
|
169
|
+
variant_id = str(created["variant"]["id"])
|
|
170
|
+
|
|
171
|
+
with open(path, "rb") as f:
|
|
172
|
+
try:
|
|
173
|
+
resp = self._http.put(upload_url, content=f, headers={"Content-Length": str(size)})
|
|
174
|
+
except httpx.HTTPError as e:
|
|
175
|
+
raise FleetMLError(0, "UPLOAD_FAILED", f"upload failed: {e}") from e
|
|
176
|
+
if resp.status_code >= 300:
|
|
177
|
+
raise FleetMLError(resp.status_code, "UPLOAD_FAILED", f"upload failed: HTTP {resp.status_code}")
|
|
178
|
+
|
|
179
|
+
self._request("POST", f"/variants/{variant_id}/finalize")
|
|
180
|
+
if promote:
|
|
181
|
+
# DRAFT -> STAGED -> ACTIVE, as the CLI does (a version that is
|
|
182
|
+
# already further along keeps its status).
|
|
183
|
+
for status in ("STAGED", "ACTIVE"):
|
|
184
|
+
with contextlib.suppress(FleetMLError):
|
|
185
|
+
self._request("PATCH", f"/versions/{version_obj.id}/status", {"status": status})
|
|
186
|
+
return self.versions.get(version_obj.id)
|
|
187
|
+
|
|
188
|
+
def wait_for_deployment(
|
|
189
|
+
self,
|
|
190
|
+
deployment_id: str,
|
|
191
|
+
timeout: float = 600.0,
|
|
192
|
+
interval: float = 2.0,
|
|
193
|
+
statuses: Collection[str] = TERMINAL_DEPLOYMENT_STATUSES,
|
|
194
|
+
) -> Deployment:
|
|
195
|
+
"""Polls a deployment until its status is one of ``statuses`` (by
|
|
196
|
+
default COMPLETE, ROLLED_BACK, CANCELLED or FAILED) and returns it.
|
|
197
|
+
Raises :class:`TimeoutError` after ``timeout`` seconds."""
|
|
198
|
+
deadline = time.monotonic() + timeout
|
|
199
|
+
while True:
|
|
200
|
+
d = self.deployments.get(deployment_id)
|
|
201
|
+
if d.status in statuses:
|
|
202
|
+
return d
|
|
203
|
+
if time.monotonic() >= deadline:
|
|
204
|
+
raise TimeoutError(f"deployment {deployment_id} is still {d.status} after {timeout:g}s")
|
|
205
|
+
time.sleep(interval)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class _API:
|
|
209
|
+
def __init__(self, client: FleetML) -> None:
|
|
210
|
+
self._c = client
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class Projects(_API):
|
|
214
|
+
"""``fleetml project``."""
|
|
215
|
+
|
|
216
|
+
def create(self, name: str, description: str = "") -> Project:
|
|
217
|
+
return Project.from_api(self._c._request("POST", "/projects", {"name": name, "description": description}))
|
|
218
|
+
|
|
219
|
+
def list(self, limit: Optional[int] = None, offset: Optional[int] = None) -> List[Project]:
|
|
220
|
+
return from_list(self._c._request("GET", "/projects", params=self._c._page(limit, offset)), Project.from_api)
|
|
221
|
+
|
|
222
|
+
def get(self, project_id: str) -> Project:
|
|
223
|
+
return Project.from_api(self._c._request("GET", f"/projects/{project_id}"))
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class Models(_API):
|
|
227
|
+
"""``fleetml model``."""
|
|
228
|
+
|
|
229
|
+
def create(self, project: str, name: str, framework: str = "TFLITE", task: str = "CLASSIFICATION") -> Model:
|
|
230
|
+
body = {"name": name, "framework": framework, "task_type": task}
|
|
231
|
+
return Model.from_api(self._c._request("POST", f"/projects/{project}/models", body))
|
|
232
|
+
|
|
233
|
+
def list(self, project: str, limit: Optional[int] = None, offset: Optional[int] = None) -> List[Model]:
|
|
234
|
+
data = self._c._request("GET", f"/projects/{project}/models", params=self._c._page(limit, offset))
|
|
235
|
+
return from_list(data, Model.from_api)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class Versions(_API):
|
|
239
|
+
"""``fleetml ver``."""
|
|
240
|
+
|
|
241
|
+
def create(self, model: str, version: str, metadata: Optional[Mapping[str, Any]] = None) -> Version:
|
|
242
|
+
body: Json = {"version": version}
|
|
243
|
+
if metadata is not None:
|
|
244
|
+
body["metadata"] = dict(metadata)
|
|
245
|
+
return Version.from_api(self._c._request("POST", f"/models/{model}/versions", body))
|
|
246
|
+
|
|
247
|
+
def list(self, model: str, limit: Optional[int] = None, offset: Optional[int] = None) -> List[Version]:
|
|
248
|
+
data = self._c._request("GET", f"/models/{model}/versions", params=self._c._page(limit, offset))
|
|
249
|
+
return from_list(data, Version.from_api)
|
|
250
|
+
|
|
251
|
+
def get(self, version_id: str) -> Version:
|
|
252
|
+
return Version.from_api(self._c._request("GET", f"/versions/{version_id}"))
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
class EnrollmentKeys(_API):
|
|
256
|
+
"""A project's enrollment keys, which devices register with."""
|
|
257
|
+
|
|
258
|
+
def create(self, project: str, name: str) -> EnrollmentKey:
|
|
259
|
+
return EnrollmentKey.from_api(self._c._request("POST", f"/projects/{project}/enrollment-keys", {"name": name}))
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class Deployments(_API):
|
|
263
|
+
"""``fleetml deploy``."""
|
|
264
|
+
|
|
265
|
+
def create(
|
|
266
|
+
self,
|
|
267
|
+
project: str,
|
|
268
|
+
version: str,
|
|
269
|
+
strategy: str = "ALL_AT_ONCE",
|
|
270
|
+
target_selector: Optional[Mapping[str, str]] = None,
|
|
271
|
+
health_gate: Optional[Mapping[str, Any]] = None,
|
|
272
|
+
canary_stages: Optional[Sequence[Mapping[str, Any]]] = None,
|
|
273
|
+
rolling_config: Optional[Mapping[str, Any]] = None,
|
|
274
|
+
urgent: bool = False,
|
|
275
|
+
) -> Deployment:
|
|
276
|
+
"""Creates a deployment of model version ``version`` (an ID) in
|
|
277
|
+
``project``. ``health_gate``, ``canary_stages`` and ``rolling_config``
|
|
278
|
+
are passed through as the REST API documents them (docs/ROLLOUTS.md)."""
|
|
279
|
+
body: Json = {"project_id": project, "model_version_id": version, "strategy": strategy, "urgent": urgent}
|
|
280
|
+
if target_selector is not None:
|
|
281
|
+
body["target_selector"] = dict(target_selector)
|
|
282
|
+
if health_gate is not None:
|
|
283
|
+
body["health_gate"] = dict(health_gate)
|
|
284
|
+
if canary_stages is not None:
|
|
285
|
+
body["canary_stages"] = [dict(s) for s in canary_stages]
|
|
286
|
+
if rolling_config is not None:
|
|
287
|
+
body["rolling_config"] = dict(rolling_config)
|
|
288
|
+
return Deployment.from_api(self._c._request("POST", "/deployments", body))
|
|
289
|
+
|
|
290
|
+
def start(self, deployment_id: str) -> Deployment:
|
|
291
|
+
return Deployment.from_api(self._c._request("POST", f"/deployments/{deployment_id}/start"))
|
|
292
|
+
|
|
293
|
+
def get(self, deployment_id: str) -> Deployment:
|
|
294
|
+
return Deployment.from_api(self._c._request("GET", f"/deployments/{deployment_id}"))
|
|
295
|
+
|
|
296
|
+
def list(self, limit: Optional[int] = None, offset: Optional[int] = None) -> List[Deployment]:
|
|
297
|
+
return from_list(
|
|
298
|
+
self._c._request("GET", "/deployments", params=self._c._page(limit, offset)), Deployment.from_api
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
def rollback(self, deployment_id: str, reason: str = "manual rollback") -> Deployment:
|
|
302
|
+
data = self._c._request("POST", f"/deployments/{deployment_id}/rollback", {"reason": reason})
|
|
303
|
+
return Deployment.from_api(data)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
class Devices(_API):
|
|
307
|
+
"""``fleetml device``."""
|
|
308
|
+
|
|
309
|
+
def list(
|
|
310
|
+
self,
|
|
311
|
+
labels: Optional[Mapping[str, str]] = None,
|
|
312
|
+
limit: Optional[int] = None,
|
|
313
|
+
offset: Optional[int] = None,
|
|
314
|
+
) -> List[Device]:
|
|
315
|
+
"""Lists devices; with ``labels``, only those that have all of them."""
|
|
316
|
+
params = self._c._page(limit, offset)
|
|
317
|
+
for k, v in (labels or {}).items():
|
|
318
|
+
params[f"label.{k}"] = v
|
|
319
|
+
return from_list(self._c._request("GET", "/devices", params=params), Device.from_api)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class Telemetry(_API):
|
|
323
|
+
"""``fleetml telemetry``."""
|
|
324
|
+
|
|
325
|
+
def summary(self, version_id: str) -> TelemetrySummary:
|
|
326
|
+
return TelemetrySummary.from_api(self._c._request("GET", f"/telemetry/summary/{version_id}"))
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
class Experiments(_API):
|
|
330
|
+
"""``fleetml experiment``."""
|
|
331
|
+
|
|
332
|
+
def create(
|
|
333
|
+
self,
|
|
334
|
+
project: str,
|
|
335
|
+
name: str,
|
|
336
|
+
control: str,
|
|
337
|
+
treatment: str,
|
|
338
|
+
metric: str = "latency",
|
|
339
|
+
split: int = 50,
|
|
340
|
+
auto_conclude: bool = False,
|
|
341
|
+
target_selector: Optional[Mapping[str, str]] = None,
|
|
342
|
+
min_sample_size: Optional[int] = None,
|
|
343
|
+
) -> Experiment:
|
|
344
|
+
"""Creates an A/B experiment between the model versions ``control``
|
|
345
|
+
and ``treatment`` (IDs); ``split`` is the treatment's share in percent."""
|
|
346
|
+
body: Json = {
|
|
347
|
+
"project_id": project,
|
|
348
|
+
"name": name,
|
|
349
|
+
"control_version_id": control,
|
|
350
|
+
"treatment_version_id": treatment,
|
|
351
|
+
"primary_metric": metric,
|
|
352
|
+
"split_ratio": split,
|
|
353
|
+
"auto_conclude": auto_conclude,
|
|
354
|
+
}
|
|
355
|
+
if target_selector is not None:
|
|
356
|
+
body["target_selector"] = dict(target_selector)
|
|
357
|
+
if min_sample_size is not None:
|
|
358
|
+
body["min_sample_size"] = min_sample_size
|
|
359
|
+
return Experiment.from_api(self._c._request("POST", "/experiments", body))
|
|
360
|
+
|
|
361
|
+
def start(self, experiment_id: str) -> Experiment:
|
|
362
|
+
return Experiment.from_api(self._c._request("POST", f"/experiments/{experiment_id}/start"))
|
|
363
|
+
|
|
364
|
+
def results(self, experiment_id: str) -> ExperimentResults:
|
|
365
|
+
return ExperimentResults.from_api(self._c._request("GET", f"/experiments/{experiment_id}/results"))
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class Drift(_API):
|
|
369
|
+
"""``fleetml drift``."""
|
|
370
|
+
|
|
371
|
+
def check(self, version_id: str) -> List[DriftResult]:
|
|
372
|
+
"""Runs a drift check now: one result per metric."""
|
|
373
|
+
return from_list(self._c._request("POST", f"/drift/{version_id}/check"), DriftResult.from_api)
|
|
374
|
+
|
|
375
|
+
def history(self, version_id: str) -> List[DriftResult]:
|
|
376
|
+
"""The last 50 drift results, newest first."""
|
|
377
|
+
return from_list(self._c._request("GET", f"/drift/{version_id}/history"), DriftResult.from_api)
|
fleetml/errors.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""The error every FleetML call raises."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class FleetMLError(Exception):
|
|
7
|
+
"""A request the server refused, or one that did not reach it.
|
|
8
|
+
|
|
9
|
+
``status`` is the HTTP status (0 when the server could not be reached),
|
|
10
|
+
``code`` the server's error code (such as ``NOT_FOUND``, ``CONFLICT``,
|
|
11
|
+
``VALIDATION_ERROR``, ``INTEGRITY_ERROR``, ``UNAUTHORIZED``) and
|
|
12
|
+
``message`` the server's message.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, status: int, code: str, message: str) -> None:
|
|
16
|
+
self.status = status
|
|
17
|
+
self.code = code
|
|
18
|
+
self.message = message
|
|
19
|
+
super().__init__(f"{status} {code}: {message}" if status else f"{code}: {message}")
|
fleetml/py.typed
ADDED
|
File without changes
|
fleetml/types.py
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""The responses users read, as dataclasses.
|
|
2
|
+
|
|
3
|
+
Each keeps the server's full JSON object in ``raw``, so fields that are not
|
|
4
|
+
listed here are still there. Timestamps are the server's RFC 3339 strings.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from typing import Any, Dict, List, Mapping, Optional
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _str(d: Mapping[str, Any], key: str) -> str:
|
|
14
|
+
v = d.get(key)
|
|
15
|
+
return "" if v is None else str(v)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _opt_str(d: Mapping[str, Any], key: str) -> Optional[str]:
|
|
19
|
+
v = d.get(key)
|
|
20
|
+
return None if v is None else str(v)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _int(d: Mapping[str, Any], key: str) -> int:
|
|
24
|
+
v = d.get(key)
|
|
25
|
+
return int(v) if isinstance(v, (int, float)) else 0
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _float(d: Mapping[str, Any], key: str) -> float:
|
|
29
|
+
v = d.get(key)
|
|
30
|
+
return float(v) if isinstance(v, (int, float)) else 0.0
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _opt_float(d: Mapping[str, Any], key: str) -> Optional[float]:
|
|
34
|
+
v = d.get(key)
|
|
35
|
+
return float(v) if isinstance(v, (int, float)) else None
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _labels(d: Mapping[str, Any], key: str) -> Dict[str, str]:
|
|
39
|
+
v = d.get(key)
|
|
40
|
+
return {str(k): str(x) for k, x in v.items()} if isinstance(v, dict) else {}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@dataclass(frozen=True)
|
|
44
|
+
class Project:
|
|
45
|
+
id: str
|
|
46
|
+
name: str
|
|
47
|
+
slug: str
|
|
48
|
+
description: str
|
|
49
|
+
created_at: str
|
|
50
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_api(cls, d: Mapping[str, Any]) -> Project:
|
|
54
|
+
return cls(
|
|
55
|
+
_str(d, "id"), _str(d, "name"), _str(d, "slug"), _str(d, "description"), _str(d, "created_at"), dict(d)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
@dataclass(frozen=True)
|
|
60
|
+
class Model:
|
|
61
|
+
id: str
|
|
62
|
+
project_id: str
|
|
63
|
+
name: str
|
|
64
|
+
framework: str
|
|
65
|
+
task_type: str
|
|
66
|
+
created_at: str
|
|
67
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
68
|
+
|
|
69
|
+
@classmethod
|
|
70
|
+
def from_api(cls, d: Mapping[str, Any]) -> Model:
|
|
71
|
+
return cls(
|
|
72
|
+
_str(d, "id"),
|
|
73
|
+
_str(d, "project_id"),
|
|
74
|
+
_str(d, "name"),
|
|
75
|
+
_str(d, "framework"),
|
|
76
|
+
_str(d, "task_type"),
|
|
77
|
+
_str(d, "created_at"),
|
|
78
|
+
dict(d),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@dataclass(frozen=True)
|
|
83
|
+
class Version:
|
|
84
|
+
"""A model version. ``status`` is DRAFT, STAGED, ACTIVE or ARCHIVED."""
|
|
85
|
+
|
|
86
|
+
id: str
|
|
87
|
+
model_id: str
|
|
88
|
+
version: str
|
|
89
|
+
status: str
|
|
90
|
+
metadata: Dict[str, Any]
|
|
91
|
+
created_at: str
|
|
92
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
93
|
+
|
|
94
|
+
@classmethod
|
|
95
|
+
def from_api(cls, d: Mapping[str, Any]) -> Version:
|
|
96
|
+
meta = d.get("metadata")
|
|
97
|
+
return cls(
|
|
98
|
+
_str(d, "id"),
|
|
99
|
+
_str(d, "model_id"),
|
|
100
|
+
_str(d, "version"),
|
|
101
|
+
_str(d, "status"),
|
|
102
|
+
dict(meta) if isinstance(meta, dict) else {},
|
|
103
|
+
_str(d, "created_at"),
|
|
104
|
+
dict(d),
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@dataclass(frozen=True)
|
|
109
|
+
class EnrollmentKey:
|
|
110
|
+
"""A project's enrollment key. ``key`` is returned only when it is created."""
|
|
111
|
+
|
|
112
|
+
id: str
|
|
113
|
+
project_id: str
|
|
114
|
+
name: str
|
|
115
|
+
key: str
|
|
116
|
+
created_at: str
|
|
117
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
118
|
+
|
|
119
|
+
@classmethod
|
|
120
|
+
def from_api(cls, d: Mapping[str, Any]) -> EnrollmentKey:
|
|
121
|
+
return cls(
|
|
122
|
+
_str(d, "id"), _str(d, "project_id"), _str(d, "name"), _str(d, "key"), _str(d, "created_at"), dict(d)
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def __repr__(self) -> str:
|
|
126
|
+
return f"EnrollmentKey(id={self.id!r}, project_id={self.project_id!r}, name={self.name!r}, key='…')"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass(frozen=True)
|
|
130
|
+
class Deployment:
|
|
131
|
+
"""A rollout. ``status`` is PENDING, ROLLING_OUT, PAUSED, COMPLETE,
|
|
132
|
+
ROLLED_BACK or CANCELLED; ``strategy`` is ALL_AT_ONCE, CANARY or ROLLING."""
|
|
133
|
+
|
|
134
|
+
id: str
|
|
135
|
+
project_id: str
|
|
136
|
+
model_version_id: str
|
|
137
|
+
strategy: str
|
|
138
|
+
status: str
|
|
139
|
+
target_selector: Dict[str, str]
|
|
140
|
+
current_stage: int
|
|
141
|
+
urgent: bool
|
|
142
|
+
rollback_reason: str
|
|
143
|
+
created_at: str
|
|
144
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
145
|
+
|
|
146
|
+
@classmethod
|
|
147
|
+
def from_api(cls, d: Mapping[str, Any]) -> Deployment:
|
|
148
|
+
return cls(
|
|
149
|
+
_str(d, "id"),
|
|
150
|
+
_str(d, "project_id"),
|
|
151
|
+
_str(d, "model_version_id"),
|
|
152
|
+
_str(d, "strategy"),
|
|
153
|
+
_str(d, "status"),
|
|
154
|
+
_labels(d, "target_selector"),
|
|
155
|
+
_int(d, "current_stage"),
|
|
156
|
+
bool(d.get("urgent")),
|
|
157
|
+
_str(d, "rollback_reason"),
|
|
158
|
+
_str(d, "created_at"),
|
|
159
|
+
dict(d),
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@dataclass(frozen=True)
|
|
164
|
+
class Device:
|
|
165
|
+
id: str
|
|
166
|
+
project_id: Optional[str]
|
|
167
|
+
os: str
|
|
168
|
+
os_version: str
|
|
169
|
+
ram_mb: int
|
|
170
|
+
chipset: str
|
|
171
|
+
agent_version: str
|
|
172
|
+
labels: Dict[str, str]
|
|
173
|
+
last_seen_at: Optional[str]
|
|
174
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
175
|
+
|
|
176
|
+
@classmethod
|
|
177
|
+
def from_api(cls, d: Mapping[str, Any]) -> Device:
|
|
178
|
+
return cls(
|
|
179
|
+
_str(d, "id"),
|
|
180
|
+
_opt_str(d, "project_id"),
|
|
181
|
+
_str(d, "os"),
|
|
182
|
+
_str(d, "os_version"),
|
|
183
|
+
_int(d, "ram_mb"),
|
|
184
|
+
_str(d, "chipset"),
|
|
185
|
+
_str(d, "agent_version"),
|
|
186
|
+
_labels(d, "labels"),
|
|
187
|
+
_opt_str(d, "last_seen_at"),
|
|
188
|
+
dict(d),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@dataclass(frozen=True)
|
|
193
|
+
class TelemetrySummary:
|
|
194
|
+
"""Inference telemetry of one model version over the last day."""
|
|
195
|
+
|
|
196
|
+
model_version_id: str
|
|
197
|
+
total_events: int
|
|
198
|
+
error_count: int
|
|
199
|
+
avg_latency_ms: float
|
|
200
|
+
p50_latency_ms: float
|
|
201
|
+
p95_latency_ms: float
|
|
202
|
+
p99_latency_ms: float
|
|
203
|
+
avg_confidence: float
|
|
204
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
205
|
+
|
|
206
|
+
@classmethod
|
|
207
|
+
def from_api(cls, d: Mapping[str, Any]) -> TelemetrySummary:
|
|
208
|
+
return cls(
|
|
209
|
+
_str(d, "model_version_id"),
|
|
210
|
+
_int(d, "total_events"),
|
|
211
|
+
_int(d, "error_count"),
|
|
212
|
+
_float(d, "avg_latency_ms"),
|
|
213
|
+
_float(d, "p50_latency_ms"),
|
|
214
|
+
_float(d, "p95_latency_ms"),
|
|
215
|
+
_float(d, "p99_latency_ms"),
|
|
216
|
+
_float(d, "avg_confidence"),
|
|
217
|
+
dict(d),
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@dataclass(frozen=True)
|
|
222
|
+
class Experiment:
|
|
223
|
+
"""An A/B experiment. ``status`` is DRAFT, RUNNING, PAUSED, CONCLUDED or CANCELLED."""
|
|
224
|
+
|
|
225
|
+
id: str
|
|
226
|
+
project_id: str
|
|
227
|
+
name: str
|
|
228
|
+
status: str
|
|
229
|
+
control_version_id: str
|
|
230
|
+
treatment_version_id: str
|
|
231
|
+
primary_metric: str
|
|
232
|
+
split_ratio: int
|
|
233
|
+
min_sample_size: int
|
|
234
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
235
|
+
|
|
236
|
+
@classmethod
|
|
237
|
+
def from_api(cls, d: Mapping[str, Any]) -> Experiment:
|
|
238
|
+
return cls(
|
|
239
|
+
_str(d, "id"),
|
|
240
|
+
_str(d, "project_id"),
|
|
241
|
+
_str(d, "name"),
|
|
242
|
+
_str(d, "status"),
|
|
243
|
+
_str(d, "control_version_id"),
|
|
244
|
+
_str(d, "treatment_version_id"),
|
|
245
|
+
_str(d, "primary_metric"),
|
|
246
|
+
_int(d, "split_ratio"),
|
|
247
|
+
_int(d, "min_sample_size"),
|
|
248
|
+
dict(d),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
@dataclass(frozen=True)
|
|
253
|
+
class ArmResult:
|
|
254
|
+
"""One arm (control or treatment) of an experiment's results."""
|
|
255
|
+
|
|
256
|
+
version_id: str
|
|
257
|
+
sample_size: int
|
|
258
|
+
avg_latency_ms: float
|
|
259
|
+
p95_latency_ms: float
|
|
260
|
+
error_rate: float
|
|
261
|
+
avg_confidence: float
|
|
262
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
263
|
+
|
|
264
|
+
@classmethod
|
|
265
|
+
def from_api(cls, d: Mapping[str, Any]) -> ArmResult:
|
|
266
|
+
return cls(
|
|
267
|
+
_str(d, "version_id"),
|
|
268
|
+
_int(d, "sample_size"),
|
|
269
|
+
_float(d, "avg_latency_ms"),
|
|
270
|
+
_float(d, "p95_latency_ms"),
|
|
271
|
+
_float(d, "error_rate"),
|
|
272
|
+
_float(d, "avg_confidence"),
|
|
273
|
+
dict(d),
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@dataclass(frozen=True)
|
|
278
|
+
class ExperimentResults:
|
|
279
|
+
"""``recommendation`` is COLLECTING_DATA until both arms reach
|
|
280
|
+
``min_sample_size``, then ADOPT_TREATMENT, KEEP_CONTROL or INCONCLUSIVE;
|
|
281
|
+
``final`` is true once the test has run."""
|
|
282
|
+
|
|
283
|
+
control: ArmResult
|
|
284
|
+
treatment: ArmResult
|
|
285
|
+
p_value: Optional[float]
|
|
286
|
+
effect_size: Optional[float]
|
|
287
|
+
is_significant: bool
|
|
288
|
+
recommendation: str
|
|
289
|
+
final: bool
|
|
290
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
291
|
+
|
|
292
|
+
@classmethod
|
|
293
|
+
def from_api(cls, d: Mapping[str, Any]) -> ExperimentResults:
|
|
294
|
+
control, treatment = d.get("control"), d.get("treatment")
|
|
295
|
+
return cls(
|
|
296
|
+
ArmResult.from_api(control if isinstance(control, dict) else {}),
|
|
297
|
+
ArmResult.from_api(treatment if isinstance(treatment, dict) else {}),
|
|
298
|
+
_opt_float(d, "p_value"),
|
|
299
|
+
_opt_float(d, "effect_size"),
|
|
300
|
+
bool(d.get("is_significant")),
|
|
301
|
+
_str(d, "recommendation"),
|
|
302
|
+
bool(d.get("final")),
|
|
303
|
+
dict(d),
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
@dataclass(frozen=True)
|
|
308
|
+
class DriftResult:
|
|
309
|
+
"""One drift check of one metric. ``severity`` is NONE, WARNING or CRITICAL."""
|
|
310
|
+
|
|
311
|
+
id: str
|
|
312
|
+
model_version_id: str
|
|
313
|
+
metric: str
|
|
314
|
+
psi_value: float
|
|
315
|
+
severity: str
|
|
316
|
+
message: str
|
|
317
|
+
checked_at: str
|
|
318
|
+
raw: Dict[str, Any] = field(repr=False, compare=False)
|
|
319
|
+
|
|
320
|
+
@classmethod
|
|
321
|
+
def from_api(cls, d: Mapping[str, Any]) -> DriftResult:
|
|
322
|
+
return cls(
|
|
323
|
+
_str(d, "id"),
|
|
324
|
+
_str(d, "model_version_id"),
|
|
325
|
+
_str(d, "metric"),
|
|
326
|
+
_float(d, "psi_value"),
|
|
327
|
+
_str(d, "severity"),
|
|
328
|
+
_str(d, "message"),
|
|
329
|
+
_str(d, "checked_at"),
|
|
330
|
+
dict(d),
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def from_list(items: Any, parse: Any) -> List[Any]:
|
|
335
|
+
"""Parses a JSON array with ``parse``; anything else is an empty list."""
|
|
336
|
+
return [parse(x) for x in items] if isinstance(items, list) else []
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: fleetml
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Python client for FleetML: push models, run and watch rollouts, A/B experiments and drift checks on a FleetML server.
|
|
5
|
+
Project-URL: Homepage, https://github.com/fleetml/fleetml
|
|
6
|
+
Project-URL: Documentation, https://github.com/fleetml/fleetml/blob/main/docs/PYTHON_CLIENT.md
|
|
7
|
+
Project-URL: Repository, https://github.com/fleetml/fleetml
|
|
8
|
+
Project-URL: Changelog, https://github.com/fleetml/fleetml/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/fleetml/fleetml/issues
|
|
10
|
+
Author-email: FleetML Maintainers <hello@fleetml.dev>
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE
|
|
14
|
+
Keywords: a/b testing,canary,edge,mlops,model deployment,ota
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.9
|
|
30
|
+
Requires-Dist: httpx<1,>=0.24
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# fleetml
|
|
38
|
+
|
|
39
|
+
The Python client for [FleetML](https://github.com/fleetml/fleetml), the
|
|
40
|
+
self-hosted platform that rolls models out to Android, iOS and Linux devices
|
|
41
|
+
with canaries, automatic rollback, A/B experiments and drift detection.
|
|
42
|
+
|
|
43
|
+
From a training pipeline, a notebook or CI: push a model, start a rollout,
|
|
44
|
+
wait for it, and read what the fleet reports. It speaks the server's REST API,
|
|
45
|
+
with the same words as the `fleetml` CLI, and depends only on `httpx`.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install fleetml
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`pip install fleetml` works from 0.6.0; until then, `pip install ./python`
|
|
52
|
+
from a clone of the repository.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from fleetml import FleetML
|
|
56
|
+
|
|
57
|
+
fm = FleetML("http://localhost:18080", api_key="...") # or FLEETML_SERVER, FLEETML_API_KEY
|
|
58
|
+
project = fm.projects.create("demo")
|
|
59
|
+
version = fm.push("model.tflite", project=project.id, model="iris", version="1.0.0")
|
|
60
|
+
deployment = fm.deployments.start(fm.deployments.create(project.id, version.id).id)
|
|
61
|
+
print(fm.wait_for_deployment(deployment.id).status)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Documentation: [docs/PYTHON_CLIENT.md](https://github.com/fleetml/fleetml/blob/main/docs/PYTHON_CLIENT.md).
|
|
65
|
+
License: Apache-2.0.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
fleetml/__init__.py,sha256=6VhLLXhzfAzor8gjSGN5X3BQjz-wZsCzdY2ydiqapyI,1058
|
|
2
|
+
fleetml/client.py,sha256=MyJw8MR-OC36vf2t8yyW1yx7rJWL477EO_EOwiV0g-s,14856
|
|
3
|
+
fleetml/errors.py,sha256=ndy4ftaM6JGPf4lz3_17DsKrzqqOGVXP34QAf6o3zwA,694
|
|
4
|
+
fleetml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
fleetml/types.py,sha256=rYnP4TEw-75alkKi1ufU1reApx_UWtjX4FvYcvHya5A,9295
|
|
6
|
+
fleetml-0.6.0.dist-info/METADATA,sha256=CIw9YA1-sPvGjIiPYY9xMlDsyBr9bo4gHbUCG4P5NjA,2783
|
|
7
|
+
fleetml-0.6.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
8
|
+
fleetml-0.6.0.dist-info/licenses/LICENSE,sha256=wCOt_hFFj7dchnKFFqTmd1ObW6UlZ0tikrYrwuYs2Tk,10771
|
|
9
|
+
fleetml-0.6.0.dist-info/licenses/NOTICE,sha256=14at2VbDYGE0I_eGpxV16yM30RiIZExyDNE8QUydrIU,1456
|
|
10
|
+
fleetml-0.6.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 FleetML Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
FleetML
|
|
2
|
+
Copyright 2026 FleetML Contributors
|
|
3
|
+
|
|
4
|
+
This product includes software developed by third parties:
|
|
5
|
+
|
|
6
|
+
internal/delta (the diff algorithm) is derived from bsdiff:
|
|
7
|
+
|
|
8
|
+
Copyright 2003-2005 Colin Percival. All rights reserved.
|
|
9
|
+
|
|
10
|
+
Redistribution and use in source and binary forms, with or without
|
|
11
|
+
modification, are permitted providing that the following conditions
|
|
12
|
+
are met:
|
|
13
|
+
1. Redistributions of source code must retain the above copyright
|
|
14
|
+
notice, this list of conditions and the following disclaimer.
|
|
15
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
16
|
+
notice, this list of conditions and the following disclaimer in the
|
|
17
|
+
documentation and/or other materials provided with the distribution.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
20
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
22
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
23
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
25
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
26
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
27
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
28
|
+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29
|
+
POSSIBILITY OF SUCH DAMAGE.
|