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

Simplify BUILD file parsing #10298

Merged
merged 3 commits into from
Jul 9, 2020

Conversation

Eric-Arellano
Copy link
Contributor

We no longer need all the flexibility from the engine experiments. For the past few years, the only Struct we've ever had is a TargetAdaptor, and it doesn't refer to other Structs beyond weak references in the dependencies field.

Simplifying this code makes it easier for us to add new features like an ! ignore syntax to the dependencies field.

# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
[ci skip-rust-tests]
Comment on lines +170 to +180
include_patterns = set(
itertools.chain.from_iterable(
address_spec.make_glob_patterns(address_mapper) for address_spec in address_specs
)
)
snapshot = await Get(
Snapshot,
PathGlobs(
globs=(*include_patterns, *(f"!{p}" for p in address_mapper.build_ignore_patterns))
),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was inlined from _address_spec_to_globs, which was only being used here.

@@ -1,57 +1,47 @@
# Copyright 2015 Pants project contributors (see CONTRIBUTORS.md).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Summary of the changes:

  • Removed the JSON parser examples. Those were testing functionality that we don't use in production, like strong references to other structs. Replaced with some integration-style tests for BUILD file parsing.
  • Rewrote tests from unittest to Pytest style.
  • Added new tests for finding BuildFileAddress and for AddressesWithOrigins -> Addresses.

return HydratedStructs(tacs)


class AddressMapperTest(unittest.TestCase, SchedulerTestBase):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was testing things that are beyond the scope of mapper.py. The functionality is roughly covered by the new tests in build_files_test.py.

Copy link
Member

@stuhood stuhood left a comment

Choose a reason for hiding this comment

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

Thanks!



@dataclass(frozen=True)
class HydratedTargetAdaptor:
Copy link
Member

Choose a reason for hiding this comment

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

Is this intermediate class necessary anymore, or could we request TargetAdaptor directly now that that class is concrete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe not. Although I like it to distinguish between a raw TargetAdaptor vs. one that's been hydrated, e.g. the dependencies field being normalized.

Copy link
Member

@stuhood stuhood Jul 9, 2020

Choose a reason for hiding this comment

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

Well, it's a bit of misnomer now. "hydrated" used to mean "embedded addressables have been inlined/expanded" (the recursive stuff we used to do there). Now it's pure parsing, which isn't particularly heavy. Anywho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants