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

Upgrade bazel version to 4.2.1 #18996

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
42 changes: 26 additions & 16 deletions ci/travis/bazel.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,45 @@ def info(self, *args):
return result

def aquery(self, *args):
lines = self._call("aquery", "--output=textproto", *args).splitlines()
return textproto_parse(lines, self.encoding, json.JSONEncoder())
out = self._call("aquery", "--output=jsonproto", *args)
return json.loads(out.decode(self.encoding))


def parse_aquery_shell_calls(aquery_results):
"""Extracts and yields the command lines representing the genrule() rules
from Bazel aquery results.
"""
for (key, val) in aquery_results:
if key == "actions":
[mnemonic] = [pair[1] for pair in val if pair[0] == "mnemonic"]
if mnemonic == "Genrule":
yield [pair[1] for pair in val if pair[0] == "arguments"]
for action in aquery_results["actions"]:
if action["mnemonic"] != "Genrule":
continue
yield action["arguments"]


def parse_aquery_output_artifacts(aquery_results):
"""Extracts and yields the file paths representing the output artifact
from the provided Bazel aquery results.

To understand the output of aquery command in textproto format, try:
bazel aquery --include_artifacts=true --output=jsonproto \
'mnemonic("Genrule", deps(//:*))'
"""
fragments = {}
for fragment in aquery_results["pathFragments"]:
fragments[fragment["id"]] = fragment

artifacts = {}
for (key, val) in aquery_results:
if key == "artifacts":
[artifact_id] = [pair[1] for pair in val if pair[0] == "id"]
[exec_path] = [pair[1] for pair in val if pair[0] == "exec_path"]
artifacts[artifact_id] = exec_path
elif key == "actions":
output_ids = [pair[1] for pair in val if pair[0] == "output_ids"]
for output_id in output_ids:
yield artifacts[output_id]
for artifact in aquery_results["artifacts"]:
artifacts[artifact["id"]] = artifact

def _path(fragment_id):
fragment = fragments[fragment_id]
parent = _path(fragment["parentId"]) if "parentId" in fragment else []
return parent + [fragment["label"]]

for action in aquery_results["actions"]:
for output_id in action["outputIds"]:
path = os.path.join(*_path(artifacts[output_id]["pathFragmentId"]))
yield path


def textproto2json(infile, outfile):
Expand Down
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)

SUPPORTED_PYTHONS = [(3, 6), (3, 7), (3, 8), (3, 9)]
SUPPORTED_BAZEL = (3, 4, 1)
SUPPORTED_BAZEL = (4, 2, 1)

ROOT_DIR = os.path.dirname(__file__)
BUILD_JAVA = os.getenv("RAY_INSTALL_JAVA") == "1"
Expand Down