Skip to content

Add a new option --fallback-sampling-target so users can specify different ratio with --target#1352

Merged
takanabe merged 4 commits into
mainfrom
fallback-sampling-target
Jul 7, 2026
Merged

Add a new option --fallback-sampling-target so users can specify different ratio with --target#1352
takanabe merged 4 commits into
mainfrom
fallback-sampling-target

Conversation

@takanabe

@takanabe takanabe commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

I noticed that --fallback-mode=random-sample can be used without --target option technically. In that case, we don’t know the how many (ratio) we choose tests from all tests. Relevant code is subset.py

To overcome the situation, I considered several options below:

Option1: Add a new option --fallback-sampling-target so users can specify different ratio with --target

Option2: Raise error when --target is not specified with random-sample -> --fallback-mode=random-sample must use with --target

Option3: Return 50% of tests as subset when --target is not specified

We chose the option 1 to specify the target of random sampling percentage when using fallback mode = random-sample

takanabe added 3 commits July 6, 2026 16:57
Without this, mypy cannot prove that execution stops after the call,
causing a false positive on the unconditional float(self.fallback_sampling_target)
in _fallback_result.
Mypy cannot narrow instance attributes across method calls, so the
assert gives _fallback_result the local type narrowing it needs.
@takanabe
takanabe requested a review from Konboi July 7, 2026 00:53

@Konboi Konboi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I left comments however not to block your task, I'll approve this PR

@@ -1,5 +1,6 @@
# TODO: add cli-specific custom exceptions
import sys
from typing import NoReturn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't know 'NoReturn`

"(no duration estimates are available in this path).",
)] = FallbackMode.RUN_ALL,
fallback_sampling_target: Annotated[Percentage | None, typer.Option(
"--fallback-sampling-target",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The --random-sample option is a hidden option however, this --fallback-sampling-target option isn't a hidden option.

Is it intentionally?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh, good catch! I fixed with 6f555ef

@takanabe
takanabe merged commit 6ae1b3a into main Jul 7, 2026
3 checks passed
@takanabe
takanabe deleted the fallback-sampling-target branch July 7, 2026 19:36
@github-actions github-actions Bot mentioned this pull request Jul 7, 2026
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