Brian Phiri
Brian Phiri

Reputation: 154

python file not reading folder in bazel

Hey I have written a python neural net that uses raw file in a folder for training, using tensorflow i have been able to build the binaries with the both the python script and the folder containing the raw data saved within the bazel-bin/.... the problem i am having is that when i run the bazel-bin/... to train the model my python script does not read from the folder with the raw data.

this is what my BUILD file looks like where raw_sound is the folder i am importing the sound files from.

py_binary(
    name = "sound",
    srcs_version = "PY3",
    srcs = [
        "sound.py",
    ],
    deps = [
        "@org_tensorflow//tensorflow:tensorflow_py",
        "@org_tensorflow//tensorflow/python/saved_model:builder",
        "@org_tensorflow//tensorflow/python/saved_model:constants",
        "@org_tensorflow//tensorflow/python/saved_model:loader",
        "@org_tensorflow//tensorflow/python/saved_model:signature_constants",
        "@org_tensorflow//tensorflow/python/saved_model:signature_def_utils",
        "@org_tensorflow//tensorflow/python/saved_model:tag_constants",
        "@org_tensorflow//tensorflow/python/saved_model:utils",
    ],
    data = glob(["raw_sound/**"]),
)

Upvotes: 1

Views: 1266

Answers (1)

kris
kris

Reputation: 23592

What does the path look like that you're loading the data from?

When you create a binary with Bazel, bazel-bin/whatever/sound will actually be a shell script that cd's to bazel-bin/whatever/sound.runfiles/workspace_name/, which is a symlink tree that contains all of the scripts/data dependencies you've declared. So you should be able to load the raw sound files using the path whatever/raw_sound/file (because those are the paths to the raw files under the runfiles tree).

Upvotes: 1

Related Questions