Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ nemo files filesets list [OPTIONS]
* `--workspace`
* `--page <INTEGER>`: Page number.
* `--page-size <INTEGER>`: Page size.
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, name, -name]
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, updated_at, -updated_at, name, -name]
Comment thread
albcui marked this conversation as resolved.
* `--all-pages`: Fetch all pages

**Filter Options:**
Expand Down Expand Up @@ -2980,7 +2980,7 @@ nemo inference prompts list [OPTIONS]
* `--workspace`
* `--page <INTEGER>`: Page number.
* `--page-size <INTEGER>`: Page size.
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: name, -name, created_at, -created_at, updated_at, -updated_at]
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, updated_at, -updated_at, name, -name]
* `--all-pages`: Fetch all pages

**Filter Options:**
Expand Down Expand Up @@ -4483,7 +4483,7 @@ nemo models list [OPTIONS]
* `--workspace`
* `--page <INTEGER>`: Page number.
* `--page-size <INTEGER>`: Page size.
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: name, -name, created_at, -created_at, updated_at, -updated_at]
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, updated_at, -updated_at, name, -name]
* `--verbose`: Whether to include full spec details
* `--all-pages`: Fetch all pages

Expand Down Expand Up @@ -5132,7 +5132,7 @@ nemo workspaces list [OPTIONS]
- Object (JSON): `{"name":{"$like":"value"}}` with operators `$eq`, `$like`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$nin`, `$and`, `$or`, `$not`
* `--page <INTEGER>`: Page number
* `--page-size <INTEGER>`: Items per page
* `--sort <CHOICE>`: Sort field [possible values: created_at, -created_at, name, -name]
* `--sort <CHOICE>`: Sort field [possible values: created_at, -created_at, updated_at, -updated_at, name, -name]
* `--all-pages`: Fetch all pages

**Help:**
Expand Down Expand Up @@ -5609,7 +5609,7 @@ nemo guardrail configs list [OPTIONS]
* `--workspace`
* `--page <INTEGER>`: Page number.
* `--page-size <INTEGER>`: Page size.
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, name, -name]
* `--sort <CHOICE>`: The field to sort by. To sort in decreasing order, use `-` in front of the field name. [possible values: created_at, -created_at, updated_at, -updated_at, name, -name]
* `--all-pages`: Fetch all pages

**Filter Options:**
Expand Down
35 changes: 17 additions & 18 deletions openapi/ga/individual/platform.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 17 additions & 18 deletions openapi/ga/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 17 additions & 18 deletions openapi/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions packages/nmp_common/src/nmp/common/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""Common structures used across multiple API endpoints/schemas."""

from datetime import datetime, timezone
from enum import Enum
from enum import Enum, StrEnum
from typing import Generic, List, Optional, TypeVar

from nemo_platform_plugin.schema import Page as Page
Expand Down Expand Up @@ -58,17 +58,26 @@ class PaginatedResult(BaseModel, Generic[T]):
pagination: PaginationData


class GenericSortField(str, Enum):
class GenericSortField(StrEnum):
"""Sort options for entity-store-backed list endpoints.

Members map to entity base columns (see ``BASE_FIELDS``), so any
entity-backed resource (filesets, guardrail configs, workspaces, projects)
can share this without advertising a sort it cannot honor. Prefix a field with ``-`` for
descending order.
"""

CREATED_AT_ASC = "created_at"
CREATED_AT_DESC = "-created_at"
UPDATED_AT_ASC = "updated_at"
UPDATED_AT_DESC = "-updated_at"
NAME_ASC = "name"
NAME_DESC = "-name"


class DeleteResponse(Value):
message: str = Field(default="Resource deleted successfully.")
id: Optional[str] = Field(default=None, description="The ID of the deleted resource.")
deleted_at: Optional[datetime] = Field(default=None, description="The timestamp when the resource was deleted.")
id: str = Field(..., description="The ID of the deleted resource.")


class ErrorResponse(Value):
Expand Down
27 changes: 10 additions & 17 deletions packages/nmp_common/src/nmp/common/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _walk_spec(d: Dict, visitor: Callable[[str, Any, Dict], None]):
_walk_spec(item, visitor)


def _normalize_refs_and_schema_keys(spec: Dict, *, strict_collisions: bool = False) -> Dict:
def _normalize_refs_and_schema_keys(spec: Dict) -> Dict:
"""Normalize all ``$ref`` values and schema dictionary keys.

Schema keys are renamed first so that ``$ref`` values can be rewritten
Expand All @@ -157,13 +157,8 @@ def _normalize_refs_and_schema_keys(spec: Dict, *, strict_collisions: bool = Fal

When the content *differs*, two distinct Pydantic models are fighting over
one schema name, and keeping one silently makes the other's ``$ref``\\ s point
at the wrong contract. With ``strict_collisions`` this raises ``ValueError``
so the build fails loudly — used for self-contained plugin specs (e.g. the
merged ``/apis/customization`` app, where each backend must namespace its
own models). Without it (the default, used for the platform/service specs)
it logs a warning and keeps the first-seen schema, preserving legacy
behaviour: the platform spec carries pre-existing such collisions that
predate this gate and are tracked separately.
at the wrong contract. This raises ``ValueError`` so the build fails loudly
rather than shipping a wrong contract in the generated SDK.
"""
schemas = spec["components"]["schemas"]

Expand All @@ -187,15 +182,13 @@ def _normalize_refs_and_schema_keys(spec: Dict, *, strict_collisions: bool = Fal
if not any(schemas[key] == schemas[rep] for rep in reps):
reps.append(key)
if len(reps) > 1:
message = (
raise ValueError(
f"OpenAPI schema name collision: {sorted(old_keys)} all normalize to "
f"'{target}' with differing content. Two distinct Pydantic models share "
f"a class name across modules — namespace them (e.g. via a per-backend "
f"NamespacedModel base) so they emit distinct schema names."
f"'{target}' with differing content. Two distinct Pydantic models share a "
f"class name across modules; give them distinct names — rename or dedupe the "
f"models, or namespace them (e.g. via a per-backend NamespacedModel base) — so "
f"they emit distinct schema names."
)
if strict_collisions:
raise ValueError(message)
logger.warning("%s Keeping the first-seen schema.", message)

# Iterating ``key_to_target`` preserves ``schemas`` order, so the first raw
# key that maps to a given target still wins the collapse below.
Expand Down Expand Up @@ -355,9 +348,9 @@ def _sort_schemas(spec: Dict) -> Dict:
return spec


def tweak_spec(spec: Dict, *, strict_collisions: bool = False) -> Dict:
def tweak_spec(spec: Dict) -> Dict:
_walk_spec(spec, _anyof_null_visitor)
spec = _normalize_refs_and_schema_keys(spec, strict_collisions=strict_collisions)
spec = _normalize_refs_and_schema_keys(spec)
spec = _split_input_output_schemas(spec)
spec = _annotate_string_references(spec)
spec = _sync_schema_titles(spec)
Expand Down
Loading
Loading