breezy-cricket-45254
07/29/2024, 7:56 AMpants export
to use it in Pycharm but I'm not using lockfiles, instead I use ambiguity_resolution = "by_source_root"
I'm not sure if this option conflicts with having lockfiles, I tried to do it but with no success
Using lockfiles on its own works great and allows me to export virtualenv-s but it makes everything so much more complex
It makes me declare so many things that are automatically inferred when using ambiguity_resolution = "by_source_root"
Is there a way to create a virtualenv according to a target instead of resolve?
Or maybe is there a way to combine the 2 methods?
Let me know if you want me to supply a detailed examplehappy-kitchen-89482
07/29/2024, 7:08 PMhappy-kitchen-89482
07/29/2024, 7:08 PMhappy-kitchen-89482
07/29/2024, 7:09 PMbreezy-cricket-45254
07/30/2024, 7:39 AMbreezy-cricket-45254
07/30/2024, 7:42 AMsteep-eve-20716
07/30/2024, 2:20 PMbreezy-cricket-45254
07/30/2024, 2:53 PMservice -> library
# service/pyproject.toml
[tool.poetry.dependencies]
requests = "2.20.0"
# library/pyproject.toml
[tool.poetry.dependencies]
requests = ">=2.20,<2.33"
because this does work for mesteep-eve-20716
07/30/2024, 3:02 PMbreezy-cricket-45254
07/30/2024, 3:05 PM18:04:18.65 [INFO] Completed: Building 3 requirements for app_1.pex from the python/apps/app_group_1/app_1/lock.json resolve: numpy==1.21.1, requests<2.33,>=2.20, requests==2.20.0
Hello, app_1!
requests version: 2.20.0
python 3.7.17 (default, Jul 21 2024, 16:26:57)
[Clang 15.0.0 (clang-1500.3.9.4)]
numpy version: 1.21.1
requests version: 2.20.0
breezy-cricket-45254
07/30/2024, 3:06 PMsteep-eve-20716
07/30/2024, 3:08 PMbreezy-cricket-45254
07/30/2024, 3:09 PMbreezy-cricket-45254
07/30/2024, 3:58 PMsteep-eve-20716
07/30/2024, 4:47 PMapp_1
and app_2
.
β¦ That causes unit tests to break, because lib2@resolve=app_1
can't find lib3
since lib3 is only in lib3@resolve=app_2
β¦ this is an easy fix, but it shows how difficult/complex it is working with resolves, as opposed to the intuitive config of poetry
β’ Unit tests run per resolve
β¦ Our core "common" library has unit tests which take 10 mins. Its used in 24 services πsteep-eve-20716
07/30/2024, 4:47 PMbreezy-cricket-45254
07/30/2024, 4:55 PMhappy-psychiatrist-90774
07/30/2024, 6:12 PMsteep-eve-20716
07/30/2024, 6:12 PMhappy-psychiatrist-90774
07/30/2024, 6:13 PMsteep-eve-20716
07/30/2024, 6:16 PMpants test lib/::
run tests for all resolves that use the libraryhappy-psychiatrist-90774
07/30/2024, 6:18 PM__defaults__(all=dict(resolve=parametrize("libA", "libB", "service1", "service2")))
steep-eve-20716
07/30/2024, 6:20 PMhappy-psychiatrist-90774
07/30/2024, 6:21 PMsteep-eve-20716
07/31/2024, 1:03 PMbreezy-cricket-45254
07/31/2024, 1:29 PMhappy-kitchen-89482
07/31/2024, 2:02 PMhappy-kitchen-89482
07/31/2024, 2:03 PMhappy-kitchen-89482
07/31/2024, 2:03 PMsteep-eve-20716
07/31/2024, 4:17 PMpants test :: --filter-target-resolve=app1
? I don't see any indication here
a. Use-case here is that our libraries take 10+ mins to test, so I would like to just pick a single resolve and test against that
b. Maybe extending the current filters syntax? like --filter-target-type=python_tests(resolve=="app1", interpreter_constraints=="3.10.*")
c. Or maybe this should be (or already is) in target expansion? i.e. pants test libs::@resolve=app1
?
2. [Feature Request] Manually adding libraries to resolves is error-prone
a. "pushing" targets to a resolve means a library needs to know everywhere its consumed by, which breaks the typical development workflow.
b. An amazing feature would be if pants could automatically add transitive targets to resolves
3. [Feature Request] Configure resolves/lockfiles more granularly
a. Some subdirectories don't need resolves at all, and for some resolves I would still prefer the "wing it" dependency resolution
b. This is a broader request and is already documented, but just noting it heresteep-eve-20716
07/31/2024, 4:27 PM**parametrize('app_1', resolve='app_1', tags=["app1_resolve"]),
then in theory I could filter by tags...steep-eve-20716
07/31/2024, 6:24 PMsteep-eve-20716
08/03/2024, 5:34 AMsteep-eve-20716
08/03/2024, 5:52 AM[mypy].config
per directory, OR update config_discovery
logic to search within the source_root treesteep-eve-20716
08/16/2024, 8:06 PMdef python_module(name: str, resolves: set[str] = None, **kwargs):
all_defaults: dict[str, str | list | dict] = {"tags": [name]}
target_defaults: dict[str, dict] = {"python_sources": {}, "python_tests": {}}
# If a module belongs to multiple resolves..
if resolves:
# Then for each resolve in the list...
for r in resolves:
# Check if the resolve is for this specific module
is_resolve_owner = r == name
# Default to skip all checks for all resolves except the owning resolve
python_defaults = {
"skip_mypy": not is_resolve_owner,
"skip_bandit": not is_resolve_owner,
"skip_black": not is_resolve_owner,
"skip_docformatter": not is_resolve_owner,
"skip_flake8": not is_resolve_owner,
"skip_isort": not is_resolve_owner,
"skip_mypy": not is_resolve_owner,
}
# Add python_sources to the resolve, and skip checks for all resolves except the owning resolve
# i.e. only run mypy for common/file.py@resolve=common and not common/file.py@resolve=activity_logger
target_defaults["python_sources"].update(**parametrize(r, resolve=r, **python_defaults))
# Add python_tests to the resolve, and skip tests for all resolves except the owning resolve
# i.e. only run tests for common/file_test.py@resolve=common and not common/file_test.py@resolve=activity_logger
target_defaults["python_tests"].update(
**parametrize(r, resolve=r, skip_tests=(not is_resolve_owner), **python_defaults)
)
# Default all other targets to use resolves
all_defaults.update(**parametrize(r, resolve=r))
else:
all_defaults["resolve"] = name
# Update all_defaults with kwargs
all_defaults.update(kwargs)
__defaults__(target_defaults, all=all_defaults, ignore_unknown_fields=True)
steep-eve-20716
08/16/2024, 11:18 PMbreezy-cricket-45254
08/18/2024, 9:25 AM