|
5 | 5 | # filterable properties for CatalogModel. Based on GetFilterableProperties in |
6 | 6 | # kubeflow/model-registry catalog/internal/db/service/catalog_model.go (PR #1875) |
7 | 7 | # |
8 | | -# Property naming: |
9 | | -# - Context properties: base name only (special case: 'validated_on.array_value' for arrays) |
10 | | -# - Artifact properties: 'artifacts.{name}.{type}' where type is string_value/array_value/double_value/int_value |
| 8 | +# Query structure: |
| 9 | +# 1. First SELECT: Context properties (model-level metadata) |
| 10 | +# - Core properties: Return base name only (e.g., license, provider, tasks) |
| 11 | +# - Custom properties with known types: Add type suffix (e.g., model_type.string_value, validated_on.array_value) |
| 12 | +# 2. UNION ALL |
| 13 | +# 3. Second SELECT: Artifact properties (model artifact metadata) |
| 14 | +# - Format: 'artifacts.{property_name}.{value_type}' |
| 15 | +# - Value types: string_value, array_value, double_value, int_value |
11 | 16 | # |
12 | 17 | # Return format: |
13 | | -# - String/array properties: text array of values |
| 18 | +# - String/array properties: PostgreSQL text array of distinct values |
14 | 19 | # - Numeric properties: 2-element text array [min, max] converted from double/int columns |
15 | 20 | FILTER_OPTIONS_DB_QUERY = """ |
16 | 21 | SELECT |
17 | 22 | CASE |
18 | | - WHEN name = 'validated_on' AND array_value IS NOT NULL THEN name || '.array_value' |
| 23 | + -- Custom properties with array_value get .array_value suffix |
| 24 | + WHEN name IN ('validated_on') AND array_value IS NOT NULL THEN name || '.array_value' |
| 25 | + -- Custom properties with string_value get .string_value suffix |
| 26 | + WHEN name IN ('model_type', 'size', 'tensor_type', 'variant_group_id') THEN name || '.string_value' |
| 27 | + -- Core properties keep base name only |
19 | 28 | ELSE name |
20 | 29 | END AS name, |
21 | 30 | COALESCE(string_value, array_value, '{}'::text[]) AS array_agg |
|
176 | 185 | "artifacts.model_id.string_value", # artifact property with full name |
177 | 186 | } |
178 | 187 |
|
| 188 | +# Fields that are dynamically computed and added by the API but do not exist in the database |
| 189 | +API_COMPUTED_FILTER_FIELDS = { |
| 190 | + "status", # Computed from CatalogSource.status field |
| 191 | +} |
| 192 | + |
179 | 193 | # SQL query for accuracy sorting database validation |
180 | 194 | # Returns an ordered list of model names (context names) that have accuracy metrics. |
181 | 195 | # Models are ordered by their overall_average (accuracy) value from artifact properties. |
|
0 commit comments