Skip to content

Commit

Permalink
Fix kernels_to_ops generating in the wrong location (#6823)
Browse files Browse the repository at this point in the history
Avoid using `chdir = 'tfjs-converter'` in kernels_to_ops.bzl. Using `chdir` follows the symlink to `tfjs-converter`'s files in the execroot directory (`/usr/local/google/home/msoulanille/.cache/bazel/_bazel_msoulanille/f671279d7efd00bb0451adc485135cc0/execroot/tfjs/tfjs-converter`). Then, when node is started, it doesn't know that it followed a symlink, so when it tries to write to `../bazel-out/.....`, it's no longer looking in the execroot directory and can not find the correct file.

Fix this by starting node in the execroot directory instead of in the `tfjs-converter` symlink's directory.
  • Loading branch information
mattsoulanille authored Sep 12, 2022
1 parent f8165e2 commit 05ff063
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions tfjs-converter/scripts/kernels_to_ops.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@ load("@build_bazel_rules_nodejs//:providers.bzl", "run_node")

def _kernels_to_ops_impl(ctx):
output_file = ctx.outputs.out

run_node(
ctx,
executable = "kernels_to_ops_bin",
inputs = ctx.files.srcs,
outputs = [output_file],
chdir = "tfjs-converter",
arguments = [
"--out",
"../" + output_file.path, # '../' due to chdir above
output_file.path,
],
)

Expand Down
4 changes: 2 additions & 2 deletions tfjs-converter/scripts/kernels_to_ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type KernelMapping = {

function getKernelMappingForFile(source: SourceFile) {
const switchStatement = getSwitchStatement(source);
if (switchStatement === null) {
if (switchStatement == null) {
throw new Error('No switch statment found in executor');
}
const caseClauses = switchStatement.getClauses();
Expand Down Expand Up @@ -138,7 +138,7 @@ function getKernelMapping() {
}

async function run(outputFilePath: string) {
const EXECUTORS_PATH = 'src/operations/executors/*_executor.ts';
const EXECUTORS_PATH = 'tfjs-converter/src/operations/executors/*_executor.ts';
project.addSourceFilesAtPaths(EXECUTORS_PATH);

const kernelMapping = getKernelMapping();
Expand Down

0 comments on commit 05ff063

Please sign in to comment.