Skip to content

Commit

Permalink
Upgrade bazel version to 4.2.1 (#18996)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjoliver authored and simon-mo committed Oct 20, 2021
1 parent ea03877 commit fe64f3d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
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

0 comments on commit fe64f3d

Please sign in to comment.