matyan_api_models 0.1.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.
- matyan_api_models-0.1.0/PKG-INFO +8 -0
- matyan_api_models-0.1.0/README.md +0 -0
- matyan_api_models-0.1.0/pyproject.toml +48 -0
- matyan_api_models-0.1.0/setup.cfg +4 -0
- matyan_api_models-0.1.0/src/matyan_api_models/__init__.py +10 -0
- matyan_api_models-0.1.0/src/matyan_api_models/kafka/__init__.py +3 -0
- matyan_api_models-0.1.0/src/matyan_api_models/kafka/_messages.py +30 -0
- matyan_api_models-0.1.0/src/matyan_api_models/py.typed +0 -0
- matyan_api_models-0.1.0/src/matyan_api_models/responses.py +18 -0
- matyan_api_models-0.1.0/src/matyan_api_models/run_creation.py +34 -0
- matyan_api_models-0.1.0/src/matyan_api_models/typing/__init__.py +29 -0
- matyan_api_models-0.1.0/src/matyan_api_models/typing/_main.py +41 -0
- matyan_api_models-0.1.0/src/matyan_api_models/ws/__init__.py +33 -0
- matyan_api_models-0.1.0/src/matyan_api_models/ws/_requests.py +115 -0
- matyan_api_models-0.1.0/src/matyan_api_models/ws/_responses.py +8 -0
- matyan_api_models-0.1.0/src/matyan_api_models.egg-info/PKG-INFO +8 -0
- matyan_api_models-0.1.0/src/matyan_api_models.egg-info/SOURCES.txt +18 -0
- matyan_api_models-0.1.0/src/matyan_api_models.egg-info/dependency_links.txt +1 -0
- matyan_api_models-0.1.0/src/matyan_api_models.egg-info/requires.txt +1 -0
- matyan_api_models-0.1.0/src/matyan_api_models.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matyan_api_models
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Models for the Matyan API
|
|
5
|
+
Author-email: Tigran Grigoryan <grigoryan.tigran119@gmail.com>
|
|
6
|
+
Requires-Python: <4,>=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: pydantic~=2.0
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "matyan_api_models"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Models for the Matyan API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Tigran Grigoryan", email = "grigoryan.tigran119@gmail.com" },
|
|
12
|
+
]
|
|
13
|
+
requires-python = ">=3.10, <4"
|
|
14
|
+
dependencies = ["pydantic~=2.0"]
|
|
15
|
+
|
|
16
|
+
[dependency-groups]
|
|
17
|
+
dev = ["mypy~=1.15"]
|
|
18
|
+
|
|
19
|
+
[tool.ruff]
|
|
20
|
+
line-length = 120
|
|
21
|
+
target-version = "py312"
|
|
22
|
+
|
|
23
|
+
[tool.ruff.lint]
|
|
24
|
+
select = ["ALL"]
|
|
25
|
+
ignore = [
|
|
26
|
+
"FBT001",
|
|
27
|
+
"FBT002",
|
|
28
|
+
"D100",
|
|
29
|
+
"D101",
|
|
30
|
+
"D102",
|
|
31
|
+
"D103",
|
|
32
|
+
"D104",
|
|
33
|
+
"D105",
|
|
34
|
+
"D106",
|
|
35
|
+
"D107",
|
|
36
|
+
"D203",
|
|
37
|
+
"D213",
|
|
38
|
+
"D417",
|
|
39
|
+
"FBT003",
|
|
40
|
+
"EXE002",
|
|
41
|
+
"S311",
|
|
42
|
+
"TD003",
|
|
43
|
+
"D205",
|
|
44
|
+
"PLR2004",
|
|
45
|
+
"PLR0913",
|
|
46
|
+
"S101",
|
|
47
|
+
"S104",
|
|
48
|
+
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from .responses import LogHParamsResponse, LogMetricResponse, ReadMetricResponse
|
|
2
|
+
from .run_creation import RunCreateRequest, RunCreateResponse
|
|
3
|
+
|
|
4
|
+
__all__ = [
|
|
5
|
+
"LogHParamsResponse",
|
|
6
|
+
"LogMetricResponse",
|
|
7
|
+
"ReadMetricResponse",
|
|
8
|
+
"RunCreateRequest",
|
|
9
|
+
"RunCreateResponse",
|
|
10
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime # noqa: TC003
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class IngestionMessage(BaseModel):
|
|
9
|
+
"""Envelope for all messages on the ``data-ingestion`` Kafka topic.
|
|
10
|
+
|
|
11
|
+
Both frontier (producer) and ingestion workers (consumer) depend on this
|
|
12
|
+
schema. The ``type`` field discriminates the payload shape.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
type: str
|
|
16
|
+
run_id: str
|
|
17
|
+
timestamp: datetime
|
|
18
|
+
payload: dict
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ControlEvent(BaseModel):
|
|
22
|
+
"""Envelope for all messages on the ``control-events`` Kafka topic.
|
|
23
|
+
|
|
24
|
+
Published by the backend API after synchronous FDB writes.
|
|
25
|
+
Consumed by control workers for async side effects (S3 cleanup, etc.).
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
type: str
|
|
29
|
+
timestamp: datetime
|
|
30
|
+
payload: dict
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ReadMetricResponse(BaseModel):
|
|
5
|
+
value: float
|
|
6
|
+
timestamp: int
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ReadHParamsResponse(BaseModel):
|
|
10
|
+
value: dict
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class LogHParamsResponse(BaseModel):
|
|
14
|
+
status: int
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class LogMetricResponse(BaseModel):
|
|
18
|
+
status: int
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, field_validator
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class RunCreateRequest(BaseModel):
|
|
10
|
+
id: str
|
|
11
|
+
project: str = Field(min_length=1)
|
|
12
|
+
experiment: str = Field(min_length=1)
|
|
13
|
+
name: str = Field(min_length=1)
|
|
14
|
+
description: str
|
|
15
|
+
|
|
16
|
+
@field_validator("id")
|
|
17
|
+
@classmethod
|
|
18
|
+
def validate_id(cls, value: str) -> str:
|
|
19
|
+
# Ensure it contains only valid hexadecimal characters
|
|
20
|
+
if not re.fullmatch(r"[0-9a-f]{32}", value):
|
|
21
|
+
msg = "UUID must be a 32-character hexadecimal lowercase string"
|
|
22
|
+
raise ValueError(msg)
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
_ = uuid.UUID(hex=value)
|
|
26
|
+
except ValueError as e:
|
|
27
|
+
msg = "Not a valid UUID hex format"
|
|
28
|
+
raise ValueError(msg) from e
|
|
29
|
+
|
|
30
|
+
return value
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class RunCreateResponse(BaseModel):
|
|
34
|
+
creation_timestamp: int
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from ._main import (
|
|
2
|
+
ContextT,
|
|
3
|
+
DescriptionT,
|
|
4
|
+
DtypeT,
|
|
5
|
+
EpochT,
|
|
6
|
+
ExperimentNameT,
|
|
7
|
+
HParams,
|
|
8
|
+
MetricT,
|
|
9
|
+
ProjectNameT,
|
|
10
|
+
RunId,
|
|
11
|
+
RunIdT,
|
|
12
|
+
RunNameT,
|
|
13
|
+
StepT,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ContextT",
|
|
18
|
+
"DescriptionT",
|
|
19
|
+
"DtypeT",
|
|
20
|
+
"EpochT",
|
|
21
|
+
"ExperimentNameT",
|
|
22
|
+
"HParams",
|
|
23
|
+
"MetricT",
|
|
24
|
+
"ProjectNameT",
|
|
25
|
+
"RunId",
|
|
26
|
+
"RunIdT",
|
|
27
|
+
"RunNameT",
|
|
28
|
+
"StepT",
|
|
29
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import uuid
|
|
5
|
+
from typing import Annotated, Any
|
|
6
|
+
|
|
7
|
+
from pydantic import BeforeValidator
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _validate_run_id(value: str | None) -> str:
|
|
11
|
+
if value is None:
|
|
12
|
+
return uuid.uuid4().hex
|
|
13
|
+
|
|
14
|
+
# Ensure it contains only valid hexadecimal characters
|
|
15
|
+
if not re.fullmatch(r"[0-9a-f]{32}", value):
|
|
16
|
+
msg = "UUID must be a 32-character hexadecimal lowercase string"
|
|
17
|
+
raise ValueError(msg)
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
_ = uuid.UUID(hex=value)
|
|
21
|
+
except ValueError as e:
|
|
22
|
+
msg = "Not a valid UUID hex format"
|
|
23
|
+
raise ValueError(msg) from e
|
|
24
|
+
|
|
25
|
+
return value
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
RunId = Annotated[str, BeforeValidator(_validate_run_id)]
|
|
29
|
+
RunIdT = str
|
|
30
|
+
RunNameT = str
|
|
31
|
+
ProjectNameT = str
|
|
32
|
+
ExperimentNameT = str
|
|
33
|
+
DescriptionT = str
|
|
34
|
+
|
|
35
|
+
MetricNameT = str
|
|
36
|
+
StepT = int
|
|
37
|
+
EpochT = int
|
|
38
|
+
ContextT = dict
|
|
39
|
+
DtypeT = str
|
|
40
|
+
MetricT = str
|
|
41
|
+
HParams = dict[str, Any]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from ._requests import (
|
|
2
|
+
AddTagWsRequest,
|
|
3
|
+
BaseWsRequest,
|
|
4
|
+
CreateRunWsRequest,
|
|
5
|
+
FinishRunWsRequest,
|
|
6
|
+
LogCustomObjectWsRequest,
|
|
7
|
+
LogHParamsWsRequest,
|
|
8
|
+
LogMetricWsRequest,
|
|
9
|
+
LogRecordWsRequest,
|
|
10
|
+
LogTerminalLineWsRequest,
|
|
11
|
+
RemoveTagWsRequest,
|
|
12
|
+
SetRunPropertyWsRequest,
|
|
13
|
+
WsRequestT,
|
|
14
|
+
WsRequestTAdapter,
|
|
15
|
+
)
|
|
16
|
+
from ._responses import WsResponse
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"AddTagWsRequest",
|
|
20
|
+
"BaseWsRequest",
|
|
21
|
+
"CreateRunWsRequest",
|
|
22
|
+
"FinishRunWsRequest",
|
|
23
|
+
"LogCustomObjectWsRequest",
|
|
24
|
+
"LogHParamsWsRequest",
|
|
25
|
+
"LogMetricWsRequest",
|
|
26
|
+
"LogRecordWsRequest",
|
|
27
|
+
"LogTerminalLineWsRequest",
|
|
28
|
+
"RemoveTagWsRequest",
|
|
29
|
+
"SetRunPropertyWsRequest",
|
|
30
|
+
"WsRequestT",
|
|
31
|
+
"WsRequestTAdapter",
|
|
32
|
+
"WsResponse",
|
|
33
|
+
]
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from datetime import datetime # noqa: TC003
|
|
4
|
+
from typing import Annotated, Literal
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field, TypeAdapter
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BaseWsRequest(BaseModel):
|
|
10
|
+
type: str
|
|
11
|
+
run_id: str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CreateRunWsRequest(BaseWsRequest):
|
|
15
|
+
type: Literal["create_run"] = "create_run"
|
|
16
|
+
client_datetime: datetime
|
|
17
|
+
force_resume: bool = False
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class LogMetricWsRequest(BaseWsRequest):
|
|
21
|
+
type: Literal["log_metric"] = "log_metric"
|
|
22
|
+
name: str
|
|
23
|
+
value: float
|
|
24
|
+
step: int | None
|
|
25
|
+
epoch: int | None
|
|
26
|
+
context: dict | None
|
|
27
|
+
dtype: str | None
|
|
28
|
+
client_datetime: datetime
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class LogHParamsWsRequest(BaseWsRequest):
|
|
32
|
+
type: Literal["log_hparams"] = "log_hparams"
|
|
33
|
+
value: dict
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FinishRunWsRequest(BaseWsRequest):
|
|
37
|
+
type: Literal["finish_run"] = "finish_run"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SetRunPropertyWsRequest(BaseWsRequest):
|
|
41
|
+
"""Set one or more run properties (name, description, archived, experiment)."""
|
|
42
|
+
|
|
43
|
+
type: Literal["set_run_property"] = "set_run_property"
|
|
44
|
+
name: str | None = None
|
|
45
|
+
description: str | None = None
|
|
46
|
+
archived: bool | None = None
|
|
47
|
+
experiment: str | None = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AddTagWsRequest(BaseWsRequest):
|
|
51
|
+
"""Add a tag to a run (by tag name — will be created if it doesn't exist)."""
|
|
52
|
+
|
|
53
|
+
type: Literal["add_tag"] = "add_tag"
|
|
54
|
+
tag_name: str
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class RemoveTagWsRequest(BaseWsRequest):
|
|
58
|
+
"""Remove a tag from a run (by tag name)."""
|
|
59
|
+
|
|
60
|
+
type: Literal["remove_tag"] = "remove_tag"
|
|
61
|
+
tag_name: str
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class LogCustomObjectWsRequest(BaseWsRequest):
|
|
65
|
+
"""Track a custom object (Image, Audio, Text, Distribution, Figure).
|
|
66
|
+
|
|
67
|
+
``value`` carries the serialized metadata dict (and for blob types, the
|
|
68
|
+
``s3_key`` referencing the already-uploaded binary data).
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
type: Literal["log_custom_object"] = "log_custom_object"
|
|
72
|
+
name: str
|
|
73
|
+
value: dict
|
|
74
|
+
step: int | None = None
|
|
75
|
+
epoch: int | None = None
|
|
76
|
+
context: dict | None = None
|
|
77
|
+
dtype: str = "custom"
|
|
78
|
+
client_datetime: datetime | None = None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class LogTerminalLineWsRequest(BaseWsRequest):
|
|
82
|
+
"""A single captured terminal output line (stdout/stderr)."""
|
|
83
|
+
|
|
84
|
+
type: Literal["log_terminal_line"] = "log_terminal_line"
|
|
85
|
+
line: str
|
|
86
|
+
step: int
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class LogRecordWsRequest(BaseWsRequest):
|
|
90
|
+
"""A structured log record (log_info / log_warning / log_error / log_debug)."""
|
|
91
|
+
|
|
92
|
+
type: Literal["log_record"] = "log_record"
|
|
93
|
+
message: str
|
|
94
|
+
level: int
|
|
95
|
+
timestamp: float
|
|
96
|
+
logger_info: list | None = None
|
|
97
|
+
extra_args: dict | None = None
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
WsRequestT = Annotated[
|
|
101
|
+
CreateRunWsRequest
|
|
102
|
+
| LogMetricWsRequest
|
|
103
|
+
| LogHParamsWsRequest
|
|
104
|
+
| FinishRunWsRequest
|
|
105
|
+
| SetRunPropertyWsRequest
|
|
106
|
+
| AddTagWsRequest
|
|
107
|
+
| RemoveTagWsRequest
|
|
108
|
+
| LogCustomObjectWsRequest
|
|
109
|
+
| LogTerminalLineWsRequest
|
|
110
|
+
| LogRecordWsRequest,
|
|
111
|
+
Field(discriminator="type"),
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
WsRequestTAdapter: TypeAdapter[WsRequestT] = TypeAdapter(WsRequestT) # ty:ignore[invalid-assignment]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matyan_api_models
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Models for the Matyan API
|
|
5
|
+
Author-email: Tigran Grigoryan <grigoryan.tigran119@gmail.com>
|
|
6
|
+
Requires-Python: <4,>=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: pydantic~=2.0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/matyan_api_models/__init__.py
|
|
4
|
+
src/matyan_api_models/py.typed
|
|
5
|
+
src/matyan_api_models/responses.py
|
|
6
|
+
src/matyan_api_models/run_creation.py
|
|
7
|
+
src/matyan_api_models.egg-info/PKG-INFO
|
|
8
|
+
src/matyan_api_models.egg-info/SOURCES.txt
|
|
9
|
+
src/matyan_api_models.egg-info/dependency_links.txt
|
|
10
|
+
src/matyan_api_models.egg-info/requires.txt
|
|
11
|
+
src/matyan_api_models.egg-info/top_level.txt
|
|
12
|
+
src/matyan_api_models/kafka/__init__.py
|
|
13
|
+
src/matyan_api_models/kafka/_messages.py
|
|
14
|
+
src/matyan_api_models/typing/__init__.py
|
|
15
|
+
src/matyan_api_models/typing/_main.py
|
|
16
|
+
src/matyan_api_models/ws/__init__.py
|
|
17
|
+
src/matyan_api_models/ws/_requests.py
|
|
18
|
+
src/matyan_api_models/ws/_responses.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pydantic~=2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
matyan_api_models
|