Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /api/instances/list #2199

Merged
merged 1 commit into from
Jan 20, 2025
Merged

Add /api/instances/list #2199

merged 1 commit into from
Jan 20, 2025

Conversation

jvstme
Copy link
Collaborator

@jvstme jvstme commented Jan 20, 2025

Add an API method for listing instances with filtering and pagination. This method will be used in the new Instances page in the UI. It is similar to the deprecated /api/pools/list_instances method, except it allows filtering by fleet and not by pool.

Also add the fleet_id and fleet_name fields to the instance model so that the Instances page in the UI can display fleet names and provide links to fleet details.

Part of #2133

Add an API method for listing instances with
filtering and pagination. This method will be used
in the new Instances page in the UI. It is similar
to the deprecated `/api/pools/list_instances`
method, except it allows filtering by fleet and
not by pool.

Also add the `fleet_id` and `fleet_name` fields to
the instance model so that the Instances page in
the UI can display fleet names and provide links
to fleet details.
@jvstme jvstme requested a review from r4victor January 20, 2025 00:34
Comment on lines +570 to +571
project_names: Optional[Container[str]],
fleet_ids: Optional[Iterable[uuid.UUID]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if there is a good reason to use abstract types if lists are sufficient. Depending on abstract types puts extra limits on the implementation (e.g. may need to convert to list). I'd not use abstract types unless there is a specific reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Conversely, depending on specific types puts extra limits on the caller, e.g. the caller may need to convert to list when in fact a set or a generator could work just as well.

It's hard to say which is more likely: changing the implementation in such a way that the abstract types are no longer sufficient, or adding new callers that prefer to use other specific types. I'd bet on the latter.

Copy link
Collaborator

@r4victor r4victor Jan 20, 2025

Choose a reason for hiding this comment

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

Conversely, depending on specific types puts extra limits on the caller,

Agree, but in this specific case we talk about a service function that's written specifically for a router, so a router will likely be the only client.

Don't you think that following the approach you suggest with defaulting to abstract types we'll end up with lots of inconsistencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we talk about a service function that's written specifically for a router, so a router will likely be the only client

It is also likely that Container and Iterable will be enough for the purposes of this function. And who knows, we may find other uses for this function as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

following the approach you suggest with defaulting to abstract types we'll end up with lots of inconsistencies

Do you mean actual type inconsistencies, when the declared type doesn't match the runtime type? This should be prevented by a type checker.

Copy link
Collaborator

@r4victor r4victor Jan 20, 2025

Choose a reason for hiding this comment

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

I don't mean type correctness. I mean some functions will accept concrete types, some abstract types, and some a mixture of both. This will likely happen if you default to use abstract / generic types from now on.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Then I don't think it's an issue. We will just trust the function's signature when calling it - if it expects a list, we pass a list; if expects an iterable, we pass any iterable.

if you default to use abstract types from now on

I've been using them all the time actually) And I see them in commits from other teammates as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I don't insist on changing the types

@jvstme jvstme merged commit bc5f0ac into master Jan 20, 2025
24 checks passed
@jvstme jvstme deleted the issue_2133_add_instances_api branch January 20, 2025 13:11
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.

2 participants