Skip to content

[WIP] --query pipelining#7356

Closed
cosmicexplorer wants to merge 2 commits intopantsbuild:mainfrom
cosmicexplorer:query-pipelining
Closed

[WIP] --query pipelining#7356
cosmicexplorer wants to merge 2 commits intopantsbuild:mainfrom
cosmicexplorer:query-pipelining

Conversation

@cosmicexplorer
Copy link
Copy Markdown
Contributor

@cosmicexplorer cosmicexplorer commented Mar 11, 2019

WIP until #7350 is merged. The diff against #7350 is at https://github.com/cosmicexplorer/pants/compare/query-option-for-unifying-target-selection...cosmicexplorer:query-pipelining?expand=1.

Problem

It would be neat to unify our separate target selection mechanisms (e.g. --owner-of, filter) under a single interface. This discussion began in #6501. See #7350 for the first diff in the series described by #7346.

We can make --query a list option and process each element as a filter, similar to jq (described in #6501 (comment)). This PR implements that.

Solution

  • Make all target root selection into v2 rules.
  • Create QueryPipeline and the process_query_pipeline rule to process BuildFileAddresses after applying each query expression as a filter using the output of the previous expression as input.
    • The initial input to the query pipeline is determined by one of --owner-of, --changed-*, or literal target specs, just as we currently do.
    • There are no filters yet (beyond owner-of, changes-since, changes-for-diffspec, and noop), and not enough testing at all.

Result

--query expressions can now be pipelined for more complex queries.

diffspec=None,
include_dependees=changes_since.include_dependees,
# TODO: is this what we want? see the --changed-fast option!
# TODO(#7346): parse --query expressions using the python ast module to support keyword args!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or starlark...?!

hydrate_noop,
noop_results,
# ???/intersection
RootRule(IntersectionOperands),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a root for testing purposes? If so, could add the root in the test instead...

"""
:param Options options: An `Options` instance to use.
:param session: The Scheduler session
# TODO: `symbol_table` is unused!!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed in master.

else:
specs = literal_specs

# TODO: this somehow deadlocks if you yield Specs instead of InitialSpecs -- FIX THIS!!!
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm... deadlocks or livelocks? What does the rule graph look like?



@rule(ScmResult, [Select(ScmRequest)])
def try_get_scm(scm_request):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that leaving the wrapped SCM as a parameter is a bit cleaner, for the reason mentioned on #7350.

the --query option, the testing for that functionality should be moved into this file (or into
unit testing), and the separate option or goal should eventually be deprecated.
"""
# TODO(#7346): test changes-since or changes-for-diffspec queries! It's currently difficult to set
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 4 times, most recently from ba6e9e6 to 52b8fd7 Compare November 11, 2019 15:33
@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 2 times, most recently from 51fe6ed to 030bb1b Compare November 27, 2019 10:37
@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 7 times, most recently from f033af2 to 04fe733 Compare February 11, 2020 04:37
@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 2 times, most recently from 8da6be8 to 955df30 Compare March 24, 2020 09:08
@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 2 times, most recently from e1fea47 to 1d0085d Compare June 30, 2020 21:21
use the ast module to parse query expressions!!

# Rust tests will be skipped. Delete if not intended.
[ci skip-rust-tests]
@cosmicexplorer cosmicexplorer force-pushed the query-pipelining branch 2 times, most recently from 2d50ea1 to df4212b Compare July 1, 2020 00:36
(by making sure that the transitive hydrated targets are all within the previous range of addresses for filters)

turn the Changed subsystem into v2 rules for target root calculation

fix --owner-of

add --query option to cover owner-of, changes-since, etc at once

make an integration test and make it pass

clean up

convert QueryComponentMixin -> just QueryComponent

actually add integration test!

tag the query integration test target as such, and use text_type()

move query.py up to src/python/pants/engine because it's not legacy

make getting changed files uncacheable!

fix test to avoid trailing newlines

...add query.py

move --query integration testing out of engine/legacy/

make things work after rebase (the test passes now!)

apply UnionRule to QueryComponent!

get to the point where we start wanting to return union values

add QueryPipeline!

fixes after rebase (broken)

remove legacy query

save point

IT WORKS!!!

ok, pipelining works again

add new query operators...unreally easily

show specific object on hash error

return just the initial specs

actually make query pipelining work (by making sure that the transitive hydrated targets are all within the previous range of addresses for filters)

make target selection conjunctions work!!

fix query integration test registration

add minimize() query operation!!

fixes after rebase

[ci skip-jvm-tests]  # No JVM changes made.

[ci skip-rust-tests]
Base automatically changed from master to main March 19, 2021 19:20
@Eric-Arellano
Copy link
Copy Markdown
Contributor

Closing as stale, which we're doing for all changes that haven't been touched in 1+ years to simplify project management.

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.

3 participants