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

[Bug]: py_test does not accept the same resolutions as py_binary #466

Open
njlr opened this issue Dec 5, 2024 · 1 comment · May be fixed by #487
Open

[Bug]: py_test does not accept the same resolutions as py_binary #466

njlr opened this issue Dec 5, 2024 · 1 comment · May be fixed by #487
Labels
bug Something isn't working

Comments

@njlr
Copy link

njlr commented Dec 5, 2024

What happened?

Trying to use virtual_deps works with py_binary but not with py_test.

It complains that the type of resolutions is wrong.

Version

Development (host) and target OS/architectures: Linux

Output of bazel --version:

bazel 6.2.0

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

http_archive(
  name = "aspect_rules_py",
  sha256 = "2ce48e0f3eaaf73204b623f99f23d45690b862a994b5b3c2464a2e361b0fc4ae",
  strip_prefix = "rules_py-1.0.0",
  url = "https://github.com/aspect-build/rules_py/releases/download/v1.0.0/rules_py-v1.0.0.tar.gz",
)

Language(s) and/or frameworks involved:
Python

How to reproduce

Create a py_test that uses resolutions like so:

# ...

resolutions = resolutions.from_requirements(all_whl_requirements_by_package, requirement)

py_test(
  name = "py_test_tests",
  srcs = glob([
    "tests/**/*.py",
  ]) + [
    ":__test__.py"
  ],
  main = ":__test__.py",
  package_collisions = "error",
  resolutions = resolutions,
  python_version = "3.9.16",
  size = "small",
)

Any other information?

No response

@njlr njlr added the bug Something isn't working label Dec 5, 2024
@njlr
Copy link
Author

njlr commented Dec 19, 2024

As a work-around:

r = resolutions.from_requirements({
  "boto3": None,
  "torch": None,
  # etc...
}, requirement).to_label_keyed_dict()

py_test(
  name = "py_test_tests",
  srcs = glob([
    "tests/**/*.py",
  ]) + [
    ":__test__.py"
  ],
  main = ":__test__.py",
  package_collisions = "error",
  resolutions = r,
  python_version = "3.9.16",
  size = "small",
)

@njlr njlr linked a pull request Dec 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant