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

pants: disambiguate test file dependencies #5833

Merged
merged 2 commits into from
Dec 5, 2022

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Dec 3, 2022

Background

This is another part of introducing pants, as discussed in various TSC meetings.

Related PRs can be found in:

Overview of this PR

Pants uses dependency inference, which the docs describe as:

Pants analyzes your code's import statements to determine files' dependencies automatically. Dependency information is required for precise change detection and cache invalidation, but inference means that you don't need to declare dependencies manually (and hermetic execution guarantees that they are always accurate)!

However, sometimes that inference gets confused. For example, in several places our test files import tests.base, but we have multiple **/tests/base.py files, so pants doesn't know which one we're talking about, even though python itself understands exactly what we're talking about.

So, this PR resolves that ambiguity by explicitly defining dependencies in the BUILD files. In a few cases, we can add that dependency to the one file that needs it. But in other cases, lots of test files have the "ambiguous" import on tests.base or tests.unit.base. Adding the dep to each of those files would be painful to maintain, so I added it to all of the test files in the affected directories.

Aside: In each case, I left a comment about why the dep was "ambiguous". I hope that a future version of pants will give us some knobs to tell the inference system how to resolve dependencies it thinks are ambiguous instead of adding it explicitly to more files than necessary. Including "ambiguous" in the BUILD file comment will make it easier to grep and figure out where we can adjust things once pants includes a feature like that.

Relevant Pants documentation

@cognifloyd cognifloyd added this to the pants milestone Dec 3, 2022
@cognifloyd cognifloyd self-assigned this Dec 3, 2022
@pull-request-size pull-request-size bot added the size/M PR that changes 30-99 lines. Good size to review. label Dec 3, 2022
We do large sets of files because maintaining manual per-file mapping of
dependencies would be a lot of pointless work.

Hopefully a future version of pants will have features that make
disambiguation more precise, integrating better with dependency
inferrence. When that happens we can revert this commit in favor of
telling pants how to infer the ambiguous deps instead of hard-coding the
deps for a large set of files that might not need the dep.
@cognifloyd cognifloyd enabled auto-merge (squash) December 3, 2022 18:26
@cognifloyd
Copy link
Member Author

Note: This PR needs to be merged before I can add pylint. Otherwise, pants will run into these ambiguous deps whenever it runs pylint, and pylint will subsequently fail when pants doesn't add all of the required files/deps to the sandbox it runs pylint in.

@cognifloyd
Copy link
Member Author

For reference, here are the warnings this resolves:

13:31:38.83 [WARN] The target contrib/core/tests/test_action_sendmail.py imports `mailparser`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/core:reqs#mail-parser', 'st2tests/st2tests/fixtures/packs/core:reqs#mail-parser'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/core/tests/test_action_sendmail.py, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.85 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_data_flow.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_data_flow.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.86 [WARN] The target st2common/tests/unit/test_db_auth.py:tests imports `tests.unit.base.BaseDBModelCRUDTestCase`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_db_auth.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.89 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_error_handling.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_error_handling.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.90 [WARN] The target st2client/tests/unit/test_inquiry.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_inquiry.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.91 [WARN] The target st2client/tests/unit/test_auth.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_auth.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.95 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_policies.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_policies.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.95 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_with_items.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_with_items.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:38.98 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_pause_and_resume.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_pause_and_resume.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.01 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_functions_task.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_functions_task.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.02 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_inquiries.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_inquiries.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.04 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_delay.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_delay.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.04 [WARN] The target st2common/tests/unit/test_db_rbac.py:tests imports `tests.unit.base.BaseDBModelCRUDTestCase`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_db_rbac.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.04 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_functions_common.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_functions_common.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.05 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_context.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_context.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.06 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_cancel.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_cancel.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.07 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_basic.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_basic.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.11 [WARN] The target st2common/tests/unit/test_db_pack.py:tests imports `tests.unit.base.BaseDBModelCRUDTestCase`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_db_pack.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.20 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_notify.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_notify.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.28 [WARN] The target st2client/tests/unit/test_formatters.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_formatters.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.31 [WARN] The target contrib/runners/orquesta_runner/tests/unit/test_output_schema.py:tests imports `tests.unit.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/runners/orquesta_runner/tests/unit/test_output_schema.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.32 [WARN] The target st2client/tests/unit/test_client_executions.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_client_executions.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.32 [WARN] The target st2client/tests/unit/test_commands.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_commands.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.33 [WARN] The target st2client/tests/unit/test_commands.py:tests imports `tests.base.BaseCLITestCase`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_commands.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.34 [WARN] The target st2client/tests/unit/test_client.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_client.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.35 [WARN] The target st2client/tests/unit/test_action.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_action.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.36 [WARN] The target st2client/tests/unit/test_action_alias.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_action_alias.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.37 [WARN] The target st2common/tests/unit/test_queue_consumer.py:tests imports `tests.unit.base.FakeModelDB`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_queue_consumer.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.41 [WARN] The target st2client/tests/unit/test_execution_tail_command.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_execution_tail_command.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.41 [WARN] The target st2client/tests/unit/test_execution_tail_command.py:tests imports `tests.base.BaseCLITestCase`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_execution_tail_command.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.43 [WARN] The target st2auth/tests/unit/controllers/v1/test_sso.py:tests imports `tests.base.FunctionalTest`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2auth/tests/unit/controllers/v1/test_sso.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.49 [WARN] The target st2client/tests/unit/test_client_actions.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_client_actions.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.50 [WARN] The target st2tests/st2tests/fixtures/packs/core/tests/test_action_sendmail.py imports `mailparser`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/core:reqs#mail-parser', 'st2tests/st2tests/fixtures/packs/core:reqs#mail-parser'].

Please explicitly include the dependency you want in the `dependencies` field of st2tests/st2tests/fixtures/packs/core/tests/test_action_sendmail.py, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.55 [WARN] The target st2client/tests/unit/test_ssl.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_ssl.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.66 [WARN] The target st2client/tests/unit/test_workflow.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_workflow.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.68 [WARN] The target st2auth/tests/unit/controllers/v1/test_token.py:tests imports `tests.base.FunctionalTest`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2auth/tests/unit/controllers/v1/test_token.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.68 [WARN] The target st2client/tests/unit/test_shell.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_shell.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.69 [WARN] The target st2client/tests/unit/test_keyvalue.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_keyvalue.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.70 [WARN] The target st2client/tests/unit/test_models.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_models.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.80 [WARN] The target contrib/packs/tests/test_action_download.py imports `tests.fixtures.FIXTURES_DIR`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/packs/tests/fixtures/__init__.py', 'st2client/tests/fixtures/__init__.py', 'st2common/tests/fixtures/__init__.py'].

Please explicitly include the dependency you want in the `dependencies` field of contrib/packs/tests/test_action_download.py, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.86 [WARN] The target st2common/tests/unit/test_persistence_change_revision.py:tests imports `tests.unit.base.ChangeRevFakeModel`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_persistence_change_revision.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.86 [WARN] The target st2common/tests/unit/test_persistence_change_revision.py:tests imports `tests.unit.base.ChangeRevFakeModelDB`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_persistence_change_revision.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.90 [WARN] The target st2common/tests/unit/test_persistence.py:tests imports `tests.unit.base.FakeModel`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_persistence.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:39.90 [WARN] The target st2common/tests/unit/test_persistence.py:tests imports `tests.unit.base.FakeModelDB`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['contrib/runners/orquesta_runner/tests/unit/base.py', 'st2common/tests/unit/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2common/tests/unit/test_persistence.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.
13:31:40.34 [WARN] The target st2client/tests/unit/test_trace_commands.py:tests imports `tests.base`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['st2auth/tests/base.py', 'st2client/tests/base.py'].

Please explicitly include the dependency you want in the `dependencies` field of st2client/tests/unit/test_trace_commands.py:tests, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies.

Copy link

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

However, sometimes that inference gets confused. For example, in several places our test files import tests.base, but we have multiple **/tests/base.py files, so pants doesn't know which one we're talking about, even though python itself understands exactly what we're talking about.

FYI this is because Pants lets you import from anywhere in your monorepo, which is a key benefit of monorepo. Whereas often when running Python directly, you only run in a subproject of your repo. So, Pants creates a global "module mapping" of e.g. the module to tests.base to ("dir1/tests/base.py, "dir2/tests/base.py")`

*In Pants 2.16, we added visibility support, where you can ban certain files from importing others.

Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

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

LGTM

@cognifloyd cognifloyd requested a review from a team December 5, 2022 15:57
Copy link
Member

@rush-skills rush-skills left a comment

Choose a reason for hiding this comment

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

LGTM

@cognifloyd cognifloyd merged commit abb7579 into master Dec 5, 2022
@cognifloyd cognifloyd deleted the pants-disambiguate-deps branch December 5, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pantsbuild size/M PR that changes 30-99 lines. Good size to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants