Do not filter by fleet in filter_instances()#3674
Merged
Conversation
Motivation: - Simplify the implementation and improve the performance of the upcoming `<project>/<fleet>` syntax in the `fleets` property. Filtering by fleet in `filter_instance()` would require loading the project from the database for each fleet in order to support filtering by `<project>/<fleet>`. - Make the behavior of `dstack offer --fleet` consistent for idle instances and backend offers, by ignoring `--fleet` for both. At least as a temporary solution, until we support filtering backend offers by `--fleet`. Apart from `dstack offer`, there is no other impact of this change for end users. In all other cases when `filter_instances()` is called, filtering by fleet is actually redundant — either because the instances are already pre-filtered by `select_run_candidate_fleet_models_with_filters`, or because `profile.fleets` is guaranteed to be `None` (the case for autocreated fleets).
r4victor
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
performance of the upcoming
<project>/<fleet>syntax in the
fleetsproperty. Filtering byfleet in
filter_instances()would requireloading the project from the database for each
fleet in order to support filtering by
<project>/<fleet>(part of [Feature]: Cross-project SSH fleet sharing #3626).dstack offer --fleetconsistent for idle instances and backend
offers, by ignoring
--fleetfor both. At leastas a temporary solution, until we support
filtering backend offers by
--fleet(fixes [Bug]: Inconsistentdstack offer --fleet#3672).Apart from
dstack offer, there is no otherimpact of this change for end users. In all other
cases when
filter_instances()is called,filtering by fleet is actually redundant — either
because the instances are already pre-filtered by
select_run_candidate_fleet_models_with_filters,or because
profile.fleetsis guaranteed to beNone(the case for autocreated fleets).