plexus-python-pulse-demeter 1.2.150__py3-none-any.whl → 1.2.151__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.
- plexus/pulse/demeter/app.py +2 -0
- plexus/pulse/demeter/cli.py +13 -25
- plexus/pulse/demeter/domains/robotic/api/catalog_endpoints.py +14 -14
- plexus/pulse/demeter/domains/robotic/api/pipeline_endpoints.py +292 -7
- plexus/pulse/demeter/domains/robotic/cli/manage.py +37 -0
- plexus/pulse/demeter/domains/robotic/client.py +142 -66
- plexus/pulse/demeter/domains/robotic/tables/catalog.py +16 -15
- plexus/pulse/demeter/domains/robotic/tables/pipeline.py +7 -6
- plexus/pulse/demeter/domains/robotic/tui/__init__.py +0 -0
- plexus/pulse/demeter/domains/robotic/tui/manage.py +999 -0
- plexus/pulse/demeter/platform/agent.py +201 -0
- plexus/pulse/demeter/platform/api/registry_endpoints.py +46 -0
- plexus/pulse/demeter/platform/cli.py +130 -0
- plexus/pulse/demeter/platform/client.py +58 -0
- plexus/pulse/demeter/platform/database.py +367 -2
- plexus/pulse/demeter/platform/tables/iam.py +11 -10
- {plexus_python_pulse_demeter-1.2.150.dist-info → plexus_python_pulse_demeter-1.2.151.dist-info}/METADATA +3 -1
- {plexus_python_pulse_demeter-1.2.150.dist-info → plexus_python_pulse_demeter-1.2.151.dist-info}/RECORD +21 -15
- {plexus_python_pulse_demeter-1.2.150.dist-info → plexus_python_pulse_demeter-1.2.151.dist-info}/WHEEL +0 -0
- {plexus_python_pulse_demeter-1.2.150.dist-info → plexus_python_pulse_demeter-1.2.151.dist-info}/entry_points.txt +0 -0
- {plexus_python_pulse_demeter-1.2.150.dist-info → plexus_python_pulse_demeter-1.2.151.dist-info}/top_level.txt +0 -0
plexus/pulse/demeter/app.py
CHANGED
|
@@ -6,6 +6,7 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
|
6
6
|
|
|
7
7
|
def make_api() -> FastAPI:
|
|
8
8
|
from plexus.pulse.demeter.platform.api.iam_internal_endpoints import router as iam_internal_router
|
|
9
|
+
from plexus.pulse.demeter.platform.api.registry_endpoints import router as registry_router
|
|
9
10
|
from plexus.pulse.demeter.domains.autodrive.api.inventory_endpoints import router as autodrive_inventory_router
|
|
10
11
|
from plexus.pulse.demeter.domains.autodrive.api.catalog_endpoints import router as autodrive_catalog_router
|
|
11
12
|
from plexus.pulse.demeter.domains.autodrive.api.tagging_endpoints import router as autodrive_tagging_router
|
|
@@ -29,6 +30,7 @@ def make_api() -> FastAPI:
|
|
|
29
30
|
)
|
|
30
31
|
|
|
31
32
|
api.include_router(iam_internal_router)
|
|
33
|
+
api.include_router(registry_router)
|
|
32
34
|
api.include_router(autodrive_inventory_router)
|
|
33
35
|
api.include_router(autodrive_catalog_router)
|
|
34
36
|
api.include_router(autodrive_workflow_router)
|
plexus/pulse/demeter/cli.py
CHANGED
|
@@ -1,44 +1,32 @@
|
|
|
1
|
-
from types import SimpleNamespace
|
|
2
|
-
|
|
3
|
-
import click
|
|
4
|
-
|
|
5
1
|
from plexus.pulse.demeter.domains.autodrive.cli.dataset import DatasetValidateCommandTool
|
|
6
2
|
from plexus.pulse.demeter.domains.autodrive.cli.tag_cache import (
|
|
7
3
|
TagCacheUploadCommandTool,
|
|
8
4
|
TagCacheValidateCommandTool,
|
|
9
5
|
)
|
|
10
6
|
from plexus.pulse.demeter.domains.robotic.cli.flow_ops import FlowOpsCommandTool
|
|
7
|
+
from plexus.pulse.demeter.domains.robotic.cli.manage import ManageCommandTool
|
|
11
8
|
from plexus.pulse.demeter.domains.robotic.cli.pipeline import PipelineUploadCommandTool
|
|
12
|
-
from plexus.pulse.demeter.platform.cli import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
@classmethod
|
|
21
|
-
def params(cls) -> list[click.Parameter]:
|
|
22
|
-
return []
|
|
23
|
-
|
|
24
|
-
@classmethod
|
|
25
|
-
def desc(cls) -> str:
|
|
26
|
-
return "Show the installed Demeter package version."
|
|
27
|
-
|
|
28
|
-
def run(self, args: SimpleNamespace) -> int:
|
|
29
|
-
from plexus.pulse.demeter import __version__
|
|
30
|
-
|
|
31
|
-
click.echo(__version__)
|
|
32
|
-
return 0
|
|
9
|
+
from plexus.pulse.demeter.platform.cli import (
|
|
10
|
+
CommandTool,
|
|
11
|
+
RegistryDescribeCommandTool,
|
|
12
|
+
RegistryExplainCommandTool,
|
|
13
|
+
RegistryOpenApiCommandTool,
|
|
14
|
+
VersionCommandTool,
|
|
15
|
+
)
|
|
16
|
+
from plexus.pulse.demeter.platform.cli import run_cli
|
|
33
17
|
|
|
34
18
|
|
|
35
19
|
def main() -> None:
|
|
36
20
|
tools: list[type[CommandTool]] = [
|
|
37
21
|
VersionCommandTool,
|
|
22
|
+
RegistryDescribeCommandTool,
|
|
23
|
+
RegistryOpenApiCommandTool,
|
|
24
|
+
RegistryExplainCommandTool,
|
|
38
25
|
TagCacheUploadCommandTool,
|
|
39
26
|
TagCacheValidateCommandTool,
|
|
40
27
|
DatasetValidateCommandTool,
|
|
41
28
|
FlowOpsCommandTool,
|
|
29
|
+
ManageCommandTool,
|
|
42
30
|
PipelineUploadCommandTool,
|
|
43
31
|
]
|
|
44
32
|
|
|
@@ -482,7 +482,7 @@ def register_robot(
|
|
|
482
482
|
return RobotWithTitles.with_titles(db, [db_robot])[0]
|
|
483
483
|
|
|
484
484
|
|
|
485
|
-
class RobotTablesAndPagination(
|
|
485
|
+
class RobotTablesAndPagination(BaseModel):
|
|
486
486
|
robots: list[RobotWithTitles]
|
|
487
487
|
pagination: Pagination
|
|
488
488
|
|
|
@@ -779,14 +779,14 @@ def delete_episode(
|
|
|
779
779
|
return EpisodeWithTitles.with_titles(db, [db_episode])[0]
|
|
780
780
|
|
|
781
781
|
|
|
782
|
-
class TagFilter(
|
|
782
|
+
class TagFilter(BaseModel):
|
|
783
783
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
784
784
|
|
|
785
785
|
tagset_spec: str = pdt.Field(max_length=64)
|
|
786
786
|
tag: str = pdt.Field(max_length=128)
|
|
787
787
|
|
|
788
788
|
|
|
789
|
-
class ArtifactFilter(
|
|
789
|
+
class ArtifactFilter(BaseModel):
|
|
790
790
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
791
791
|
|
|
792
792
|
family: str | None = pdt.Field(None, max_length=32)
|
|
@@ -796,11 +796,11 @@ class ArtifactFilter(pdt.BaseModel):
|
|
|
796
796
|
@pdt.model_validator(mode="after")
|
|
797
797
|
def validate_selector(self):
|
|
798
798
|
if (self.family is None) == (self.format_spec is None):
|
|
799
|
-
raise ValueError("
|
|
799
|
+
raise ValueError("specify exactly one of family or format_spec")
|
|
800
800
|
return self
|
|
801
801
|
|
|
802
802
|
|
|
803
|
-
class EpisodeFilterSet(
|
|
803
|
+
class EpisodeFilterSet(BaseModel):
|
|
804
804
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
805
805
|
|
|
806
806
|
pipeline_name: str = pdt.Field(max_length=128)
|
|
@@ -881,7 +881,7 @@ def make_episode_filter_predicate_stmt(filter_set: EpisodeFilterSet):
|
|
|
881
881
|
return sa.and_(*sub_predicate_stmts)
|
|
882
882
|
|
|
883
883
|
|
|
884
|
-
class EpisodeSelection(
|
|
884
|
+
class EpisodeSelection(BaseModel):
|
|
885
885
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
886
886
|
|
|
887
887
|
select_filter_set: EpisodeFilterSet | None = None
|
|
@@ -890,13 +890,13 @@ class EpisodeSelection(pdt.BaseModel):
|
|
|
890
890
|
description="Episode bag UUIDs; exclusion overrides inclusion")
|
|
891
891
|
|
|
892
892
|
|
|
893
|
-
class TagSelector(
|
|
893
|
+
class TagSelector(BaseModel):
|
|
894
894
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
895
895
|
|
|
896
896
|
tagset_spec: str | None = pdt.Field(None, max_length=64)
|
|
897
897
|
|
|
898
898
|
|
|
899
|
-
class ArtifactSelector(
|
|
899
|
+
class ArtifactSelector(BaseModel):
|
|
900
900
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
901
901
|
|
|
902
902
|
family: str | None = pdt.Field(None, max_length=32)
|
|
@@ -906,7 +906,7 @@ class ArtifactSelector(pdt.BaseModel):
|
|
|
906
906
|
@pdt.model_validator(mode="after")
|
|
907
907
|
def validate_selector(self):
|
|
908
908
|
if (self.family is None) == (self.format_spec is None):
|
|
909
|
-
raise ValueError("
|
|
909
|
+
raise ValueError("specify exactly one of family or format_spec")
|
|
910
910
|
return self
|
|
911
911
|
|
|
912
912
|
|
|
@@ -918,7 +918,7 @@ class QueryEpisodeRequest(EpisodeSelection):
|
|
|
918
918
|
limit: int = pdt.Field(100, ge=1, le=1000)
|
|
919
919
|
|
|
920
920
|
|
|
921
|
-
class EnrichedEpisode(
|
|
921
|
+
class EnrichedEpisode(BaseModel):
|
|
922
922
|
episode: EpisodeWithTitles
|
|
923
923
|
bag: BagWithTitles
|
|
924
924
|
tags: list[TagWithTitles] = pdt.Field(default_factory=list)
|
|
@@ -926,7 +926,7 @@ class EnrichedEpisode(pdt.BaseModel):
|
|
|
926
926
|
selected: bool = False
|
|
927
927
|
|
|
928
928
|
|
|
929
|
-
class EnrichedEpisodesAndPagination(
|
|
929
|
+
class EnrichedEpisodesAndPagination(BaseModel):
|
|
930
930
|
episodes: list[EnrichedEpisode]
|
|
931
931
|
pagination: Pagination
|
|
932
932
|
|
|
@@ -1048,7 +1048,7 @@ class StatEpisodeRequest(EpisodeSelection):
|
|
|
1048
1048
|
pass
|
|
1049
1049
|
|
|
1050
1050
|
|
|
1051
|
-
class EpisodeStatistics(
|
|
1051
|
+
class EpisodeStatistics(BaseModel):
|
|
1052
1052
|
total_count: int
|
|
1053
1053
|
total_duration_ns: int
|
|
1054
1054
|
|
|
@@ -1129,12 +1129,12 @@ def create_dataset_from_selection(
|
|
|
1129
1129
|
return db_dataset
|
|
1130
1130
|
|
|
1131
1131
|
|
|
1132
|
-
class DatasetWithEpisodeCount(
|
|
1132
|
+
class DatasetWithEpisodeCount(BaseModel):
|
|
1133
1133
|
dataset: DatasetTable
|
|
1134
1134
|
episodes_count: int
|
|
1135
1135
|
|
|
1136
1136
|
|
|
1137
|
-
class DatasetsAndPagination(
|
|
1137
|
+
class DatasetsAndPagination(BaseModel):
|
|
1138
1138
|
datasets: list[DatasetWithEpisodeCount]
|
|
1139
1139
|
pagination: Pagination
|
|
1140
1140
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import functools
|
|
2
3
|
import hashlib
|
|
3
4
|
import json
|
|
4
5
|
import tempfile
|
|
@@ -36,6 +37,8 @@ from plexus.pulse.demeter.domains.robotic.tables.pipeline import (
|
|
|
36
37
|
StageRunTable,
|
|
37
38
|
)
|
|
38
39
|
from plexus.pulse.demeter.platform.api import Pagination
|
|
40
|
+
from plexus.pulse.demeter.platform.api.registry_endpoints import require_query_access
|
|
41
|
+
from plexus.pulse.demeter.platform.database import execute_readonly_filter, validate_uuid_column
|
|
39
42
|
from plexus.pulse.demeter.platform.database import make_session
|
|
40
43
|
from plexus.pulse.demeter.platform.models import BaseModel
|
|
41
44
|
|
|
@@ -47,7 +50,7 @@ exception_redirect = {
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
|
|
50
|
-
class PipelineTablesAndPagination(
|
|
53
|
+
class PipelineTablesAndPagination(BaseModel):
|
|
51
54
|
pipelines: list[PipelineTable]
|
|
52
55
|
pagination: Pagination
|
|
53
56
|
|
|
@@ -76,12 +79,132 @@ def read_pipeline(pipeline_uuid: py_uuid.UUID, db: sa_orm.Session = Depends(make
|
|
|
76
79
|
return db_pipeline
|
|
77
80
|
|
|
78
81
|
|
|
79
|
-
class
|
|
82
|
+
class ExecutionCounts(BaseModel):
|
|
83
|
+
queued: int = 0
|
|
84
|
+
running: int = 0
|
|
85
|
+
succeeded: int = 0
|
|
86
|
+
failed: int = 0
|
|
87
|
+
cancelled: int = 0
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class AttemptCounts(BaseModel):
|
|
91
|
+
running: int = 0
|
|
92
|
+
succeeded: int = 0
|
|
93
|
+
failed: int = 0
|
|
94
|
+
expired: int = 0
|
|
95
|
+
cancelled: int = 0
|
|
96
|
+
skipped: int = 0
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class TopicExecutionCounts(BaseModel):
|
|
100
|
+
name: str
|
|
101
|
+
counts: ExecutionCounts
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
class TopicAttemptCounts(BaseModel):
|
|
105
|
+
name: str
|
|
106
|
+
counts: AttemptCounts
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class TopicCount(BaseModel):
|
|
110
|
+
name: str
|
|
111
|
+
count: int
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class StageOverview(BaseModel):
|
|
115
|
+
stage: str
|
|
116
|
+
stage_runs: ExecutionCounts = pdt.Field(default_factory=ExecutionCounts)
|
|
117
|
+
stage_run_attempts: AttemptCounts = pdt.Field(default_factory=AttemptCounts)
|
|
118
|
+
stage_inputs: list[TopicExecutionCounts] = pdt.Field(default_factory=list)
|
|
119
|
+
stage_input_attempts: list[TopicAttemptCounts] = pdt.Field(default_factory=list)
|
|
120
|
+
stage_outputs: list[TopicCount] = pdt.Field(default_factory=list)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@router.get("/pipelines/{pipeline_uuid}/overview/", response_model=list[StageOverview])
|
|
124
|
+
def read_pipeline_overview(
|
|
125
|
+
pipeline_uuid: py_uuid.UUID,
|
|
126
|
+
db: sa_orm.Session = Depends(make_session),
|
|
127
|
+
) -> list[StageOverview]:
|
|
128
|
+
pipeline = read_pipeline(pipeline_uuid, db)
|
|
129
|
+
flow = validate_flow(pipeline.flow)
|
|
130
|
+
|
|
131
|
+
stages = {stage.name: StageOverview(stage=stage.name) for stage in flow.stages}
|
|
132
|
+
|
|
133
|
+
run_counts = (
|
|
134
|
+
db
|
|
135
|
+
.query(StageRunTable.stage, StageRunTable.status, sa.func.count())
|
|
136
|
+
.filter(StageRunTable.pipeline_name == pipeline.name)
|
|
137
|
+
.group_by(StageRunTable.stage, StageRunTable.status)
|
|
138
|
+
)
|
|
139
|
+
for stage, status, count in run_counts:
|
|
140
|
+
if stage in stages:
|
|
141
|
+
setattr(stages[stage].stage_runs, status.lower(), count)
|
|
142
|
+
|
|
143
|
+
run_attempt_counts = (
|
|
144
|
+
db
|
|
145
|
+
.query(StageRunTable.stage, StageRunAttemptTable.status, sa.func.count())
|
|
146
|
+
.select_from(StageRunTable)
|
|
147
|
+
.join(StageRunAttemptTable, StageRunAttemptTable.stage_run_uuid == StageRunTable.uuid)
|
|
148
|
+
.filter(StageRunTable.pipeline_name == pipeline.name)
|
|
149
|
+
.group_by(StageRunTable.stage, StageRunAttemptTable.status)
|
|
150
|
+
)
|
|
151
|
+
for stage, status, count in run_attempt_counts:
|
|
152
|
+
if stage in stages:
|
|
153
|
+
setattr(stages[stage].stage_run_attempts, status.lower(), count)
|
|
154
|
+
|
|
155
|
+
input_counts_by_topic: dict[tuple[str, str], ExecutionCounts] = {}
|
|
156
|
+
input_counts = (
|
|
157
|
+
db
|
|
158
|
+
.query(StageInputTable.consumer_stage, StageOutputTable.topic, StageInputTable.status, sa.func.count())
|
|
159
|
+
.select_from(StageInputTable)
|
|
160
|
+
.join(StageOutputTable, StageOutputTable.uuid == StageInputTable.stage_output_uuid)
|
|
161
|
+
.filter(StageInputTable.pipeline_name == pipeline.name)
|
|
162
|
+
.group_by(StageInputTable.consumer_stage, StageOutputTable.topic, StageInputTable.status)
|
|
163
|
+
)
|
|
164
|
+
for stage, topic, status, count in input_counts:
|
|
165
|
+
if stage in stages:
|
|
166
|
+
counts = input_counts_by_topic.setdefault((stage, topic), ExecutionCounts())
|
|
167
|
+
setattr(counts, status.lower(), count)
|
|
168
|
+
for (stage, topic), counts in sorted(input_counts_by_topic.items()):
|
|
169
|
+
stages[stage].stage_inputs.append(TopicExecutionCounts(name=topic, counts=counts))
|
|
170
|
+
|
|
171
|
+
input_attempt_counts_by_topic: dict[tuple[str, str], AttemptCounts] = {}
|
|
172
|
+
input_attempt_counts = (
|
|
173
|
+
db
|
|
174
|
+
.query(StageInputTable.consumer_stage, StageOutputTable.topic, StageInputAttemptTable.status, sa.func.count())
|
|
175
|
+
.select_from(StageInputTable)
|
|
176
|
+
.join(StageOutputTable, StageOutputTable.uuid == StageInputTable.stage_output_uuid)
|
|
177
|
+
.join(StageInputAttemptTable, StageInputAttemptTable.stage_input_uuid == StageInputTable.uuid)
|
|
178
|
+
.filter(StageInputTable.pipeline_name == pipeline.name)
|
|
179
|
+
.group_by(StageInputTable.consumer_stage, StageOutputTable.topic, StageInputAttemptTable.status)
|
|
180
|
+
)
|
|
181
|
+
for stage, topic, status, count in input_attempt_counts:
|
|
182
|
+
if stage in stages:
|
|
183
|
+
counts = input_attempt_counts_by_topic.setdefault((stage, topic), AttemptCounts())
|
|
184
|
+
setattr(counts, status.lower(), count)
|
|
185
|
+
for (stage, topic), counts in sorted(input_attempt_counts_by_topic.items()):
|
|
186
|
+
stages[stage].stage_input_attempts.append(TopicAttemptCounts(name=topic, counts=counts))
|
|
187
|
+
|
|
188
|
+
output_counts = (
|
|
189
|
+
db
|
|
190
|
+
.query(StageOutputTable.producer_stage, StageOutputTable.topic, sa.func.count())
|
|
191
|
+
.filter(StageOutputTable.pipeline_name == pipeline.name)
|
|
192
|
+
.group_by(StageOutputTable.producer_stage, StageOutputTable.topic)
|
|
193
|
+
.order_by(StageOutputTable.topic)
|
|
194
|
+
)
|
|
195
|
+
for stage, topic, count in output_counts:
|
|
196
|
+
if stage in stages:
|
|
197
|
+
stages[stage].stage_outputs.append(TopicCount(name=topic, count=count))
|
|
198
|
+
|
|
199
|
+
return list(stages.values())
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class StageRunAndStageRunAttempt(BaseModel):
|
|
80
203
|
stage_run: StageRunTable
|
|
81
204
|
stage_run_attempt: StageRunAttemptTable
|
|
82
205
|
|
|
83
206
|
|
|
84
|
-
class StageRunTablesAndPagination(
|
|
207
|
+
class StageRunTablesAndPagination(BaseModel):
|
|
85
208
|
stage_runs: list[StageRunTable]
|
|
86
209
|
pagination: Pagination
|
|
87
210
|
|
|
@@ -95,6 +218,55 @@ def list_stage_runs(
|
|
|
95
218
|
skip: int = Query(0, ge=0),
|
|
96
219
|
limit: int = Query(100, ge=1, le=1000),
|
|
97
220
|
db: sa_orm.Session = Depends(make_session),
|
|
221
|
+
) -> StageRunTablesAndPagination:
|
|
222
|
+
return stage_run_page(
|
|
223
|
+
db,
|
|
224
|
+
pipeline_name=pipeline_name,
|
|
225
|
+
stage=stage,
|
|
226
|
+
title=title,
|
|
227
|
+
status=status,
|
|
228
|
+
skip=skip,
|
|
229
|
+
limit=limit,
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class StageRunSearchRequest(BaseModel):
|
|
234
|
+
filter_sql: str = pdt.Field(min_length=1)
|
|
235
|
+
pipeline_name: str = pdt.Field(min_length=1)
|
|
236
|
+
stage: str = pdt.Field(min_length=1)
|
|
237
|
+
skip: int = pdt.Field(default=0, ge=0)
|
|
238
|
+
limit: int = pdt.Field(default=100, ge=1, le=1000)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@router.post("/stage_runs/search/",
|
|
242
|
+
response_model=StageRunTablesAndPagination,
|
|
243
|
+
dependencies=[Depends(require_query_access)])
|
|
244
|
+
def search_stage_runs(request: StageRunSearchRequest) -> StageRunTablesAndPagination:
|
|
245
|
+
return execute_readonly_filter(
|
|
246
|
+
request.filter_sql,
|
|
247
|
+
validator=validate_uuid_column,
|
|
248
|
+
executor=functools.partial(
|
|
249
|
+
stage_run_page,
|
|
250
|
+
pipeline_name=request.pipeline_name,
|
|
251
|
+
stage=request.stage,
|
|
252
|
+
title=None,
|
|
253
|
+
status=None,
|
|
254
|
+
skip=request.skip,
|
|
255
|
+
limit=request.limit,
|
|
256
|
+
),
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def stage_run_page(
|
|
261
|
+
db: sa_orm.Session,
|
|
262
|
+
filter_sql: str | None = None,
|
|
263
|
+
*,
|
|
264
|
+
pipeline_name: str | None,
|
|
265
|
+
stage: str | None,
|
|
266
|
+
title: str | None,
|
|
267
|
+
status: ExecutionStatus | None,
|
|
268
|
+
skip: int,
|
|
269
|
+
limit: int,
|
|
98
270
|
) -> StageRunTablesAndPagination:
|
|
99
271
|
query_stmt = db.query(StageRunTable)
|
|
100
272
|
|
|
@@ -106,6 +278,9 @@ def list_stage_runs(
|
|
|
106
278
|
query_stmt = query_stmt.filter(StageRunTable.title == title)
|
|
107
279
|
if status is not None:
|
|
108
280
|
query_stmt = query_stmt.filter(StageRunTable.status == status)
|
|
281
|
+
if filter_sql is not None:
|
|
282
|
+
matching_stmt = sa.literal_column(f"({filter_sql})")
|
|
283
|
+
query_stmt = query_stmt.filter(StageRunTable.uuid.op("IN", is_comparison=True)(matching_stmt))
|
|
109
284
|
|
|
110
285
|
total = query_stmt.count()
|
|
111
286
|
|
|
@@ -148,7 +323,7 @@ def list_stage_run_attempts(
|
|
|
148
323
|
)
|
|
149
324
|
|
|
150
325
|
|
|
151
|
-
class StageOutputTablesAndPagination(
|
|
326
|
+
class StageOutputTablesAndPagination(BaseModel):
|
|
152
327
|
stage_outputs: list[StageOutputTable]
|
|
153
328
|
pagination: Pagination
|
|
154
329
|
|
|
@@ -162,6 +337,55 @@ def list_stage_outputs(
|
|
|
162
337
|
skip: int = Query(0, ge=0),
|
|
163
338
|
limit: int = Query(100, ge=1, le=1000),
|
|
164
339
|
db: sa_orm.Session = Depends(make_session),
|
|
340
|
+
) -> StageOutputTablesAndPagination:
|
|
341
|
+
return stage_output_page(
|
|
342
|
+
db,
|
|
343
|
+
pipeline_name=pipeline_name,
|
|
344
|
+
producer_stage=producer_stage,
|
|
345
|
+
topic=topic,
|
|
346
|
+
dedup_key=dedup_key,
|
|
347
|
+
skip=skip,
|
|
348
|
+
limit=limit,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
class StageOutputSearchRequest(BaseModel):
|
|
353
|
+
filter_sql: str = pdt.Field(min_length=1)
|
|
354
|
+
pipeline_name: str = pdt.Field(min_length=1)
|
|
355
|
+
producer_stage: str = pdt.Field(min_length=1)
|
|
356
|
+
skip: int = pdt.Field(default=0, ge=0)
|
|
357
|
+
limit: int = pdt.Field(default=100, ge=1, le=1000)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
@router.post("/stage_outputs/search/",
|
|
361
|
+
response_model=StageOutputTablesAndPagination,
|
|
362
|
+
dependencies=[Depends(require_query_access)])
|
|
363
|
+
def search_stage_outputs(request: StageOutputSearchRequest) -> StageOutputTablesAndPagination:
|
|
364
|
+
return execute_readonly_filter(
|
|
365
|
+
request.filter_sql,
|
|
366
|
+
validator=validate_uuid_column,
|
|
367
|
+
executor=functools.partial(
|
|
368
|
+
stage_output_page,
|
|
369
|
+
pipeline_name=request.pipeline_name,
|
|
370
|
+
producer_stage=request.producer_stage,
|
|
371
|
+
topic=None,
|
|
372
|
+
dedup_key=None,
|
|
373
|
+
skip=request.skip,
|
|
374
|
+
limit=request.limit,
|
|
375
|
+
),
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def stage_output_page(
|
|
380
|
+
db: sa_orm.Session,
|
|
381
|
+
filter_sql: str | None = None,
|
|
382
|
+
*,
|
|
383
|
+
pipeline_name: str | None,
|
|
384
|
+
producer_stage: str | None,
|
|
385
|
+
topic: str | None,
|
|
386
|
+
dedup_key: str | None,
|
|
387
|
+
skip: int,
|
|
388
|
+
limit: int,
|
|
165
389
|
) -> StageOutputTablesAndPagination:
|
|
166
390
|
query_stmt = db.query(StageOutputTable)
|
|
167
391
|
|
|
@@ -173,6 +397,9 @@ def list_stage_outputs(
|
|
|
173
397
|
query_stmt = query_stmt.filter(StageOutputTable.topic == topic)
|
|
174
398
|
if dedup_key is not None:
|
|
175
399
|
query_stmt = query_stmt.filter(StageOutputTable.dedup_key == dedup_key)
|
|
400
|
+
if filter_sql is not None:
|
|
401
|
+
matching_stmt = sa.literal_column(f"({filter_sql})")
|
|
402
|
+
query_stmt = query_stmt.filter(StageOutputTable.uuid.op("IN", is_comparison=True)(matching_stmt))
|
|
176
403
|
|
|
177
404
|
total = query_stmt.count()
|
|
178
405
|
|
|
@@ -192,7 +419,7 @@ def read_stage_output(stage_output_uuid: py_uuid.UUID, db: sa_orm.Session = Depe
|
|
|
192
419
|
return db_stage_output
|
|
193
420
|
|
|
194
421
|
|
|
195
|
-
class StageInputTablesAndPagination(
|
|
422
|
+
class StageInputTablesAndPagination(BaseModel):
|
|
196
423
|
stage_inputs: list[StageInputTable]
|
|
197
424
|
pagination: Pagination
|
|
198
425
|
|
|
@@ -208,6 +435,61 @@ def list_stage_inputs(
|
|
|
208
435
|
skip: int = Query(0, ge=0),
|
|
209
436
|
limit: int = Query(100, ge=1, le=1000),
|
|
210
437
|
db: sa_orm.Session = Depends(make_session),
|
|
438
|
+
) -> StageInputTablesAndPagination:
|
|
439
|
+
return stage_input_page(
|
|
440
|
+
db,
|
|
441
|
+
pipeline_name=pipeline_name,
|
|
442
|
+
producer_stage=producer_stage,
|
|
443
|
+
consumer_stage=consumer_stage,
|
|
444
|
+
topic=topic,
|
|
445
|
+
stage_output_uuid=stage_output_uuid,
|
|
446
|
+
status=status,
|
|
447
|
+
skip=skip,
|
|
448
|
+
limit=limit,
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
|
|
452
|
+
class StageInputSearchRequest(BaseModel):
|
|
453
|
+
filter_sql: str = pdt.Field(min_length=1)
|
|
454
|
+
pipeline_name: str = pdt.Field(min_length=1)
|
|
455
|
+
consumer_stage: str = pdt.Field(min_length=1)
|
|
456
|
+
skip: int = pdt.Field(default=0, ge=0)
|
|
457
|
+
limit: int = pdt.Field(default=100, ge=1, le=1000)
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
@router.post("/stage_inputs/search/",
|
|
461
|
+
response_model=StageInputTablesAndPagination,
|
|
462
|
+
dependencies=[Depends(require_query_access)])
|
|
463
|
+
def search_stage_inputs(request: StageInputSearchRequest) -> StageInputTablesAndPagination:
|
|
464
|
+
return execute_readonly_filter(
|
|
465
|
+
request.filter_sql,
|
|
466
|
+
validator=validate_uuid_column,
|
|
467
|
+
executor=functools.partial(
|
|
468
|
+
stage_input_page,
|
|
469
|
+
pipeline_name=request.pipeline_name,
|
|
470
|
+
producer_stage=None,
|
|
471
|
+
consumer_stage=request.consumer_stage,
|
|
472
|
+
topic=None,
|
|
473
|
+
stage_output_uuid=None,
|
|
474
|
+
status=None,
|
|
475
|
+
skip=request.skip,
|
|
476
|
+
limit=request.limit,
|
|
477
|
+
),
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
def stage_input_page(
|
|
482
|
+
db: sa_orm.Session,
|
|
483
|
+
filter_sql: str | None = None,
|
|
484
|
+
*,
|
|
485
|
+
pipeline_name: str | None,
|
|
486
|
+
producer_stage: str | None,
|
|
487
|
+
consumer_stage: str | None,
|
|
488
|
+
topic: str | None,
|
|
489
|
+
stage_output_uuid: py_uuid.UUID | None,
|
|
490
|
+
status: ExecutionStatus | None,
|
|
491
|
+
skip: int,
|
|
492
|
+
limit: int,
|
|
211
493
|
) -> StageInputTablesAndPagination:
|
|
212
494
|
query_stmt = (
|
|
213
495
|
db
|
|
@@ -227,6 +509,9 @@ def list_stage_inputs(
|
|
|
227
509
|
query_stmt = query_stmt.filter(StageInputTable.stage_output_uuid == stage_output_uuid)
|
|
228
510
|
if status is not None:
|
|
229
511
|
query_stmt = query_stmt.filter(StageInputTable.status == status)
|
|
512
|
+
if filter_sql is not None:
|
|
513
|
+
matching_stmt = sa.literal_column(f"({filter_sql})")
|
|
514
|
+
query_stmt = query_stmt.filter(StageInputTable.uuid.op("IN", is_comparison=True)(matching_stmt))
|
|
230
515
|
|
|
231
516
|
total = query_stmt.count()
|
|
232
517
|
|
|
@@ -956,7 +1241,7 @@ def heartbeat_stage_run(
|
|
|
956
1241
|
return StageRunAndStageRunAttempt(stage_run=db_stage_run, stage_run_attempt=db_stage_run_attempt)
|
|
957
1242
|
|
|
958
1243
|
|
|
959
|
-
class UploadedFile(
|
|
1244
|
+
class UploadedFile(BaseModel):
|
|
960
1245
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
961
1246
|
|
|
962
1247
|
path: str = pdt.Field(min_length=1, max_length=1024)
|
|
@@ -970,7 +1255,7 @@ class UploadedFile(pdt.BaseModel):
|
|
|
970
1255
|
return value.removesuffix("/")
|
|
971
1256
|
|
|
972
1257
|
|
|
973
|
-
class CompleteUploadRequest(
|
|
1258
|
+
class CompleteUploadRequest(BaseModel):
|
|
974
1259
|
model_config = pdt.ConfigDict(extra="forbid")
|
|
975
1260
|
|
|
976
1261
|
pipeline_name: str
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from types import SimpleNamespace
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from plexus.pulse.demeter.platform.cli import CommandTool
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ManageCommandTool(CommandTool):
|
|
9
|
+
@classmethod
|
|
10
|
+
def path(cls) -> list[str]:
|
|
11
|
+
return ["manage"]
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def params(cls) -> list[click.Parameter]:
|
|
15
|
+
return [
|
|
16
|
+
click.Option(["--api-url"],
|
|
17
|
+
envvar="PULSE_DEMETER_API_URL",
|
|
18
|
+
default="http://localhost:8000",
|
|
19
|
+
show_default=True,
|
|
20
|
+
show_envvar=True,
|
|
21
|
+
help="Demeter API URL."),
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def desc(cls) -> str:
|
|
26
|
+
return "Open the pipeline management terminal interface."
|
|
27
|
+
|
|
28
|
+
def run(self, args: SimpleNamespace) -> int:
|
|
29
|
+
if not (click.get_text_stream("stdin").isatty() and click.get_text_stream("stdout").isatty()):
|
|
30
|
+
raise click.UsageError("requires a terminal")
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
from plexus.pulse.demeter.domains.robotic.tui.manage import ManageApp
|
|
34
|
+
ManageApp(args.api_url).run()
|
|
35
|
+
except ModuleNotFoundError:
|
|
36
|
+
raise click.UsageError("tui extra is required")
|
|
37
|
+
return 0
|