-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
[internal] Refactor JVM artifact mapping code #13905
Conversation
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
"""Maps JVM unversioned coordinates to target `Address`es and declared packages.""" | ||
|
||
artifacts: FrozenDict[UnversionedCoordinate, tuple[tuple[Address, ...], tuple[str, ...]]] | ||
|
||
def addresses_for_coordinates( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
@@ -156,42 +142,57 @@ def find_all_jvm_provides_fields(targets: AllTargets) -> AllJvmTypeProvidingTarg | |||
class ThirdPartyPackageToArtifactMapping: | |||
mapping_root: FrozenTrieNode | |||
|
|||
def addresses_for_symbol(self, symbol: str) -> FrozenOrderedSet[Address]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply converted into a method rather than free function. Only line 147 changed
group = tgt[JvmArtifactGroupField].value | ||
if not group: | ||
raise ValueError( | ||
f"The {JvmArtifactGroupField.alias} field of target {tgt.address} must be set." | ||
) | ||
|
||
artifact = tgt[JvmArtifactArtifactField].value | ||
if not artifact: | ||
raise ValueError( | ||
f"The {JvmArtifactArtifactField.alias} field of target {tgt.address} must be set." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Target API already validates that these are set.
# TODO: error if no resolves for the target. Wait to change until we automatically set a | ||
# default resolve. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we a) decided to not have [jvm].default_compatible_resolves
in #13902, and b) we plan to set a default for default_resolve
, this won't be able to happen soon. There will always be a resolve defined.
@@ -35,3 +42,35 @@ def resolves(self) -> dict[str, str]: | |||
@property | |||
def default_resolve(self) -> str | None: | |||
return cast(str, self.options.default_resolve) | |||
|
|||
def resolves_for_target(self, target: Target) -> tuple[str, ...]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is checking that all resolves are recognized, which we did not do before.
@@ -18,14 +20,19 @@ def register_options(cls, register): | |||
register( | |||
"--resolves", | |||
type=dict, | |||
# TODO: Default this to something like {'jvm-default': '3rdparty/jvm/default.lockfile'}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Four different refactors as prework for #13621.