Skip to content

Conversation

@pitercl
Copy link
Member

@pitercl pitercl commented Oct 27, 2025

Summary by Sourcery

Add a new global leaderboard search API endpoint and corresponding request model, while updating protobuf typings for ForkPoint optional fields.

New Features:

  • Introduce the search_global_leaderboard_entries_proto retrieval endpoint for querying leaderboard entries across all accessible projects.
  • Add the GlobalSearchParamsDTO model to represent parameters for global leaderboard searches and export it from the public models package.

Enhancements:

  • Adjust ForkPoint protobuf definitions and type stubs so parent_project is treated as an optional/oneof field and keep generated offsets in sync.
  • Include the new global leaderboard search operation in the Redocly code generation filter so it is part of the generated API surface.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 27, 2025

Reviewer's Guide

Adds a new global leaderboard search client and request model, wires the endpoint into codegen/docs, and regenerates protobuf v3/v4 types to make ForkPoint.parent_project optional and keep descriptors in sync.

Sequence diagram for searchGlobalLeaderboardEntriesProto sync request flow

sequenceDiagram
    actor Caller
    participant SearchGlobalLeaderboardEntriesClient
    participant AuthenticatedClient
    participant HttpxClient
    participant NeptuneAPI

    Caller->>SearchGlobalLeaderboardEntriesClient: sync(client, body, x_neptune_client_metadata)
    SearchGlobalLeaderboardEntriesClient->>SearchGlobalLeaderboardEntriesClient: _get_kwargs(body, x_neptune_client_metadata)
    SearchGlobalLeaderboardEntriesClient->>AuthenticatedClient: get_httpx_client()
    AuthenticatedClient-->>SearchGlobalLeaderboardEntriesClient: HttpxClient
    SearchGlobalLeaderboardEntriesClient->>HttpxClient: request(method=post, url=/api/leaderboard/v1/proto/leaderboard/entries/global/search/, json=body.to_dict(), headers)
    HttpxClient->>NeptuneAPI: HTTP POST /api/leaderboard/v1/proto/leaderboard/entries/global/search/
    NeptuneAPI-->>HttpxClient: HTTP response (status, content)
    HttpxClient-->>SearchGlobalLeaderboardEntriesClient: httpx.Response
    SearchGlobalLeaderboardEntriesClient->>SearchGlobalLeaderboardEntriesClient: _build_response(client, response)
    SearchGlobalLeaderboardEntriesClient->>SearchGlobalLeaderboardEntriesClient: _parse_response(client, response)
    SearchGlobalLeaderboardEntriesClient-->>Caller: parsed result (File or Any or None)
Loading

Class diagram for GlobalSearchParamsDTO and related leaderboard search models

classDiagram
    class GlobalSearchParamsDTO {
        +experiment_leader: bool
        +pagination: QueryLeaderboardParamsPaginationDTO
        +query: NqlQueryParamsDTO
        +sorting: QueryLeaderboardParamsSortingParamsDTO
        +additional_properties: Dict~str, Any~
        +to_dict() Dict~str, Any~
        +from_dict(src_dict: Dict~str, Any~) GlobalSearchParamsDTO
        +additional_keys() List~str~
        +__getitem__(key: str) Any
        +__setitem__(key: str, value: Any) None
        +__delitem__(key: str) None
        +__contains__(key: str) bool
    }

    class NqlQueryParamsDTO {
    }

    class QueryLeaderboardParamsPaginationDTO {
    }

    class QueryLeaderboardParamsSortingParamsDTO {
    }

    GlobalSearchParamsDTO --> NqlQueryParamsDTO : query
    GlobalSearchParamsDTO --> QueryLeaderboardParamsPaginationDTO : pagination
    GlobalSearchParamsDTO --> QueryLeaderboardParamsSortingParamsDTO : sorting
Loading

Class diagram for ForkPoint with optional parent_project field

classDiagram
    class Step {
        +whole: uint64
        +micro: uint64
    }

    class ForkPoint {
        +parent_project: str
        +parent_run_id: str
        +step: Step
        +requested_parent_id: str
        +HasField(field_name)
        +ClearField(field_name)
        +WhichOneof(oneof_group)
    }

    ForkPoint --> Step : step

    class ForkPointParentProjectOneof {
        <<oneof>>
        +parent_project: str
    }

    class ForkPointRequestedParentIdOneof {
        <<oneof>>
        +requested_parent_id: str
    }

    ForkPoint *-- ForkPointParentProjectOneof : _parent_project
    ForkPoint *-- ForkPointRequestedParentIdOneof : _requested_parent_id
Loading

File-Level Changes

Change Details Files
Introduce client for global leaderboard search with sync/async entrypoints and corresponding request DTO.
  • Create search_global_leaderboard_entries_proto client module with sync and asyncio helpers that POST JSON to the global leaderboard search proto endpoint and return raw protobuf bytes via File.
  • Support X-Neptune-Client-Metadata header and standard error-handling/UnexpectedStatus behaviors aligned with existing API clients.
  • Expose the GlobalSearchParamsDTO model from the models package for consumer imports.
src/neptune_api/api/retrieval/search_global_leaderboard_entries_proto.py
src/neptune_api/models/global_search_params_dto.py
src/neptune_api/models/__init__.py
Define GlobalSearchParamsDTO request shape for global search, reusing existing pagination, query, and sorting DTOs.
  • Implement attrs-based GlobalSearchParamsDTO with experiment_leader flag plus pagination, query, and sorting fields, all optional and round-tripping via to_dict/from_dict.
  • Allow arbitrary additional properties for forward compatibility with server-side schema changes.
src/neptune_api/models/global_search_params_dto.py
Update protobuf-generated ingest common types to mark ForkPoint.parent_project as optional in both runtime and type stubs.
  • Regenerate protobuf_v3 and protobuf_v4plus common_pb2 modules to update serialized descriptor blobs and index metadata, reflecting ForkPoint.parent_project as a presence-tracked optional field.
  • Adjust corresponding .pyi stubs so ForkPoint.init accepts parent_project: str
None, and HasField/ClearField/WhichOneof now cover the _parent_project oneof case.
Integrate the new searchGlobalLeaderboardEntriesProto operation into OpenAPI-based codegen/docs.
  • Include searchGlobalLeaderboardEntriesProto operationId in redocly codegen filter for retrieval APIs so it is documented and client code is generated.
  • Update retrieval swagger definition to describe the new global leaderboard search proto endpoint used by the client.
codegen/redocly.yaml
codegen/swagger/retrieval.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pitercl pitercl force-pushed the pl/global-search branch 2 times, most recently from 6c5062a to 7ce3fbe Compare October 27, 2025 13:08
@pitercl pitercl changed the title Update API to include searchLGlobalEntriesProto chore: update API to include searchLGlobalEntriesProto Oct 27, 2025
@pitercl pitercl changed the title chore: update API to include searchLGlobalEntriesProto chore: update API to include searchGlobalLeaderboardEntriesProto Nov 24, 2025
@pitercl pitercl marked this pull request as ready for review November 25, 2025 09:33
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/neptune_api/api/retrieval/search_global_leaderboard_entries_proto.py:70` </location>
<code_context>
def _parse_response(
    *, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Any, File]]:
    try:
        if response.status_code == HTTPStatus.OK:
            response_200 = File(payload=BytesIO(response.content))

            return response_200
        if response.status_code == HTTPStatus.BAD_REQUEST:
            response_400 = cast(Any, None)
            return response_400
        if response.status_code == HTTPStatus.UNAUTHORIZED:
            response_401 = cast(Any, None)
            return response_401
        if response.status_code == HTTPStatus.FORBIDDEN:
            response_403 = cast(Any, None)
            return response_403
        if response.status_code == HTTPStatus.NOT_FOUND:
            response_404 = cast(Any, None)
            return response_404
        if response.status_code == HTTPStatus.REQUEST_TIMEOUT:
            response_408 = cast(Any, None)
            return response_408
        if response.status_code == HTTPStatus.CONFLICT:
            response_409 = cast(Any, None)
            return response_409
        if response.status_code == HTTPStatus.UNPROCESSABLE_ENTITY:
            response_422 = cast(Any, None)
            return response_422
        if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
            response_429 = cast(Any, None)
            return response_429
    except Exception as e:
        raise errors.UnableToParseResponse(e, response) from e

    if client.raise_on_unexpected_status:
        raise errors.UnexpectedStatus(response.status_code, response.content)
    else:
        return None

</code_context>

<issue_to_address>
**issue (code-quality):** Inline variable that is immediately returned [×5] ([`inline-immediately-returned-variable`](https://docs.sourcery.ai/Reference/Default-Rules/refactorings/inline-immediately-returned-variable/))
</issue_to_address>

### Comment 2
<location> `src/neptune_api/models/global_search_params_dto.py:75` </location>
<code_context>
    def to_dict(self) -> Dict[str, Any]:
        experiment_leader = self.experiment_leader

        pagination: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.pagination, Unset):
            pagination = self.pagination.to_dict()

        query: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.query, Unset):
            query = self.query.to_dict()

        sorting: Union[Unset, Dict[str, Any]] = UNSET
        if not isinstance(self.sorting, Unset):
            sorting = self.sorting.to_dict()

        field_dict: Dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if experiment_leader is not UNSET:
            field_dict["experimentLeader"] = experiment_leader
        if pagination is not UNSET:
            field_dict["pagination"] = pagination
        if query is not UNSET:
            field_dict["query"] = query
        if sorting is not UNSET:
            field_dict["sorting"] = sorting

        return field_dict

</code_context>

<issue_to_address>
**suggestion (code-quality):** Merge dictionary updates via the union operator ([`dict-assign-update-to-union`](https://docs.sourcery.ai/Reference/Default-Rules/suggestions/dict-assign-update-to-union/))

```suggestion
        field_dict |= self.additional_properties
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

) -> Optional[Union[Any, File]]:
try:
if response.status_code == HTTPStatus.OK:
response_200 = File(payload=BytesIO(response.content))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Inline variable that is immediately returned [×5] (inline-immediately-returned-variable)

sorting = self.sorting.to_dict()

field_dict: Dict[str, Any] = {}
field_dict.update(self.additional_properties)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Merge dictionary updates via the union operator (dict-assign-update-to-union)

Suggested change
field_dict.update(self.additional_properties)
field_dict |= self.additional_properties

@pitercl pitercl merged commit 71cf73b into main Nov 26, 2025
9 checks passed
@pitercl pitercl deleted the pl/global-search branch November 26, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants