Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e9e39c8
Table with accordians, styling overridden
uzairali19 Aug 22, 2025
8d280a3
update the table with BE
uzairali19 Aug 28, 2025
f8ce699
remove path comment
uzairali19 Aug 28, 2025
906c55c
TEMP parts config with scan_repo
uzairali19 Aug 28, 2025
5f5d01c
fix: use det_cls for defect types instead of name for weld IDs
Yasserelhaddar Aug 28, 2025
734ee04
fix: use actual camera names instead of generic part keys
Yasserelhaddar Aug 28, 2025
8b5d033
fix: display actual parts data instead of debug text in accordion exp…
Yasserelhaddar Aug 28, 2025
295cbbb
fix: use rx.cond instead of if statement to avoid VarTypeError
Yasserelhaddar Aug 28, 2025
7b3753e
fix: return formatted string instead of dict to display actual camera…
Yasserelhaddar Aug 28, 2025
da17ad2
feat: add operator, model version and confidence fields to inspection…
Yasserelhaddar Aug 28, 2025
582cd2c
fix: implement camera status chips with proper data handling and acco…
Yasserelhaddar Aug 28, 2025
3aef5eb
fix: use class method references instead of instance methods in event…
Yasserelhaddar Aug 28, 2025
68a48a8
update with yassers work with few adjustments
uzairali19 Aug 29, 2025
c717c82
updated with new settings
uzairali19 Aug 29, 2025
ec1e2ba
update image links and optimise queries
uzairali19 Sep 2, 2025
fca2525
update password verification
uzairali19 Sep 2, 2025
c620256
change from audit to line view
uzairali19 Sep 2, 2025
001b796
update to lineview
uzairali19 Sep 2, 2025
030df94
query rework
uzairali19 Sep 4, 2025
1daf13b
update parts for images
uzairali19 Sep 8, 2025
23e09aa
updated from scan_repository to dataview
uzairali19 Sep 8, 2025
b0e7004
update with Can's repo
uzairali19 Sep 8, 2025
813e174
update repo
uzairali19 Sep 8, 2025
5e68529
update with indexing
uzairali19 Sep 9, 2025
d0ad510
update table rows design changes
uzairali19 Sep 9, 2025
6e65e06
update cursor
uzairali19 Sep 9, 2025
a9c861d
update bounding box
uzairali19 Sep 9, 2025
48d6f5c
update line view
uzairali19 Sep 9, 2025
f23db34
update code
uzairali19 Sep 9, 2025
dfe2ab0
update chips order
uzairali19 Sep 9, 2025
4a399ba
update dataview table
uzairali19 Sep 9, 2025
8685996
update namesort
uzairali19 Sep 9, 2025
815ae28
update line_view state for redundant values
uzairali19 Sep 12, 2025
13d46da
update with poseidon/dev
uzairali19 Sep 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def rebuild_all_models():
scan_module = sys.modules['poseidon.backend.database.models.scan']
scan_image_module = sys.modules['poseidon.backend.database.models.scan_image']
scan_classification_module = sys.modules['poseidon.backend.database.models.scan_classification']

# Add all models to each module's global namespace for cross-references
models_dict = {
'Organization': Organization,
Expand All @@ -47,7 +47,7 @@ def rebuild_all_models():
'ScanImage': ScanImage,
'ScanClassification': ScanClassification,
}

for module in [organization_module, project_module, user_module, camera_module, model_module, model_deployment_module, scan_module, scan_image_module, scan_classification_module, image_module]:
for name, model_class in models_dict.items():
setattr(module, name, model_class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .enums import ScanStatus
from pymongo import IndexModel, ASCENDING, DESCENDING


if TYPE_CHECKING:
from .organization import Organization
from .project import Project
Expand All @@ -19,31 +18,56 @@ class Scan(MindtraceDocument):
organization: Link["Organization"]
project: Link["Project"]
model_deployment: Link["ModelDeployment"]

# Optional relationship
user: Optional[Link["User"]] = None


# Unique serial number (from camera or generated)
serial_number: str

# Status and results
status: ScanStatus = ScanStatus.PENDING
cls_result: Optional[str] = None
cls_confidence: Optional[float] = None
cls_pred_time: Optional[float] = None # in seconds

# Related images - back-reference
images: List[Link["ScanImage"]] = Field(default_factory=list)

# Timestamps
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))

class Settings:
name = "Scan"
indexes = [
IndexModel([("project.$id", ASCENDING), ("created_at", DESCENDING)], name="scan_project_created_at"),
# Existing index (keep)
IndexModel(
[("project.$id", ASCENDING), ("created_at", DESCENDING)],
name="scan_project_created_at",
),
# Filter by project + result and sort by created_at (very common listing)
IndexModel(
[("project.$id", ASCENDING), ("cls_result", ASCENDING), ("created_at", DESCENDING)],
name="scan_proj_result_created",
),
# Fast global sort by recency (fallback)
IndexModel(
[("created_at", DESCENDING)],
name="scan_created_at_desc",
),
# Serial number lookup
IndexModel(
[("serial_number", ASCENDING)],
name="scan_sn_asc",
),
# If you scope by organization frequently
IndexModel(
[("organization.$id", ASCENDING), ("created_at", DESCENDING)],
name="scan_org_created",
),
]


@before_event(Insert)
def set_creation_timestamps(self):
now = datetime.now(UTC)
Expand All @@ -55,18 +79,14 @@ def update_timestamp(self):
self.updated_at = datetime.now(UTC)

def add_image(self, image: "ScanImage"):
"""Add an image to this scan"""
if image not in self.images:
self.images.append(image)

def remove_image(self, image: "ScanImage"):
"""Remove an image from this scan"""
self.images = [img for img in self.images if img.id != image.id]

def is_completed(self) -> bool:
"""Check if scan is completed"""
return self.status == ScanStatus.COMPLETED

def is_failed(self) -> bool:
"""Check if scan failed"""
return self.status == ScanStatus.FAILED
return self.status == ScanStatus.FAILED
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from asyncio.base_futures import _PENDING
from asyncio.base_futures import _PENDING # (left as in your original file)
from mindtrace.database import MindtraceDocument
from typing import Optional, TYPE_CHECKING
from datetime import datetime, UTC
Expand All @@ -17,19 +17,19 @@ class ScanClassification(MindtraceDocument):
scan: Link["Scan"]
scan_project_id: Optional[PydanticObjectId] = None
is_defect: Optional[bool] = None

# Classification information
name: str # classification name/label
cls_confidence: Optional[float] = None
cls_pred_time: Optional[float] = None # in seconds

# Detection bounding box coordinates
det_cls: Optional[str] = None # detected class
det_x: Optional[float] = None # x coordinate
det_y: Optional[float] = None # y coordinate
det_y: Optional[float] = None # y coordinate
det_w: Optional[float] = None # width
det_h: Optional[float] = None # height

# Timestamps
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
Expand All @@ -38,6 +38,7 @@ class Settings:
name = "ScanClassification"
indexes = [
IndexModel([("scan.$id", ASCENDING), ("created_at", DESCENDING)], name="scancls_scan_created_at"),
IndexModel([("image.$id", ASCENDING)], name="scancls_image_id"),
IndexModel([("name", ASCENDING), ("created_at", DESCENDING)], name="scancls_name_created_at"),
IndexModel([("det_cls", ASCENDING), ("created_at", DESCENDING)], name="scancls_detcls_created_at"),
IndexModel([("scan_project_id", ASCENDING), ("created_at", DESCENDING)], name="scancls_scanprojectid_created_at"),
Expand Down Expand Up @@ -77,4 +78,4 @@ def get_bounding_box(self) -> Optional[dict]:

def is_high_confidence(self, threshold: float = 0.8) -> bool:
"""Check if classification confidence is above threshold"""
return self.cls_confidence is not None and self.cls_confidence >= threshold
return self.cls_confidence is not None and self.cls_confidence >= threshold
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from beanie import Link, before_event, Insert, Replace, SaveChanges
from pydantic import Field
from .enums import ScanImageStatus
from pymongo import IndexModel, ASCENDING, DESCENDING

if TYPE_CHECKING:
from .organization import Organization
Expand All @@ -19,26 +20,34 @@ class ScanImage(MindtraceDocument):
project: Link["Project"]
camera: Link["Camera"]
scan: Link["Scan"]

# Optional relationship
user: Optional[Link["User"]] = None

# Status
status: ScanImageStatus = ScanImageStatus.UPLOADED

# File information
file_name: str
path: str
bucket_name: Optional[str] = None
full_path: str

# Related classifications
classifications: List[Link["ScanClassification"]] = Field(default_factory=list)

# Timestamps
created_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
updated_at: datetime = Field(default_factory=lambda: datetime.now(UTC))

class Settings:
name = "ScanImage"
indexes = [
IndexModel([("scan.$id", ASCENDING), ("created_at", DESCENDING)], name="scanimg_scan_created"),
IndexModel([("project.$id", ASCENDING), ("created_at", DESCENDING)], name="scanimg_project_created"),
IndexModel([("full_path", ASCENDING)], name="scanimg_full_path"),
]

@before_event(Insert)
def set_creation_timestamps(self):
now = datetime.now(UTC)
Expand Down Expand Up @@ -70,4 +79,4 @@ def get_file_url(self) -> str:
"""Get the full file URL/path"""
if self.bucket_name:
return f"gs://{self.bucket_name}/{self.path}/{self.file_name}"
return self.full_path
return self.full_path
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .scan_repository import ScanRepository
from .scan_image_repository import ScanImageRepository
from .scan_classification_repository import ScanClassificationRepository
from .data_view_table_repository import TableRepository

__all__ = [
"UserRepository",
Expand All @@ -19,5 +20,6 @@
"ModelDeploymentRepository",
"ScanRepository",
"ScanImageRepository",
"ScanClassificationRepository"
"ScanClassificationRepository",
"TableRepository",
]
Loading