4

I am trying to run this code using Bazel: https://github.com/google/in-silico-labeling. This is the associated Bazel BUILD file (I have added the appropriate bazel python rules, including a "py_runtime" interpreter path, "default_python_version", and "srcs_version" where applicable):

    package(default_visibility = ["//visibility:public"])

py_runtime(
    name="python-3.5.2",
    files=[],
    interpreter_path="/usr/bin/python3.5"
)

py_library(
    name = "tensorcheck",
    srcs = ["tensorcheck.py"],
    srcs_version="PY3",
)

py_library(
    name = "util",
    srcs = [
        "util.py",
    ],
    srcs_version="PY3",

)

py_library(
    name = "ops",
    srcs = ["ops.py"],
    deps = [
        ":tensorcheck",
    ],
    srcs_version="PY3",

)

py_library(
    name = "augment",
    srcs = [
        "augment.py",
    ],
    deps = [
        ":ops",
        ":util",
    ],
    srcs_version="PY3",

)

py_library(
    name = "visualize",
    srcs = [
        "visualize.py",
    ],
    deps = [
        ":ops",
        ":util",
    ],
    srcs_version="PY3",

)

py_library(
    name = "data_provider",
    srcs = [
        "data_provider.py",
    ],
    deps = [
        ":ops",
        ":tensorcheck",
        ":util",
    ],
    srcs_version="PY3",

)

py_library(
    name = "controller",
    srcs = [
        "controller.py",
    ],
    deps = [
        ":augment",
        ":data_provider",
        ":ops",
        ":tensorcheck",
        ":util",
        ":visualize",
        "//isl/models:model_util",
    ],
    srcs_version="PY3",

)

py_library(
    name = "infer",
    srcs = [
        "infer.py",
    ],
    deps = [
        ":augment",
        ":controller",
        ":data_provider",
        ":ops",
        ":tensorcheck",
        ":util",
        ":visualize",
        "//isl/models:model_util",
    ],
    srcs_version="PY3",

)

py_binary(
    name = "launch",
    srcs = [
        "launch.py",
    ],
    deps = [
        ":augment",
        ":controller",
        ":data_provider",
        ":infer",
        ":ops",
        ":util",
        "//isl/models:concordance",
        "//isl/models:model_util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",

)

filegroup(
    name = "testdata",
    srcs = glob([
        "testdata/**/*.png",
        "testdata/*png",
    ]) + [
        "testdata/research_logo.jpg",
    ],
)

py_library(
    name = "test_util",
    srcs = ["test_util.py"],
    data = [
        ":testdata",
    ],
    deps = [
        ":data_provider",
        ":ops",
        ":util",
    ],
    srcs_version="PY3",
)

py_test(
    name = "tensorcheck_test",
    srcs = ["tensorcheck_test.py"],
    # Enable the tensorcheck module.
    args = ["--tensorcheck_enable_checks"],
    deps = [
        ":tensorcheck",
        ":test_util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "util_test",
    srcs = [
        "util_test.py",
    ],
    deps = [
        ":test_util",
        ":util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "controller_test",
    size = "enormous",
    srcs = ["controller_test.py"],
    deps = [
        ":augment",
        ":controller",
        ":data_provider",
        ":test_util",
        ":util",
        "//isl/models:fovea",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "ops_test",
    size = "large",
    srcs = ["ops_test.py"],
    deps = [
        ":ops",
        ":test_util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "augment_test",
    srcs = ["augment_test.py"],
    deps = [
        ":augment",
        ":test_util",
        ":util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "visualize_test",
    size = "large",
    srcs = ["visualize_test.py"],
    deps = [
        ":data_provider",
        ":test_util",
        ":util",
        ":visualize",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

py_test(
    name = "data_provider_test",
    srcs = ["data_provider_test.py"],
    deps = [
        ":data_provider",
        ":test_util",
        ":util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

I have also edited a second BUILD file located in the "models" folder of the repository:

package(default_visibility = ["//visibility:public"])

py_runtime(
    name="python-3.5.2",
    files=[],
    interpreter_path="/usr/bin/python3.5"
)

py_library(
    name = "model_util",
    srcs = ["model_util.py"],
    deps = [
        "//isl:tensorcheck",
        "//isl:util",
    ],
    srcs_version="PY3",
)

py_library(
    name = "fovea",
    srcs = ["fovea.py"],
    deps = [
        ":model_util",
        "//isl:tensorcheck",
        "//isl:util",
    ],
    srcs_version="PY3",
)

py_library(
    name = "concordance",
    srcs = ["concordance.py"],
    deps = [
        ":model_util",
        "//isl:tensorcheck",
        "//isl:util",
    ],
    srcs_version="PY3",
)

py_test(
    name = "model_test",
    size = "large",
    srcs = ["model_test.py"],
    deps = [
        ":fovea",
        ":model_util",
        "//isl:controller",
        "//isl:test_util",
    ],
    default_python_version="PY3",
    srcs_version="PY3",
)

However, I get the following error when running the program through Bazel:

bazel run isl:launch -- \ --alsologtostderr \ --base_directory $BASE_DIRECTORY \ --mode EVAL_EVAL \ --metric INFER_FULL \ --stitch_crop_size 150 \ restore_directory $/data1/adamw/insilico_labeling/checkpoints \ read_pngs \ dataset_eval_directory $/data1/adamw/insilico_labeling/data_sample/condition_b_sample \ infer_channel_whitelist DAPI_CONFOCAL,MAP2_CONFOCAL,NFH_CONFOCAL
INFO: Analysed target //isl:launch (1 packages loaded).
INFO: Found 1 target...
Target //isl:launch up-to-date:
  bazel-out/k8-py3-fastbuild/bin/isl/launch
INFO: Elapsed time: 0.318s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-out/k8-py3-fastbuild/bin/isl/launch ' --alsologtostderr' ' --base_directory' ' --mode' EVAL_EVAL ' --metric' INFER_FULL ' --stitch_crop_size' 150 ' restore_directory' '$/data1/adamw/insilico_labeling/checkpoints' ' read_pngs' ' dataset_eval_directory' '$/data1/adamw/insilico_labeling/data_sample/condition_b_sample' ' infer_cINFO: Build completed successfully, 1 total action
  File "/home/adam/.cache/bazel/_bazel_adam/3c24d2105da2efbf30d96eb3fd97126b/execroot/__main__/bazel-out/k8-py3-fastbuild/bin/isl/launch.runfiles/__main__/isl/launch.py", line 199
    def get_z_values() -> List[float]:
                       ^
SyntaxError: invalid syntax

Am I missing something in the build file or command line? I have seen that "--force_python" may be deprecated but haven't tried this in combination with the python rules.

0 Answers0