plexus-python-pulse-demeter 1.1.145__py3-none-any.whl → 1.2.146__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 +58 -0
- plexus/pulse/demeter/cli.py +24 -0
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/catalog_endpoints.py +16 -17
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/catalog_internal_endpoints.py +3 -3
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/inventory_endpoints.py +9 -20
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/inventory_internal_endpoints.py +8 -6
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/tagging_endpoints.py +4 -6
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/workflow_endpoints.py +11 -11
- plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/workflow_internal_endpoints.py +3 -3
- plexus/pulse/demeter/domains/autodrive/cli/dataset.py +72 -0
- plexus/pulse/demeter/domains/autodrive/cli/tag_cache.py +173 -0
- plexus/pulse/demeter/{utils/datasetutils.py → domains/autodrive/dataset.py} +7 -245
- plexus/pulse/demeter/{app/models/autodrive → domains/autodrive/models}/catalog.py +2 -289
- plexus/pulse/demeter/domains/autodrive/models/dataset.py +250 -0
- plexus/pulse/demeter/{app/models/autodrive → domains/autodrive/models}/inventory.py +2 -135
- plexus/pulse/demeter/{app/models/autodrive → domains/autodrive/models}/tagging.py +2 -93
- plexus/pulse/demeter/{app/models/autodrive → domains/autodrive/models}/workflow.py +2 -138
- plexus/pulse/demeter/domains/autodrive/tables/catalog.py +313 -0
- plexus/pulse/demeter/domains/autodrive/tables/inventory.py +151 -0
- plexus/pulse/demeter/domains/autodrive/tables/tagging.py +108 -0
- plexus/pulse/demeter/domains/autodrive/tables/workflow.py +153 -0
- plexus/pulse/demeter/{app/api/robotic → domains/robotic/api}/catalog_endpoints.py +17 -28
- plexus/pulse/demeter/{app/api/robotic → domains/robotic/api}/catalog_internal_endpoints.py +15 -13
- plexus/pulse/demeter/{app/api/robotic → domains/robotic/api}/pipeline_endpoints.py +33 -51
- plexus/pulse/demeter/{app/api/robotic → domains/robotic/api}/pipeline_internal_endpoints.py +9 -7
- plexus/pulse/demeter/{app/api/robotic → domains/robotic/api}/pipeline_metrics_endpoints.py +6 -7
- plexus/pulse/demeter/{utils/flowutils.py → domains/robotic/capsule.py} +199 -516
- plexus/pulse/demeter/domains/robotic/cli/__init__.py +0 -0
- plexus/pulse/demeter/domains/robotic/cli/flow_ops.py +59 -0
- plexus/pulse/demeter/{tools/demeter.py → domains/robotic/cli/pipeline.py} +98 -130
- plexus/pulse/demeter/domains/robotic/client.py +176 -0
- plexus/pulse/demeter/domains/robotic/models/__init__.py +0 -0
- plexus/pulse/demeter/domains/robotic/models/capsule.py +268 -0
- plexus/pulse/demeter/{app/models/robotic → domains/robotic/models}/catalog.py +64 -301
- plexus/pulse/demeter/{app/core/pipeline.py → domains/robotic/models/flow.py} +32 -34
- plexus/pulse/demeter/{app/models/robotic → domains/robotic/models}/pipeline.py +45 -220
- plexus/pulse/demeter/domains/robotic/sdk/__init__.py +0 -0
- plexus/pulse/demeter/domains/robotic/sdk/flow.py +27 -0
- plexus/pulse/demeter/domains/robotic/sdk/oss.py +59 -0
- plexus/pulse/demeter/domains/robotic/tables/__init__.py +0 -0
- plexus/pulse/demeter/domains/robotic/tables/catalog.py +257 -0
- plexus/pulse/demeter/domains/robotic/tables/pipeline.py +189 -0
- plexus/pulse/demeter/platform/__init__.py +0 -0
- plexus/pulse/demeter/{app → platform}/api/__init__.py +0 -44
- plexus/pulse/demeter/{app → platform}/api/iam_internal_endpoints.py +12 -10
- plexus/pulse/demeter/platform/cli.py +65 -0
- plexus/pulse/demeter/{utils → platform}/config.py +1 -0
- plexus/pulse/demeter/{app/core → platform}/database.py +8 -1
- plexus/pulse/demeter/{app → platform}/models/__init__.py +0 -2
- plexus/pulse/demeter/platform/models/iam.py +296 -0
- plexus/pulse/demeter/{app/core → platform}/rbac.py +9 -7
- plexus/pulse/demeter/platform/tables/__init__.py +0 -0
- plexus/pulse/demeter/platform/tables/iam.py +241 -0
- plexus/pulse/demeter/{app/core → platform}/vault.py +1 -1
- plexus/pulse/demeter/sdk.py +6 -0
- {plexus_python_pulse_demeter-1.1.145.dist-info → plexus_python_pulse_demeter-1.2.146.dist-info}/METADATA +18 -20
- plexus_python_pulse_demeter-1.2.146.dist-info/RECORD +69 -0
- plexus_python_pulse_demeter-1.2.146.dist-info/entry_points.txt +3 -0
- plexus/pulse/demeter/app/main.py +0 -16
- plexus/pulse/demeter/app/models/iam.py +0 -532
- plexus/pulse/demeter/tools/main.py +0 -412
- plexus/pulse/demeter/utils/datautils.py +0 -25
- plexus_python_pulse_demeter-1.1.145.dist-info/RECORD +0 -47
- plexus_python_pulse_demeter-1.1.145.dist-info/entry_points.txt +0 -3
- /plexus/pulse/demeter/{app → domains}/__init__.py +0 -0
- /plexus/pulse/demeter/{app/api → domains}/autodrive/__init__.py +0 -0
- /plexus/pulse/demeter/{app/api/robotic → domains/autodrive/api}/__init__.py +0 -0
- /plexus/pulse/demeter/{app/core → domains/autodrive/cli}/__init__.py +0 -0
- /plexus/pulse/demeter/{app/models/autodrive → domains/autodrive/models}/__init__.py +0 -0
- /plexus/pulse/demeter/{app/models/robotic → domains/autodrive/tables}/__init__.py +0 -0
- /plexus/pulse/demeter/{tools → domains/robotic}/__init__.py +0 -0
- /plexus/pulse/demeter/{utils → domains/robotic/api}/__init__.py +0 -0
- {plexus_python_pulse_demeter-1.1.145.dist-info → plexus_python_pulse_demeter-1.2.146.dist-info}/WHEEL +0 -0
- {plexus_python_pulse_demeter-1.1.145.dist-info → plexus_python_pulse_demeter-1.2.146.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from fastapi import FastAPI
|
|
2
|
+
from fastapi import Response
|
|
3
|
+
from fastapi import status
|
|
4
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def make_api() -> FastAPI:
|
|
8
|
+
from plexus.pulse.demeter.platform.api.iam_internal_endpoints import router as iam_internal_router
|
|
9
|
+
from plexus.pulse.demeter.domains.autodrive.api.inventory_endpoints import router as autodrive_inventory_router
|
|
10
|
+
from plexus.pulse.demeter.domains.autodrive.api.catalog_endpoints import router as autodrive_catalog_router
|
|
11
|
+
from plexus.pulse.demeter.domains.autodrive.api.tagging_endpoints import router as autodrive_tagging_router
|
|
12
|
+
from plexus.pulse.demeter.domains.autodrive.api.workflow_endpoints import router as autodrive_workflow_router
|
|
13
|
+
from plexus.pulse.demeter.domains.autodrive.api.inventory_internal_endpoints import router as autodrive_inventory_internal_router
|
|
14
|
+
from plexus.pulse.demeter.domains.autodrive.api.catalog_internal_endpoints import router as autodrive_catalog_internal_router
|
|
15
|
+
from plexus.pulse.demeter.domains.autodrive.api.workflow_internal_endpoints import router as autodrive_workflow_internal_router
|
|
16
|
+
from plexus.pulse.demeter.domains.robotic.api.catalog_endpoints import router as robotic_catalog_router
|
|
17
|
+
from plexus.pulse.demeter.domains.robotic.api.catalog_internal_endpoints import router as robotic_catalog_internal_router
|
|
18
|
+
from plexus.pulse.demeter.domains.robotic.api.pipeline_endpoints import router as robotic_pipeline_router
|
|
19
|
+
from plexus.pulse.demeter.domains.robotic.api.pipeline_metrics_endpoints import router as robotic_pipeline_metrics_router
|
|
20
|
+
from plexus.pulse.demeter.domains.robotic.api.pipeline_internal_endpoints import router as robotic_pipeline_internal_router
|
|
21
|
+
|
|
22
|
+
api = FastAPI(title="Pulse Demeter API", description="API for Pulse Demeter")
|
|
23
|
+
api.add_middleware(
|
|
24
|
+
CORSMiddleware,
|
|
25
|
+
allow_origins=["*"],
|
|
26
|
+
allow_credentials=True,
|
|
27
|
+
allow_methods=["*"],
|
|
28
|
+
allow_headers=["*"],
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
api.include_router(iam_internal_router)
|
|
32
|
+
api.include_router(autodrive_inventory_router)
|
|
33
|
+
api.include_router(autodrive_catalog_router)
|
|
34
|
+
api.include_router(autodrive_workflow_router)
|
|
35
|
+
api.include_router(autodrive_tagging_router)
|
|
36
|
+
api.include_router(autodrive_inventory_internal_router)
|
|
37
|
+
api.include_router(autodrive_catalog_internal_router)
|
|
38
|
+
api.include_router(autodrive_workflow_internal_router)
|
|
39
|
+
api.include_router(robotic_catalog_router)
|
|
40
|
+
api.include_router(robotic_catalog_internal_router)
|
|
41
|
+
api.include_router(robotic_pipeline_router)
|
|
42
|
+
api.include_router(robotic_pipeline_internal_router)
|
|
43
|
+
api.include_router(robotic_pipeline_metrics_router)
|
|
44
|
+
|
|
45
|
+
return api
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
app = make_api()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@app.get("/health")
|
|
52
|
+
async def check_health():
|
|
53
|
+
return Response(status_code=status.HTTP_200_OK)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@app.get("/live")
|
|
57
|
+
async def check_liveness():
|
|
58
|
+
return Response(status_code=status.HTTP_200_OK)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from plexus.pulse.demeter.domains.autodrive.cli.dataset import DatasetValidateCommandTool
|
|
2
|
+
from plexus.pulse.demeter.domains.autodrive.cli.tag_cache import (
|
|
3
|
+
TagCacheUploadCommandTool,
|
|
4
|
+
TagCacheValidateCommandTool,
|
|
5
|
+
)
|
|
6
|
+
from plexus.pulse.demeter.domains.robotic.cli.flow_ops import FlowOpsCommandTool
|
|
7
|
+
from plexus.pulse.demeter.domains.robotic.cli.pipeline import PipelineUploadCommandTool
|
|
8
|
+
from plexus.pulse.demeter.platform.cli import CommandTool, run_cli
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main() -> None:
|
|
12
|
+
tools: list[type[CommandTool]] = [
|
|
13
|
+
TagCacheUploadCommandTool,
|
|
14
|
+
TagCacheValidateCommandTool,
|
|
15
|
+
DatasetValidateCommandTool,
|
|
16
|
+
FlowOpsCommandTool,
|
|
17
|
+
PipelineUploadCommandTool,
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
run_cli(tools)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
if __name__ == "__main__":
|
|
24
|
+
main()
|
|
@@ -20,13 +20,16 @@ from plexus.pulse.common.utils.ormutils import (
|
|
|
20
20
|
db_read_active_revision_models,
|
|
21
21
|
model_name_of,
|
|
22
22
|
)
|
|
23
|
-
from plexus.pulse.common.utils.sqlutils import escape_sql_like
|
|
24
23
|
from plexus.pulse.common.utils.tagutils import predefined_tagsets
|
|
25
24
|
|
|
26
|
-
from plexus.pulse.demeter.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
from plexus.pulse.demeter.domains.autodrive.models.catalog import (
|
|
26
|
+
RegisteredDataset as Dataset,
|
|
27
|
+
RegisteredSample as Sample,
|
|
28
|
+
SampleAnnotation as Annotation,
|
|
29
|
+
SampleClassifier as Classifier,
|
|
30
|
+
)
|
|
31
|
+
from plexus.pulse.demeter.domains.autodrive.models.workflow import JobStatusFlag
|
|
32
|
+
from plexus.pulse.demeter.domains.autodrive.tables.catalog import (
|
|
30
33
|
AnnotationGuidelineTable as GuidelineTable,
|
|
31
34
|
ClassifierTaxonomyTable as TaxonomyTable,
|
|
32
35
|
ModelArchitectureTable as ArchitectureTable,
|
|
@@ -41,21 +44,17 @@ from plexus.pulse.demeter.app.models.autodrive.catalog import (
|
|
|
41
44
|
SampleClassifierTable as ClassifierTable,
|
|
42
45
|
SampleLayoutTable as LayoutTable,
|
|
43
46
|
)
|
|
44
|
-
from plexus.pulse.demeter.
|
|
45
|
-
RegisteredDataset as Dataset,
|
|
46
|
-
RegisteredSample as Sample,
|
|
47
|
-
SampleAnnotation as Annotation,
|
|
48
|
-
SampleClassifier as Classifier,
|
|
49
|
-
)
|
|
50
|
-
from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
47
|
+
from plexus.pulse.demeter.domains.autodrive.tables.workflow import (
|
|
51
48
|
DatasetPromotionTable as DatasetPromotionTable,
|
|
52
49
|
DatasetRegistrationTable as RegistrationTable,
|
|
53
|
-
JobStatusFlag,
|
|
54
50
|
ModelAssessmentPromotionTable as AssessmentPromotionTable,
|
|
55
51
|
ModelEvaluationTable as EvaluationTable,
|
|
56
52
|
ModelExperimentPromotionTable as ExperimentPromotionTable,
|
|
57
53
|
ModelTrainingTable as TrainingTable,
|
|
58
54
|
)
|
|
55
|
+
from plexus.pulse.demeter.platform.api import ColumnFormatter, ColumnOrdering, Pagination, TableColumn
|
|
56
|
+
from plexus.pulse.demeter.platform.api import current_dt_clock
|
|
57
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
59
58
|
|
|
60
59
|
router = APIRouter(prefix="/pulse_demeter/autodrive/catalog", tags=["autodrive", "catalog"])
|
|
61
60
|
|
|
@@ -295,7 +294,7 @@ def list_datasets(
|
|
|
295
294
|
if end_at is not None:
|
|
296
295
|
query_stmt = query_stmt.where(DatasetTable.created_at < end_at)
|
|
297
296
|
if name_match is not None:
|
|
298
|
-
query_stmt = query_stmt.where(DatasetTable.name.
|
|
297
|
+
query_stmt = query_stmt.where(DatasetTable.name.icontains(name_match, autoescape=True))
|
|
299
298
|
if contributor_sso_sid is not None:
|
|
300
299
|
query_stmt = query_stmt.where(DatasetTable.contributor_sso_sid == contributor_sso_sid)
|
|
301
300
|
query_stmt = query_stmt.order_by(*db_make_order_by_clause(DatasetTable, order_by))
|
|
@@ -432,7 +431,7 @@ def list_model_experiments(
|
|
|
432
431
|
if architecture_uuid is not None:
|
|
433
432
|
query_stmt = query_stmt.where(ExperimentTable.architecture_uuid == architecture_uuid)
|
|
434
433
|
if name_match is not None:
|
|
435
|
-
query_stmt = query_stmt.where(ExperimentTable.name.
|
|
434
|
+
query_stmt = query_stmt.where(ExperimentTable.name.icontains(name_match, autoescape=True))
|
|
436
435
|
if contributor_sso_sid is not None:
|
|
437
436
|
query_stmt = query_stmt.where(ExperimentTable.contributor_sso_sid == contributor_sso_sid)
|
|
438
437
|
query_stmt = query_stmt.order_by(*db_make_order_by_clause(ExperimentTable, order_by))
|
|
@@ -607,7 +606,7 @@ def list_model_assessments(
|
|
|
607
606
|
if benchmark_uuid is not None:
|
|
608
607
|
query_stmt = query_stmt.where(AssessmentTable.benchmark_uuid == benchmark_uuid)
|
|
609
608
|
if name_match is not None:
|
|
610
|
-
query_stmt = query_stmt.where(AssessmentTable.name.
|
|
609
|
+
query_stmt = query_stmt.where(AssessmentTable.name.icontains(name_match, autoescape=True))
|
|
611
610
|
if contributor_sso_sid is not None:
|
|
612
611
|
query_stmt = query_stmt.where(AssessmentTable.contributor_sso_sid == contributor_sso_sid)
|
|
613
612
|
query_stmt = query_stmt.order_by(*db_make_order_by_clause(AssessmentTable, order_by))
|
|
@@ -1947,7 +1946,7 @@ def benchmark_rankings(
|
|
|
1947
1946
|
if end_at is not None:
|
|
1948
1947
|
query_stmt = query_stmt.where(AssessmentTable.created_at < end_at)
|
|
1949
1948
|
if name_match is not None:
|
|
1950
|
-
query_stmt = query_stmt.where(AssessmentTable.name.
|
|
1949
|
+
query_stmt = query_stmt.where(AssessmentTable.name.icontains(name_match, autoescape=True))
|
|
1951
1950
|
if contributor_sso_sid is not None:
|
|
1952
1951
|
query_stmt = query_stmt.where(AssessmentTable.contributor_sso_sid == contributor_sso_sid)
|
|
1953
1952
|
|
plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/catalog_internal_endpoints.py
RENAMED
|
@@ -15,8 +15,7 @@ from plexus.pulse.common.utils.ormutils import (
|
|
|
15
15
|
db_update_revision_model,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from plexus.pulse.demeter.
|
|
19
|
-
from plexus.pulse.demeter.app.models.autodrive.catalog import (
|
|
18
|
+
from plexus.pulse.demeter.domains.autodrive.models.catalog import (
|
|
20
19
|
AnnotationGuideline as Guideline,
|
|
21
20
|
ClassifierTaxonomy as Taxonomy,
|
|
22
21
|
ModelArchitecture as Architecture,
|
|
@@ -29,7 +28,7 @@ from plexus.pulse.demeter.app.models.autodrive.catalog import (
|
|
|
29
28
|
SampleClassifier as Classifier,
|
|
30
29
|
SampleLayout as Layout,
|
|
31
30
|
)
|
|
32
|
-
from plexus.pulse.demeter.
|
|
31
|
+
from plexus.pulse.demeter.domains.autodrive.tables.catalog import (
|
|
33
32
|
AnnotationGuidelineTable as GuidelineTable,
|
|
34
33
|
ClassifierTaxonomyTable as TaxonomyTable,
|
|
35
34
|
ModelArchitectureTable as ArchitectureTable,
|
|
@@ -42,6 +41,7 @@ from plexus.pulse.demeter.app.models.autodrive.catalog import (
|
|
|
42
41
|
SampleClassifierTable as ClassifierTable,
|
|
43
42
|
SampleLayoutTable as LayoutTable,
|
|
44
43
|
)
|
|
44
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
45
45
|
|
|
46
46
|
router = APIRouter(prefix="/pulse_demeter/autodrive/internal/catalog", tags=["autodrive", "catalog", "internal"])
|
|
47
47
|
|
|
@@ -6,24 +6,17 @@ import sqlalchemy.exc as sa_exc
|
|
|
6
6
|
import sqlalchemy.orm as sa_orm
|
|
7
7
|
from fastapi import APIRouter, Body, Depends, Query
|
|
8
8
|
from plexus.pulse.common.utils.apiutils import database_transaction
|
|
9
|
-
from plexus.pulse.common.utils.ormutils import
|
|
10
|
-
db_create_revision_model,
|
|
11
|
-
db_update_revision_model,
|
|
12
|
-
model_name_of,
|
|
13
|
-
)
|
|
14
|
-
from plexus.pulse.common.utils.sqlutils import escape_sql_like
|
|
9
|
+
from plexus.pulse.common.utils.ormutils import db_create_revision_model, db_update_revision_model, model_name_of
|
|
15
10
|
|
|
16
|
-
from plexus.pulse.demeter.
|
|
17
|
-
from plexus.pulse.demeter.
|
|
18
|
-
from plexus.pulse.demeter.app.core.database import make_session
|
|
19
|
-
from plexus.pulse.demeter.app.models.autodrive.inventory import (
|
|
20
|
-
RegisteredBag as Bag,
|
|
11
|
+
from plexus.pulse.demeter.domains.autodrive.models.inventory import RegisteredBag as Bag, Sensor, Vehicle
|
|
12
|
+
from plexus.pulse.demeter.domains.autodrive.tables.inventory import (
|
|
21
13
|
RegisteredBagTable as BagTable,
|
|
22
|
-
Sensor,
|
|
23
14
|
SensorTable,
|
|
24
|
-
Vehicle,
|
|
25
15
|
VehicleTable,
|
|
26
16
|
)
|
|
17
|
+
from plexus.pulse.demeter.platform.api import Pagination
|
|
18
|
+
from plexus.pulse.demeter.platform.api import current_dt_clock
|
|
19
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
27
20
|
|
|
28
21
|
router = APIRouter(prefix="/pulse_demeter/autodrive/inventory", tags=["autodrive", "inventory"])
|
|
29
22
|
|
|
@@ -126,9 +119,7 @@ def retrieve_vehicles(
|
|
|
126
119
|
with database_transaction(db):
|
|
127
120
|
query_stmt = db.query(VehicleTable).where(VehicleTable.expired_at.is_(None))
|
|
128
121
|
if name_match:
|
|
129
|
-
query_stmt = query_stmt.where(
|
|
130
|
-
VehicleTable.name.ilike(f"%{escape_sql_like(name_match)}%", escape="\\"),
|
|
131
|
-
)
|
|
122
|
+
query_stmt = query_stmt.where(VehicleTable.name.icontains(name_match, autoescape=True))
|
|
132
123
|
|
|
133
124
|
total = query_stmt.count()
|
|
134
125
|
db_vehicles = query_stmt.order_by(VehicleTable.sqn.asc()).offset(skip).limit(limit).all()
|
|
@@ -172,9 +163,7 @@ def retrieve_sensors(
|
|
|
172
163
|
with database_transaction(db):
|
|
173
164
|
query_stmt = db.query(SensorTable).where(SensorTable.expired_at.is_(None))
|
|
174
165
|
if serial_number_match:
|
|
175
|
-
query_stmt = query_stmt.where(
|
|
176
|
-
SensorTable.serial_number.ilike(f"%{escape_sql_like(serial_number_match)}%", escape="\\"),
|
|
177
|
-
)
|
|
166
|
+
query_stmt = query_stmt.where(SensorTable.serial_number.icontains(serial_number_match, autoescape=True))
|
|
178
167
|
|
|
179
168
|
total = query_stmt.count()
|
|
180
169
|
db_sensors = query_stmt.order_by(SensorTable.sqn.asc()).offset(skip).limit(limit).all()
|
|
@@ -227,7 +216,7 @@ def retrieve_bags(
|
|
|
227
216
|
if vehicle_names:
|
|
228
217
|
query_stmt = query_stmt.where(BagTable.vehicle_name.in_(vehicle_names))
|
|
229
218
|
if name_match:
|
|
230
|
-
query_stmt = query_stmt.where(BagTable.name.
|
|
219
|
+
query_stmt = query_stmt.where(BagTable.name.icontains(name_match, autoescape=True))
|
|
231
220
|
|
|
232
221
|
total = query_stmt.count()
|
|
233
222
|
db_bags = query_stmt.order_by(BagTable.sqn.asc()).offset(skip).limit(limit).all()
|
plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/inventory_internal_endpoints.py
RENAMED
|
@@ -15,19 +15,21 @@ from plexus.pulse.common.utils.ormutils import (
|
|
|
15
15
|
db_update_revision_model,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from plexus.pulse.demeter.
|
|
19
|
-
from plexus.pulse.demeter.app.models.autodrive.inventory import (
|
|
18
|
+
from plexus.pulse.demeter.domains.autodrive.models.inventory import (
|
|
20
19
|
RegisteredBag as Bag,
|
|
21
|
-
RegisteredBagTable as BagTable,
|
|
22
20
|
Sensor,
|
|
23
|
-
SensorTable,
|
|
24
21
|
SensorTemplate,
|
|
25
|
-
SensorTemplateTable,
|
|
26
22
|
Vehicle,
|
|
27
|
-
VehicleTable,
|
|
28
23
|
VehicleTemplate,
|
|
24
|
+
)
|
|
25
|
+
from plexus.pulse.demeter.domains.autodrive.tables.inventory import (
|
|
26
|
+
RegisteredBagTable as BagTable,
|
|
27
|
+
SensorTable,
|
|
28
|
+
SensorTemplateTable,
|
|
29
|
+
VehicleTable,
|
|
29
30
|
VehicleTemplateTable,
|
|
30
31
|
)
|
|
32
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
31
33
|
|
|
32
34
|
router = APIRouter(prefix="/pulse_demeter/autodrive/internal/inventory", tags=["autodrive", "inventory", "internal"])
|
|
33
35
|
|
|
@@ -23,16 +23,14 @@ from plexus.pulse.common.utils.tagutils import TagCache
|
|
|
23
23
|
from plexus.pulse.common.utils.tagutils import populate_clip_ranges, predefined_tagsets, standard_clip_duration_us
|
|
24
24
|
from plexus.pulse.common.utils.tagutils import versioned_identifier
|
|
25
25
|
|
|
26
|
-
from plexus.pulse.demeter.
|
|
27
|
-
from plexus.pulse.demeter.
|
|
28
|
-
from plexus.pulse.demeter.app.models.autodrive.tagging import (
|
|
29
|
-
DataTagClip,
|
|
26
|
+
from plexus.pulse.demeter.domains.autodrive.models.tagging import DataTagClip, DataTagRecord, DataTagTarget
|
|
27
|
+
from plexus.pulse.demeter.domains.autodrive.tables.tagging import (
|
|
30
28
|
DataTagClipTable,
|
|
31
|
-
DataTagRecord,
|
|
32
29
|
DataTagRecordTable,
|
|
33
|
-
DataTagTarget,
|
|
34
30
|
DataTagTargetTable,
|
|
35
31
|
)
|
|
32
|
+
from plexus.pulse.demeter.platform.api import Pagination
|
|
33
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
36
34
|
|
|
37
35
|
router = APIRouter(prefix="/pulse_demeter/autodrive/tagging", tags=["autodrive", "tagging"])
|
|
38
36
|
|
|
@@ -15,19 +15,12 @@ from plexus.pulse.common.utils.ormutils import (
|
|
|
15
15
|
model_name_of,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from plexus.pulse.demeter.
|
|
19
|
-
from plexus.pulse.demeter.app.core.database import make_session
|
|
20
|
-
from plexus.pulse.demeter.app.models.autodrive.catalog import (
|
|
18
|
+
from plexus.pulse.demeter.domains.autodrive.models.catalog import (
|
|
21
19
|
ModelAssessment as Assessment,
|
|
22
20
|
ModelExperiment as Experiment,
|
|
23
21
|
RegisteredDataset as Dataset,
|
|
24
22
|
)
|
|
25
|
-
from plexus.pulse.demeter.
|
|
26
|
-
ModelAssessmentTable as AssessmentTable,
|
|
27
|
-
ModelExperimentTable as ExperimentTable,
|
|
28
|
-
RegisteredDatasetTable as DatasetTable,
|
|
29
|
-
)
|
|
30
|
-
from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
23
|
+
from plexus.pulse.demeter.domains.autodrive.models.workflow import (
|
|
31
24
|
DatasetPromotion as DatasetPromotion,
|
|
32
25
|
DatasetRegistration as Registration,
|
|
33
26
|
ModelAssessmentPromotion as AssessmentPromotion,
|
|
@@ -35,15 +28,22 @@ from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
|
35
28
|
ModelExperimentPromotion as ExperimentPromotion,
|
|
36
29
|
ModelTraining as Training,
|
|
37
30
|
)
|
|
38
|
-
from plexus.pulse.demeter.
|
|
31
|
+
from plexus.pulse.demeter.domains.autodrive.models.workflow import JobStatusFlag
|
|
32
|
+
from plexus.pulse.demeter.domains.autodrive.tables.catalog import (
|
|
33
|
+
ModelAssessmentTable as AssessmentTable,
|
|
34
|
+
ModelExperimentTable as ExperimentTable,
|
|
35
|
+
RegisteredDatasetTable as DatasetTable,
|
|
36
|
+
)
|
|
37
|
+
from plexus.pulse.demeter.domains.autodrive.tables.workflow import (
|
|
39
38
|
DatasetPromotionTable as DatasetPromotionTable,
|
|
40
39
|
DatasetRegistrationTable as RegistrationTable,
|
|
41
|
-
JobStatusFlag,
|
|
42
40
|
ModelAssessmentPromotionTable as AssessmentPromotionTable,
|
|
43
41
|
ModelEvaluationTable as EvaluationTable,
|
|
44
42
|
ModelExperimentPromotionTable as ExperimentPromotionTable,
|
|
45
43
|
ModelTrainingTable as TrainingTable,
|
|
46
44
|
)
|
|
45
|
+
from plexus.pulse.demeter.platform.api import current_dt_clock
|
|
46
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
47
47
|
|
|
48
48
|
router = APIRouter(prefix="/pulse_demeter/autodrive/workflow", tags=["autodrive", "workflow"])
|
|
49
49
|
|
plexus/pulse/demeter/{app/api/autodrive → domains/autodrive/api}/workflow_internal_endpoints.py
RENAMED
|
@@ -15,8 +15,7 @@ from plexus.pulse.common.utils.ormutils import (
|
|
|
15
15
|
db_update_revision_model,
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
-
from plexus.pulse.demeter.
|
|
19
|
-
from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
18
|
+
from plexus.pulse.demeter.domains.autodrive.models.workflow import (
|
|
20
19
|
DatasetPromotion as DatasetPromotion,
|
|
21
20
|
DatasetRegistration as Registration,
|
|
22
21
|
ModelAssessmentPromotion as AssessmentPromotion,
|
|
@@ -24,7 +23,7 @@ from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
|
24
23
|
ModelExperimentPromotion as ExperimentPromotion,
|
|
25
24
|
ModelTraining as Training,
|
|
26
25
|
)
|
|
27
|
-
from plexus.pulse.demeter.
|
|
26
|
+
from plexus.pulse.demeter.domains.autodrive.tables.workflow import (
|
|
28
27
|
DatasetPromotionTable as DatasetPromotionTable,
|
|
29
28
|
DatasetRegistrationTable as RegistrationTable,
|
|
30
29
|
ModelAssessmentPromotionTable as AssessmentPromotionTable,
|
|
@@ -32,6 +31,7 @@ from plexus.pulse.demeter.app.models.autodrive.workflow import (
|
|
|
32
31
|
ModelExperimentPromotionTable as ExperimentPromotionTable,
|
|
33
32
|
ModelTrainingTable as TrainingTable,
|
|
34
33
|
)
|
|
34
|
+
from plexus.pulse.demeter.platform.database import make_session
|
|
35
35
|
|
|
36
36
|
router = APIRouter(prefix="/pulse_demeter/autodrive/internal/workflow", tags=["autodrive", "workflow", "internal"])
|
|
37
37
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from types import SimpleNamespace
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
|
|
6
|
+
from plexus.pulse.demeter.platform.cli import CommandTool
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"DatasetValidateCommandTool",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class DatasetValidateCommandTool(CommandTool):
|
|
14
|
+
@classmethod
|
|
15
|
+
def path(cls) -> list[str]:
|
|
16
|
+
return ["dataset", "validate"]
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def params(cls) -> list[click.Parameter]:
|
|
20
|
+
return [
|
|
21
|
+
click.Argument(["dataset_root"], type=str),
|
|
22
|
+
click.Option(["--api-url"],
|
|
23
|
+
type=str,
|
|
24
|
+
default="http://localhost:8000",
|
|
25
|
+
help="URL of the Demeter API server."),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def desc(cls) -> str:
|
|
30
|
+
return "Validate standalone samples from a specified dataset source directory."
|
|
31
|
+
|
|
32
|
+
def run(self, args: SimpleNamespace) -> int:
|
|
33
|
+
from pathlib import Path
|
|
34
|
+
|
|
35
|
+
import requests
|
|
36
|
+
from cloudpathlib import AnyPath, S3Path
|
|
37
|
+
|
|
38
|
+
from plexus.pulse.demeter.platform.vault import make_progressed_client
|
|
39
|
+
from plexus.pulse.demeter.domains.autodrive.models.catalog import SampleLayout
|
|
40
|
+
from plexus.pulse.demeter.domains.autodrive.dataset import collect_standalone_dataset_samples
|
|
41
|
+
|
|
42
|
+
dataset_root = args.dataset_root
|
|
43
|
+
|
|
44
|
+
logging.info("Starting sample collection from dataset root '%s'.", dataset_root)
|
|
45
|
+
|
|
46
|
+
api_url = args.api_url.rstrip("/")
|
|
47
|
+
|
|
48
|
+
logging.info("Fetching sample layouts from API at '%s'.", api_url)
|
|
49
|
+
|
|
50
|
+
response = requests.get(f"{api_url}/pulse_demeter/autodrive/internal/catalog/layouts/")
|
|
51
|
+
response.raise_for_status()
|
|
52
|
+
|
|
53
|
+
layouts = [SampleLayout.model_validate(item) for item in response.json()]
|
|
54
|
+
|
|
55
|
+
logging.info("Retrieved '%d' sample layouts from API.", len(layouts))
|
|
56
|
+
|
|
57
|
+
if isinstance(AnyPath(dataset_root), S3Path):
|
|
58
|
+
with make_progressed_client() as s3_client:
|
|
59
|
+
dataset_root = s3_client.CloudPath(dataset_root)
|
|
60
|
+
_, _, errors = collect_standalone_dataset_samples(dataset_root, layouts)
|
|
61
|
+
else:
|
|
62
|
+
_, _, errors = collect_standalone_dataset_samples(Path(dataset_root).absolute(), layouts)
|
|
63
|
+
|
|
64
|
+
if len(errors) > 0:
|
|
65
|
+
print("Validation errors found:")
|
|
66
|
+
for error in errors:
|
|
67
|
+
print(f"- {error}")
|
|
68
|
+
return 1
|
|
69
|
+
|
|
70
|
+
logging.info("Sample collection completed successfully with no errors.")
|
|
71
|
+
|
|
72
|
+
return 0
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
from types import SimpleNamespace
|
|
4
|
+
|
|
5
|
+
import click
|
|
6
|
+
|
|
7
|
+
from plexus.pulse.demeter.platform.cli import CommandTool
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"TagCacheUploadCommandTool",
|
|
11
|
+
"TagCacheValidateCommandTool",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TagCacheUploadCommandTool(CommandTool):
|
|
16
|
+
@classmethod
|
|
17
|
+
def path(cls) -> list[str]:
|
|
18
|
+
return ["tag-cache", "upload"]
|
|
19
|
+
|
|
20
|
+
@classmethod
|
|
21
|
+
def params(cls) -> list[click.Parameter]:
|
|
22
|
+
return [
|
|
23
|
+
click.Argument(["tag_cache_file"], type=str),
|
|
24
|
+
click.Option(["--api-url"],
|
|
25
|
+
type=str,
|
|
26
|
+
default=os.environ.get("PULSE_DEMETER_API_URL", "http://localhost:8000"),
|
|
27
|
+
help="Demeter URL (or PULSE_DEMETER_API_URL; defaults to http://localhost:8000)."),
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
@classmethod
|
|
31
|
+
def desc(cls) -> str:
|
|
32
|
+
return "Upload the tag cache SQLite DB file to the Demeter API server for ingestion."
|
|
33
|
+
|
|
34
|
+
def run(self, args: SimpleNamespace) -> int:
|
|
35
|
+
import shutil
|
|
36
|
+
import tempfile
|
|
37
|
+
from pathlib import Path
|
|
38
|
+
|
|
39
|
+
import requests
|
|
40
|
+
from plexus.common.utils.pathutils import make_path
|
|
41
|
+
from plexus.pulse.common.utils.tagutils import TagCache
|
|
42
|
+
from plexus.pulse.common.utils.tagutils import predefined_tagsets
|
|
43
|
+
|
|
44
|
+
tag_cache_file_path = make_path(args.tag_cache_file)
|
|
45
|
+
if not tag_cache_file_path.is_file():
|
|
46
|
+
raise ValueError(f"tag cache file '{args.tag_cache_file}' does not exist or is not a file")
|
|
47
|
+
|
|
48
|
+
api_url = args.api_url.rstrip("/")
|
|
49
|
+
|
|
50
|
+
logging.info("Uploading tag cache from file '%s' to API at '%s'", tag_cache_file_path, api_url)
|
|
51
|
+
|
|
52
|
+
with tempfile.NamedTemporaryFile(suffix=tag_cache_file_path.suffix, delete=False) as temp_file:
|
|
53
|
+
temp_file_path = Path(temp_file.name)
|
|
54
|
+
|
|
55
|
+
try:
|
|
56
|
+
shutil.copy2(tag_cache_file_path, temp_file_path)
|
|
57
|
+
upload_file_path = temp_file_path
|
|
58
|
+
|
|
59
|
+
tag_cache = TagCache(file_path=upload_file_path)
|
|
60
|
+
if args.prune_undefined:
|
|
61
|
+
tag_cache.remove_records(tagsets=list(predefined_tagsets().values()), tagset_inverted=True)
|
|
62
|
+
|
|
63
|
+
with open(upload_file_path, "rb") as fh:
|
|
64
|
+
response = requests.post(f"{api_url}/pulse_demeter/autodrive/tagging/upload_tag_cache/",
|
|
65
|
+
files={"tag_cache_file": fh})
|
|
66
|
+
if response.status_code != 200:
|
|
67
|
+
logging.error("Failed to upload tag cache. Status code '%s', Response:\n%s",
|
|
68
|
+
response.status_code,
|
|
69
|
+
response.text)
|
|
70
|
+
return -1
|
|
71
|
+
|
|
72
|
+
logging.info(
|
|
73
|
+
"Tag cache uploaded successfully to API at '%s' with '%d' tag targets and '%d' tags records were uploaded.",
|
|
74
|
+
api_url,
|
|
75
|
+
len(tag_cache.query_targets()),
|
|
76
|
+
len(list(tag_cache.iter_record_and_targets())),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return 0
|
|
80
|
+
|
|
81
|
+
finally:
|
|
82
|
+
if temp_file_path is not None and temp_file_path.exists():
|
|
83
|
+
temp_file_path.unlink()
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class TagCacheValidateCommandTool(CommandTool):
|
|
87
|
+
@classmethod
|
|
88
|
+
def path(cls) -> list[str]:
|
|
89
|
+
return ["tag-cache", "validate"]
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def params(cls) -> list[click.Parameter]:
|
|
93
|
+
return [
|
|
94
|
+
click.Argument(["tag_cache_file"], type=str),
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def desc(cls) -> str:
|
|
99
|
+
return "Validate the tag cache SQLite DB file and print its contents in a human-readable format."
|
|
100
|
+
|
|
101
|
+
def run(self, args: SimpleNamespace) -> int:
|
|
102
|
+
import uuid as py_uuid
|
|
103
|
+
|
|
104
|
+
import rich.console
|
|
105
|
+
from plexus.common.utils.pathutils import make_path
|
|
106
|
+
from plexus.pulse.common.utils.ormutils import print_model_results
|
|
107
|
+
from plexus.pulse.common.utils.tagutils import TagCache
|
|
108
|
+
from plexus.pulse.common.utils.tagutils import predefined_tagsets
|
|
109
|
+
from plexus.pulse.common.utils.tagutils import versioned_identifier
|
|
110
|
+
|
|
111
|
+
from plexus.pulse.demeter.domains.autodrive.models.tagging import DataTagRecord, DataTagTarget
|
|
112
|
+
|
|
113
|
+
console = rich.console.Console()
|
|
114
|
+
|
|
115
|
+
tag_cache_file_path = make_path(args.tag_cache_file)
|
|
116
|
+
if not tag_cache_file_path.is_file():
|
|
117
|
+
raise ValueError(f"tag cache file '{args.tag_cache_file}' does not exist or is not a file")
|
|
118
|
+
|
|
119
|
+
logging.info("Loading tag cache from file '%s'", tag_cache_file_path)
|
|
120
|
+
|
|
121
|
+
tag_cache = TagCache(file_path=tag_cache_file_path)
|
|
122
|
+
|
|
123
|
+
errors_count = 0
|
|
124
|
+
|
|
125
|
+
for target in tag_cache.query_targets():
|
|
126
|
+
try:
|
|
127
|
+
DataTagTarget(
|
|
128
|
+
uuid=py_uuid.uuid4(),
|
|
129
|
+
tagger_name=target.tagger_name,
|
|
130
|
+
tagger_version=target.tagger_version,
|
|
131
|
+
vehicle_name=target.vehicle_name,
|
|
132
|
+
begin_dt=target.begin_dt,
|
|
133
|
+
end_dt=target.end_dt,
|
|
134
|
+
)
|
|
135
|
+
except Exception as e:
|
|
136
|
+
errors_count += 1
|
|
137
|
+
console.print(
|
|
138
|
+
f"[red]Error:[/red] Failed to parse tag target [bold]{target}[/bold]. Exception: {str(e)}")
|
|
139
|
+
|
|
140
|
+
for record in tag_cache.with_target(target.identifier).iter_records():
|
|
141
|
+
versioned_namespace = versioned_identifier(record.tagset_namespace, record.tagset_version)
|
|
142
|
+
if versioned_namespace not in predefined_tagsets():
|
|
143
|
+
errors_count += 1
|
|
144
|
+
console.print(
|
|
145
|
+
f"[red]Error:[/red] Tagset [bold]{versioned_namespace}[/bold] is not predefined.")
|
|
146
|
+
|
|
147
|
+
try:
|
|
148
|
+
DataTagRecord(
|
|
149
|
+
target_uuid=py_uuid.uuid4(),
|
|
150
|
+
vehicle_name=target.vehicle_name,
|
|
151
|
+
begin_dt=record.begin_dt,
|
|
152
|
+
end_dt=record.end_dt,
|
|
153
|
+
tagset_namespace=record.tagset_namespace,
|
|
154
|
+
tagset_version=record.tagset_version or
|
|
155
|
+
(
|
|
156
|
+
predefined_tagsets().get(record.tagset_namespace).version
|
|
157
|
+
if record.tagset_namespace in predefined_tagsets()
|
|
158
|
+
else None
|
|
159
|
+
),
|
|
160
|
+
tag=record.tag,
|
|
161
|
+
props=record.props,
|
|
162
|
+
)
|
|
163
|
+
except Exception as e:
|
|
164
|
+
errors_count += 1
|
|
165
|
+
console.print(
|
|
166
|
+
f"[red]Error:[/red] Failed to parse tag record [bold]{record}[/bold]. Exception: {str(e)}")
|
|
167
|
+
|
|
168
|
+
logging.info("Tag cache validation completed with '%d' error(s).", errors_count)
|
|
169
|
+
|
|
170
|
+
print_model_results(tag_cache.query_targets())
|
|
171
|
+
print_model_results(tag_cache.iter_record_and_targets())
|
|
172
|
+
|
|
173
|
+
return 0 if errors_count == 0 else -1
|