cuvis-ai-schemas 0.1.0__py3-none-any.whl → 0.1.2__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.
@@ -1,159 +1,159 @@
1
- """UI display extensions for PortSpec."""
2
-
3
- from __future__ import annotations
4
-
5
- from typing import TYPE_CHECKING
6
-
7
- if TYPE_CHECKING:
8
- from cuvis_ai_schemas.pipeline.ports import PortSpec
9
-
10
- # Default RGB colors for different data types
11
- # Extended with hyperspectral/cuvis-ai specific types for comprehensive UI support
12
- DTYPE_COLORS: dict[str, tuple[int, int, int]] = {
13
- # === PyTorch Tensor Types ===
14
- "torch.Tensor": (100, 150, 255), # Blue for generic tensors
15
- "tensor": (255, 200, 150), # Peach for generic tensor type
16
- # Floating point types - warm orange/yellow tones
17
- "torch.float16": (255, 180, 80), # Light orange
18
- "torch.float32": (255, 150, 50), # Orange
19
- "torch.float64": (255, 120, 30), # Dark orange
20
- "torch.bfloat16": (255, 200, 100), # Pale orange
21
- "float16": (255, 180, 80),
22
- "float32": (255, 150, 50),
23
- "float64": (255, 120, 30),
24
- "float": (150, 255, 150), # Green for Python floats
25
- # Integer types - cool blue tones
26
- "torch.int8": (150, 200, 255), # Light blue
27
- "torch.int16": (120, 180, 255), # Medium blue
28
- "torch.int32": (100, 160, 255), # Blue
29
- "torch.int64": (80, 140, 255), # Dark blue
30
- "torch.uint8": (180, 220, 255), # Pale blue
31
- "torch.uint16": (160, 210, 255), # Light pale blue
32
- "int8": (150, 200, 255),
33
- "int16": (120, 180, 255),
34
- "int32": (100, 160, 255),
35
- "int64": (80, 140, 255),
36
- "uint8": (180, 220, 255),
37
- "uint16": (160, 210, 255),
38
- "int": (255, 200, 100), # Orange for Python ints
39
- # Boolean types - green
40
- "torch.bool": (100, 220, 100), # Green
41
- "bool": (255, 150, 150), # Pink for Python bools (keep original for backward compat)
42
- # Complex types - purple tones
43
- "torch.complex64": (200, 150, 255), # Light purple
44
- "torch.complex128": (180, 120, 255), # Purple
45
- # === Python Built-in Types ===
46
- "str": (200, 200, 200), # Gray for strings
47
- "list": (180, 180, 255), # Light blue for lists
48
- "dict": (255, 180, 255), # Light purple for dicts
49
- "object": (180, 180, 180), # Gray for generic objects
50
- # === Hyperspectral/Cuvis-AI Specific Types ===
51
- "cube": (255, 180, 100), # Orange-ish (hyperspectral data cube)
52
- "mask": (150, 255, 150), # Light green (binary/segmentation mask)
53
- "wavelengths": (100, 200, 255), # Light blue (spectral wavelength array)
54
- "bbox": (255, 150, 150), # Light red (bounding box coordinates)
55
- "points": (200, 255, 200), # Pale green (point cloud/coordinates)
56
- "labels": (255, 200, 200), # Light pink (classification labels)
57
- "indices": (200, 180, 255), # Light purple (index array)
58
- "scalar": (255, 255, 180), # Light yellow (single value)
59
- "image": (200, 255, 255), # Light cyan (2D image output)
60
- # === Special/Generic Types ===
61
- "any": (255, 255, 255), # White (accepts anything)
62
- }
63
-
64
- DEFAULT_COLOR = (200, 200, 200) # Light gray for unknown types
65
-
66
-
67
- class PortDisplaySpec:
68
- """UI display wrapper for PortSpec providing color and formatting.
69
-
70
- This class wraps a PortSpec and adds UI-specific display properties
71
- like colors and formatted tooltips.
72
-
73
- Attributes
74
- ----------
75
- port_spec : PortSpec
76
- The underlying port specification
77
-
78
- Examples
79
- --------
80
- >>> from cuvis_ai_schemas.pipeline.ports import PortSpec
81
- >>> port = PortSpec(dtype="torch.Tensor", shape=(1, 3, 224, 224))
82
- >>> display = PortDisplaySpec(port)
83
- >>> display.color
84
- (100, 150, 255)
85
- >>> display.format_tooltip()
86
- 'torch.Tensor\\nShape: (1, 3, 224, 224)'
87
- """
88
-
89
- def __init__(self, port_spec: PortSpec) -> None:
90
- """Initialize display spec.
91
-
92
- Parameters
93
- ----------
94
- port_spec : PortSpec
95
- Port specification to wrap
96
- """
97
- self.port_spec = port_spec
98
-
99
- @property
100
- def color(self) -> tuple[int, int, int]:
101
- """Get RGB color for this port's dtype.
102
-
103
- Returns
104
- -------
105
- tuple[int, int, int]
106
- RGB color tuple (0-255 range)
107
- """
108
- dtype_str = str(self.port_spec.dtype)
109
-
110
- # Try exact match first
111
- if dtype_str in DTYPE_COLORS:
112
- return DTYPE_COLORS[dtype_str]
113
-
114
- # Try to extract typename for partial matches
115
- if hasattr(self.port_spec.dtype, "__name__"):
116
- typename = self.port_spec.dtype.__name__
117
- if typename in DTYPE_COLORS:
118
- return DTYPE_COLORS[typename]
119
-
120
- # Check if it contains "Tensor"
121
- if "Tensor" in dtype_str or "tensor" in dtype_str:
122
- return DTYPE_COLORS["torch.Tensor"]
123
-
124
- return DEFAULT_COLOR
125
-
126
- @property
127
- def display_name(self) -> str:
128
- """Get formatted display name for the dtype.
129
-
130
- Returns
131
- -------
132
- str
133
- Human-readable dtype name
134
- """
135
- if hasattr(self.port_spec.dtype, "__name__"):
136
- return self.port_spec.dtype.__name__
137
- return str(self.port_spec.dtype)
138
-
139
- def format_tooltip(self) -> str:
140
- """Format a tooltip string for UI display.
141
-
142
- Returns
143
- -------
144
- str
145
- Formatted tooltip with dtype, shape, and description
146
- """
147
- lines = [self.display_name]
148
-
149
- if self.port_spec.shape:
150
- shape_str = ", ".join(str(d) for d in self.port_spec.shape)
151
- lines.append(f"Shape: ({shape_str})")
152
-
153
- if self.port_spec.description:
154
- lines.append(f"\\n{self.port_spec.description}")
155
-
156
- if self.port_spec.optional:
157
- lines.append("[Optional]")
158
-
159
- return "\\n".join(lines)
1
+ """UI display extensions for PortSpec."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from cuvis_ai_schemas.pipeline.ports import PortSpec
9
+
10
+ # Default RGB colors for different data types
11
+ # Extended with hyperspectral/cuvis-ai specific types for comprehensive UI support
12
+ DTYPE_COLORS: dict[str, tuple[int, int, int]] = {
13
+ # === PyTorch Tensor Types ===
14
+ "torch.Tensor": (100, 150, 255), # Blue for generic tensors
15
+ "tensor": (255, 200, 150), # Peach for generic tensor type
16
+ # Floating point types - warm orange/yellow tones
17
+ "torch.float16": (255, 180, 80), # Light orange
18
+ "torch.float32": (255, 150, 50), # Orange
19
+ "torch.float64": (255, 120, 30), # Dark orange
20
+ "torch.bfloat16": (255, 200, 100), # Pale orange
21
+ "float16": (255, 180, 80),
22
+ "float32": (255, 150, 50),
23
+ "float64": (255, 120, 30),
24
+ "float": (150, 255, 150), # Green for Python floats
25
+ # Integer types - cool blue tones
26
+ "torch.int8": (150, 200, 255), # Light blue
27
+ "torch.int16": (120, 180, 255), # Medium blue
28
+ "torch.int32": (100, 160, 255), # Blue
29
+ "torch.int64": (80, 140, 255), # Dark blue
30
+ "torch.uint8": (180, 220, 255), # Pale blue
31
+ "torch.uint16": (160, 210, 255), # Light pale blue
32
+ "int8": (150, 200, 255),
33
+ "int16": (120, 180, 255),
34
+ "int32": (100, 160, 255),
35
+ "int64": (80, 140, 255),
36
+ "uint8": (180, 220, 255),
37
+ "uint16": (160, 210, 255),
38
+ "int": (255, 200, 100), # Orange for Python ints
39
+ # Boolean types - green
40
+ "torch.bool": (100, 220, 100), # Green
41
+ "bool": (255, 150, 150), # Pink for Python bools (keep original for backward compat)
42
+ # Complex types - purple tones
43
+ "torch.complex64": (200, 150, 255), # Light purple
44
+ "torch.complex128": (180, 120, 255), # Purple
45
+ # === Python Built-in Types ===
46
+ "str": (200, 200, 200), # Gray for strings
47
+ "list": (180, 180, 255), # Light blue for lists
48
+ "dict": (255, 180, 255), # Light purple for dicts
49
+ "object": (180, 180, 180), # Gray for generic objects
50
+ # === Hyperspectral/Cuvis-AI Specific Types ===
51
+ "cube": (255, 180, 100), # Orange-ish (hyperspectral data cube)
52
+ "mask": (150, 255, 150), # Light green (binary/segmentation mask)
53
+ "wavelengths": (100, 200, 255), # Light blue (spectral wavelength array)
54
+ "bbox": (255, 150, 150), # Light red (bounding box coordinates)
55
+ "points": (200, 255, 200), # Pale green (point cloud/coordinates)
56
+ "labels": (255, 200, 200), # Light pink (classification labels)
57
+ "indices": (200, 180, 255), # Light purple (index array)
58
+ "scalar": (255, 255, 180), # Light yellow (single value)
59
+ "image": (200, 255, 255), # Light cyan (2D image output)
60
+ # === Special/Generic Types ===
61
+ "any": (255, 255, 255), # White (accepts anything)
62
+ }
63
+
64
+ DEFAULT_COLOR = (200, 200, 200) # Light gray for unknown types
65
+
66
+
67
+ class PortDisplaySpec:
68
+ """UI display wrapper for PortSpec providing color and formatting.
69
+
70
+ This class wraps a PortSpec and adds UI-specific display properties
71
+ like colors and formatted tooltips.
72
+
73
+ Attributes
74
+ ----------
75
+ port_spec : PortSpec
76
+ The underlying port specification
77
+
78
+ Examples
79
+ --------
80
+ >>> from cuvis_ai_schemas.pipeline.ports import PortSpec
81
+ >>> port = PortSpec(dtype="torch.Tensor", shape=(1, 3, 224, 224))
82
+ >>> display = PortDisplaySpec(port)
83
+ >>> display.color
84
+ (100, 150, 255)
85
+ >>> display.format_tooltip()
86
+ 'torch.Tensor\\nShape: (1, 3, 224, 224)'
87
+ """
88
+
89
+ def __init__(self, port_spec: PortSpec) -> None:
90
+ """Initialize display spec.
91
+
92
+ Parameters
93
+ ----------
94
+ port_spec : PortSpec
95
+ Port specification to wrap
96
+ """
97
+ self.port_spec = port_spec
98
+
99
+ @property
100
+ def color(self) -> tuple[int, int, int]:
101
+ """Get RGB color for this port's dtype.
102
+
103
+ Returns
104
+ -------
105
+ tuple[int, int, int]
106
+ RGB color tuple (0-255 range)
107
+ """
108
+ dtype_str = str(self.port_spec.dtype)
109
+
110
+ # Try exact match first
111
+ if dtype_str in DTYPE_COLORS:
112
+ return DTYPE_COLORS[dtype_str]
113
+
114
+ # Try to extract typename for partial matches
115
+ if hasattr(self.port_spec.dtype, "__name__"):
116
+ typename = self.port_spec.dtype.__name__
117
+ if typename in DTYPE_COLORS:
118
+ return DTYPE_COLORS[typename]
119
+
120
+ # Check if it contains "Tensor"
121
+ if "Tensor" in dtype_str or "tensor" in dtype_str:
122
+ return DTYPE_COLORS["torch.Tensor"]
123
+
124
+ return DEFAULT_COLOR
125
+
126
+ @property
127
+ def display_name(self) -> str:
128
+ """Get formatted display name for the dtype.
129
+
130
+ Returns
131
+ -------
132
+ str
133
+ Human-readable dtype name
134
+ """
135
+ if hasattr(self.port_spec.dtype, "__name__"):
136
+ return self.port_spec.dtype.__name__
137
+ return str(self.port_spec.dtype)
138
+
139
+ def format_tooltip(self) -> str:
140
+ """Format a tooltip string for UI display.
141
+
142
+ Returns
143
+ -------
144
+ str
145
+ Formatted tooltip with dtype, shape, and description
146
+ """
147
+ lines = [self.display_name]
148
+
149
+ if self.port_spec.shape:
150
+ shape_str = ", ".join(str(d) for d in self.port_spec.shape)
151
+ lines.append(f"Shape: ({shape_str})")
152
+
153
+ if self.port_spec.description:
154
+ lines.append(f"\\n{self.port_spec.description}")
155
+
156
+ if self.port_spec.optional:
157
+ lines.append("[Optional]")
158
+
159
+ return "\\n".join(lines)
@@ -1,3 +1,3 @@
1
- """gRPC proto messages and helpers."""
2
-
3
- __all__: list[str] = []
1
+ """gRPC proto messages and helpers."""
2
+
3
+ __all__: list[str] = []
@@ -1,11 +1,11 @@
1
- """Generated proto files for cuvis.ai gRPC API v1."""
2
-
3
- __all__: list[str] = []
4
-
5
- try:
6
- from cuvis_ai_schemas.grpc.v1 import cuvis_ai_pb2, cuvis_ai_pb2_grpc
7
-
8
- __all__ = ["cuvis_ai_pb2", "cuvis_ai_pb2_grpc"]
9
- except ImportError:
10
- # Proto files not generated yet or proto extra not installed
11
- pass
1
+ """Generated proto files for cuvis.ai gRPC API v1."""
2
+
3
+ __all__: list[str] = []
4
+
5
+ try:
6
+ from cuvis_ai_schemas.grpc.v1 import cuvis_ai_pb2, cuvis_ai_pb2_grpc
7
+
8
+ __all__ = ["cuvis_ai_pb2", "cuvis_ai_pb2_grpc"]
9
+ except ImportError:
10
+ # Proto files not generated yet or proto extra not installed
11
+ pass
@@ -1,17 +1,17 @@
1
- """Pipeline structure schemas."""
2
-
3
- from cuvis_ai_schemas.pipeline.config import (
4
- ConnectionConfig,
5
- NodeConfig,
6
- PipelineConfig,
7
- PipelineMetadata,
8
- )
9
- from cuvis_ai_schemas.pipeline.ports import PortSpec
10
-
11
- __all__ = [
12
- "PipelineConfig",
13
- "PipelineMetadata",
14
- "NodeConfig",
15
- "ConnectionConfig",
16
- "PortSpec",
17
- ]
1
+ """Pipeline structure schemas."""
2
+
3
+ from cuvis_ai_schemas.pipeline.config import (
4
+ ConnectionConfig,
5
+ NodeConfig,
6
+ PipelineConfig,
7
+ PipelineMetadata,
8
+ )
9
+ from cuvis_ai_schemas.pipeline.ports import PortSpec
10
+
11
+ __all__ = [
12
+ "PipelineConfig",
13
+ "PipelineMetadata",
14
+ "NodeConfig",
15
+ "ConnectionConfig",
16
+ "PortSpec",
17
+ ]