Repository navigation
Use separate Bazel invocation for TF integration binaries - #4836
Conversation
b8f368e to
93ce1c8
Compare
| process = subprocess.run(["bazel", "info", "bazel-bin"], | ||
| cwd=TF_INTEGRATIONS_DIR, | ||
| check=True, | ||
| capture_output=True, | ||
| universal_newlines=True) | ||
| if len(process.stdout.splitlines()) != 1: | ||
| raise RuntimeError( | ||
| f"Unexpected output from `bazel info bazel-bin`:\n{process.stdout}") | ||
| bazel_bin_dir = process.stdout.strip() | ||
| if not os.path.isdir(bazel_bin_dir): | ||
| raise RuntimeError( | ||
| f"`bazel info bazel-bin` '{bazel_bin_dir}' is not a directory") | ||
|
|
||
| return bazel_bin_dir |
There was a problem hiding this comment.
Can you document this (either through variable naming or comments) a bit more?
- I'm not sure why
bazel_build_tf_binary(target)is returning a directory path processcould be renamed toinfo_processor something similarly descriptive, considering there is anothersubprocess.run()call in this function that does something different
You could also split this into two functions - one for bazel build and one for bazel info bazel-bin
There was a problem hiding this comment.
Yeah you're right this is not great. I needed to call it always in the same place and from the same working directory so I merged them into one function. I'll rework it
There was a problem hiding this comment.
Ok I made the function just return the path to the binary it just built, which seems like a much more reasonable thing for it to do. Of course, this totally reasonable thing is not well supported in Bazel, but 🙄
| "${BAZEL_CMD[@]?}" build --config=generic_clang //iree_tf_compiler:all | ||
| popd | ||
|
|
||
| CMAKE_BUILD_DIR="$HOME/iree/build/tf" |
There was a problem hiding this comment.
Any particular reason to use this path instead of ../iree-build or ../iree-build-tf (just thinking about being consistent with some of our docs and other scripts)
There was a problem hiding this comment.
Yes. This is running in a docker container, so only mounted paths are writeable. As set up, we mount the directory in which IREE is checked out and the home directory, but not the parent of the directory in which IREE is checked out. See #4195
(as a side note, I hate sticking build directories as siblings to source directories)
There was a problem hiding this comment.
(technically we don't mount the real home directory, we create a fake one so it's also mounted on the local_ssd for fast IO, see https://github.com/google/iree/blob/main/build_tools/kokoro/gcp_ubuntu/docker_common.sh)
| @@ -0,0 +1,81 @@ | |||
| # Getting Started with IREE TensorFlow Integrations | |||
There was a problem hiding this comment.
Eh, really not a fan of there being even more "getting started" docs... we should really differentiate more between developer docs and user docs, and anything involving building from source is pretty developer-oriented :P
What concerns me in particular about this document (where it is located and how it is titled) is that users coming from TensorFlow Python should absolutely not be following this guide - they should be using the pip packages.
There was a problem hiding this comment.
The contents of the doc are great though :) ... just concerned with the direction the "getting started" docs are taking.
There was a problem hiding this comment.
I welcome anyone writing docs on how to do this 😛 This is the only way I know how to do it. Note that I do have a section for getting the binaries from the pip packages. All our getting started docs are about building from source. Until quite recently that was the only thing to get started on. But in particular @ewconnell was trying to actually use this stuff and the current documentation is super out of date, so I thought I would try to at least not make that worse with this change.
There was a problem hiding this comment.
(and because tone is hard to convey, I don't disagree with you here). I think the addition of this doc makes things at least better documented, so we should keep it. The current docs are just...wrong AFAICT
There was a problem hiding this comment.
I think we need to re-organize a lot of these docs into a longer "developer guide" instead of discrete getting started docs. We should reserve the "getting started" moniker for actual users, not us poor saps who build this stuff.
Fine to reorganize as a followup.
| cmd = [ | ||
| "bazel", | ||
| "run", | ||
| "--run_under=echo", |
There was a problem hiding this comment.
WTF. I swear, the people who wrote these things never tried to use them in a real project.
There was a problem hiding this comment.
Left a comment on the issue.
| @@ -0,0 +1,81 @@ | |||
| # Getting Started with IREE TensorFlow Integrations | |||
There was a problem hiding this comment.
I think we need to re-organize a lot of these docs into a longer "developer guide" instead of discrete getting started docs. We should reserve the "getting started" moniker for actual users, not us poor saps who build this stuff.
Fine to reorganize as a followup.
Fix release builds to build without asserts and turn off annoying deprecation warnings. The former is fallout from #4836 and the latter is something we've noticed being really annoying recently. The setting of deprecation to no-error (explicitly inviting warning spam) is something we seem to have inherited from Google's internal build. My best guess is that people mostly only see these in the code they're changing because everything is cached or something. If we want to surface these warnings, we should set up clang-tidy. Spamming the logs for anyone building anything in the project is not the way.
Rather than having CMake invoke Bazel itself, require that the
necessary binaries be built prior to running CMake and then import
them.
This is similar to what #4584 did
in the Android build and has similar advantages: the user can get these
binaries in a variety of ways: building with their chosen config (e.g.
with local or remote caching), installing prebuilt binaries, etc.
It also is significantly more clear what's going on IMO. Having CMake
invoke Bazel has caused a fair amount of confusion.
Incidentally, I'm pretty sure this increases test coverage by enabling
TF tests that were apparently not getting run.
Tested:
In addition to the CI, ran all the release distribution commands
locally and confirmed they still exited successfully.