Is there a way to rerun python_tests on failure? K...
# general
p
Is there a way to rerun python_tests on failure? Kind of like bazel's
flaky
tag.. not ideal, but there is currently a database test that only times out occasionally in pants that can't be figured out.. 😕
1
p
Oh! Fun!
Can that be on the underlying python_test target? Like instead of for all tests, do this test only.
Doesn't seem like it is a field on the python_test target 😕
Copy code
Unrecognized field `attempts_default=2` in target __. Valid fields for the target type `python_tests`: ['batch_compatibility_tag', 'dependencies', 'description', 'environment', 'extra_env_vars', 'interpreter_constraints', 'overrides', 'resolve', 'run_goal_use_sandbox', 'runtime_package_dependencies', 'skip_tests', 'sources', 'tags', 'timeout', 'xdist_concurrency']
c
unfortunately not. you can splice something together with pants tags, like
pants --tag="flaky" test --attempts-default=3 path/to/flaky.py
tag reference: https://www.pantsbuild.org/2.18/docs/using-pants/advanced-target-selection#tags-annotating-targets
p
❤️
Unfortunately, shared the workload that way isn't ideal. No worries, this is certainly better than nothing.. well until the test is figured out. Shouldn't be flaky
c
agreed. Implementing it at the goal level was pretty easy and had clear semantics, but implementing it per target is more complicated (impact the batching) and less clear semantics. For example, if 1 target in a batch fails, do we rerun the whole batch, or just the failed ones? Is this flake because of a problem between tests, so we should only rerun the failed tests; or is it a problem in the code and the only way to surface it is to rerun the whole batch?
Aliases might also make this more convenient: https://www.pantsbuild.org/2.18/reference/subsystems/cli#alias