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

Add debug goals to python #17057

Merged
merged 43 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
86935dd
goal is resolving
lilatomic Sep 28, 2022
8c8019e
working version
lilatomic Sep 28, 2022
fb22a1e
use correct fieldset to properly instantiate iterpreter reqs
lilatomic Sep 28, 2022
ff781d0
refactor marshalling ParsePythonDependenciesRequest
lilatomic Sep 29, 2022
cdac64b
properly use rules
lilatomic Sep 29, 2022
f1deda7
better vectorisation
lilatomic Sep 30, 2022
29d86b0
pull parsing inference results to helper rule
lilatomic Sep 30, 2022
69b5c2b
wire resolving parse into source analysis dump
lilatomic Sep 30, 2022
1f87e1d
use peek's json encoder
lilatomic Sep 30, 2022
acd07c4
extract helper rule for resolving possible owners
lilatomic Sep 30, 2022
6b62b23
wire possible other ownership into analysis
lilatomic Sep 30, 2022
260bb7f
defaultdict isn't serialisable by asdict
lilatomic Sep 30, 2022
cb3071c
add stage to determine importownerstatus
lilatomic Oct 1, 2022
44bdc28
honour multiple unambiguous owners
lilatomic Oct 1, 2022
be5f07f
separate collection from reduction of imports information
lilatomic Oct 1, 2022
6cde50a
push gathering one level down
lilatomic Oct 1, 2022
22965f6
wire in raw resolve results to analysis
lilatomic Oct 1, 2022
0e8910d
add address to output
lilatomic Oct 1, 2022
46f3df1
comments
lilatomic Oct 1, 2022
5caa77c
evaporate ExecParseDepsRequest
lilatomic Oct 1, 2022
f84667c
evaporate ExecParseDepsResponse
lilatomic Oct 1, 2022
8561c9f
comments
lilatomic Oct 2, 2022
d8c72b7
have asset resolution return ImportResolveResult
lilatomic Oct 2, 2022
ac227da
mark assets with inferred targets
lilatomic Oct 2, 2022
4ba01fb
mark unambiguous assets as such
lilatomic Oct 2, 2022
a1fc482
flag ambiguous assets as such
lilatomic Oct 2, 2022
f00ac69
wire assets into collected output
lilatomic Oct 2, 2022
00c41ef
add option for flavour of analysis requested
lilatomic Oct 2, 2022
704e4ea
test _get_imports_info
lilatomic Oct 10, 2022
9d9dc0d
refactor test cases to all use helper
lilatomic Oct 10, 2022
9755415
tests for finding other imports
lilatomic Oct 12, 2022
94a4eba
add smoke test for debug goal
lilatomic Oct 12, 2022
b322e72
freeze dataclass
lilatomic Oct 22, 2022
1fefb7e
simplify control flow
lilatomic Oct 22, 2022
800bee2
extract rule finding owners for single import
lilatomic Oct 22, 2022
dff9184
rebuild as rule_helper
lilatomic Oct 22, 2022
a6561af
rebuild as rule_helper
lilatomic Oct 22, 2022
b345000
remove now-redundant check
lilatomic Oct 26, 2022
490974b
fix: test has proper precondition
lilatomic Oct 26, 2022
d30a883
lint: proper name, remove print
lilatomic Oct 26, 2022
bbbc2de
move to experimental
lilatomic Oct 29, 2022
ece4589
better help text
lilatomic Oct 29, 2022
8e44026
include python imports rules in debug rules backend
lilatomic Nov 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/python/pants/backend/experimental/python/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from pants.backend.codegen import export_codegen_goal
from pants.backend.python.goals import publish
from pants.backend.python.goals import debug_goals, publish
from pants.backend.python.subsystems import setuptools_scm, twine
from pants.backend.python.target_types import VCSVersion
from pants.backend.python.util_rules import pex, vcs_versioning
Expand All @@ -16,6 +16,7 @@ def rules():
*setuptools_scm.rules(),
*export_codegen_goal.rules(),
*twine.rules(),
*debug_goals.rules(),
)


Expand Down
13 changes: 12 additions & 1 deletion src/python/pants/backend/project_info/peek.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pants.engine.target import (
Dependencies,
DependenciesRequest,
Field,
HydratedSources,
HydrateSourcesRequest,
SourcesField,
Expand Down Expand Up @@ -89,12 +90,22 @@ class _PeekJsonEncoder(json.JSONEncoder):

def default(self, o):
"""Return a serializable object for o."""
if isinstance(o, str): # early exit prevents strings from being treated as sequences
return o
if o is None:
return o
if is_dataclass(o):
return asdict(o)
if isinstance(o, collections.abc.Mapping):
return dict(o)
if isinstance(o, collections.abc.Sequence):
if (
isinstance(o, collections.abc.Sequence)
or isinstance(o, set)
or isinstance(o, collections.abc.Set)
):
return list(o)
if isinstance(o, Field):
return self.default(o.value)
try:
return super().default(o)
except TypeError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@ def add_modules(modules: Iterable[str], *, type_stub: bool = False) -> None:
class PythonModuleOwners:
"""The target(s) that own a Python module.

If >1 targets own the same module, and they're implementations (vs .pyi type stubs), they will
be put into `ambiguous` instead of `unambiguous`. `unambiguous` should never be > 2.
Up to 2 targets can unambiguously own the same module, if one is an implementation and the other
is a .pyi type stub. It is ambiguous for >1 implementation target to own the same module, and
those targets will be put into `ambiguous` instead of `unambiguous`. Therefore, `unambiguous`
should never be >2; and only 1 of `unambiguous` and `ambiguous` should have targets.
"""

unambiguous: tuple[Address, ...]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

import json
from dataclasses import dataclass

Expand Down
Loading