From 0ecd0b6535eaa1ee05df3d1919062083c9bee91f Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Thu, 16 Oct 2025 13:07:46 +0200 Subject: [PATCH] bazel: backport cleanup from main --- ortools/pdlp/BUILD.bazel | 15 +++--- ortools/scheduling/BUILD.bazel | 72 ++++++++++++++----------- ortools/scheduling/python/BUILD.bazel | 6 +-- ortools/scheduling/python/rcpsp_test.py | 20 +++---- ortools/set_cover/BUILD.bazel | 2 +- 5 files changed, 60 insertions(+), 55 deletions(-) diff --git a/ortools/pdlp/BUILD.bazel b/ortools/pdlp/BUILD.bazel index 187db82bda..8a80c26b49 100644 --- a/ortools/pdlp/BUILD.bazel +++ b/ortools/pdlp/BUILD.bazel @@ -34,8 +34,8 @@ cc_library( cc_test( name = "scheduler_test", - size = "medium", srcs = ["scheduler_test.cc"], + tags = ["noci"], deps = [ ":scheduler", ":solvers_cc_proto", @@ -95,8 +95,8 @@ cc_library( cc_test( name = "iteration_stats_test", - size = "medium", srcs = ["iteration_stats_test.cc"], + tags = ["noci"], deps = [ ":iteration_stats", ":quadratic_program", @@ -152,6 +152,7 @@ cc_test( name = "primal_dual_hybrid_gradient_test", size = "medium", srcs = ["primal_dual_hybrid_gradient_test.cc"], + tags = ["noci"], deps = [ ":iteration_stats", ":primal_dual_hybrid_gradient", @@ -253,8 +254,9 @@ cc_library( cc_test( name = "sharded_optimization_utils_test", - size = "medium", + size = "small", srcs = ["sharded_optimization_utils_test.cc"], + tags = ["noci"], deps = [ ":quadratic_program", ":sharded_optimization_utils", @@ -286,8 +288,8 @@ cc_library( cc_test( name = "sharded_quadratic_program_test", - size = "medium", srcs = ["sharded_quadratic_program_test.cc"], + tags = ["noci"], deps = [ ":quadratic_program", ":sharded_quadratic_program", @@ -317,8 +319,9 @@ cc_library( cc_test( name = "sharder_test", - size = "medium", + size = "small", srcs = ["sharder_test.cc"], + tags = ["noci"], deps = [ ":scheduler", ":sharder", @@ -427,8 +430,8 @@ cc_library( cc_test( name = "trust_region_test", - size = "medium", srcs = ["trust_region_test.cc"], + tags = ["noci"], deps = [ ":quadratic_program", ":sharded_optimization_utils", diff --git a/ortools/scheduling/BUILD.bazel b/ortools/scheduling/BUILD.bazel index 5f361e2745..6e27790607 100644 --- a/ortools/scheduling/BUILD.bazel +++ b/ortools/scheduling/BUILD.bazel @@ -11,6 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This directory contains scheduling libraries to solve different types of +# scheduling problem. + load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library") @@ -18,6 +21,37 @@ load("@rules_cc//cc:cc_library.bzl", "cc_library") package(default_visibility = ["//visibility:public"]) +### RCPSP ### +proto_library( + name = "rcpsp_proto", + srcs = ["rcpsp.proto"], +) + +cc_proto_library( + name = "rcpsp_cc_proto", + deps = [":rcpsp_proto"], +) + +py_proto_library( + name = "rcpsp_py_pb2", + deps = [":rcpsp_proto"], +) + +cc_library( + name = "rcpsp_parser", + srcs = ["rcpsp_parser.cc"], + hdrs = ["rcpsp_parser.h"], + deps = [ + ":rcpsp_cc_proto", + "//ortools/base:path", + "//ortools/util:filelineiter", + "@abseil-cpp//absl/log", + "@abseil-cpp//absl/log:check", + "@abseil-cpp//absl/strings", + ], +) + +### Jobshop Scheduling ### proto_library( name = "jobshop_scheduling_proto", srcs = ["jobshop_scheduling.proto"], @@ -37,42 +71,17 @@ cc_library( ":jobshop_scheduling_cc_proto", "//ortools/base", "//ortools/base:path", + "//ortools/base:types", "//ortools/util:filelineiter", + "@abseil-cpp//absl/base:core_headers", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings", - "@protobuf", - ], -) - -proto_library( - name = "rcpsp_proto", - srcs = ["rcpsp.proto"], -) - -cc_proto_library( - name = "rcpsp_cc_proto", - deps = [":rcpsp_proto"], -) - -py_proto_library( - name = "rcpsp_py_proto", - deps = [":rcpsp_proto"], -) - -cc_library( - name = "rcpsp_parser", - srcs = ["rcpsp_parser.cc"], - hdrs = ["rcpsp_parser.h"], - visibility = ["//visibility:public"], - deps = [ - ":rcpsp_cc_proto", - "//ortools/base", - "//ortools/base:file", - "//ortools/base:path", - "//ortools/util:filelineiter", - "@abseil-cpp//absl/strings", + "@protobuf//:wrappers_cc_proto", ], ) +### Course Scheduling ### proto_library( name = "course_scheduling_proto", srcs = ["course_scheduling.proto"], @@ -80,6 +89,5 @@ proto_library( cc_proto_library( name = "course_scheduling_cc_proto", - visibility = ["//visibility:public"], deps = [":course_scheduling_proto"], ) diff --git a/ortools/scheduling/python/BUILD.bazel b/ortools/scheduling/python/BUILD.bazel index d5941e58d7..cc12f16153 100644 --- a/ortools/scheduling/python/BUILD.bazel +++ b/ortools/scheduling/python/BUILD.bazel @@ -11,8 +11,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Python wrapper for .. - load("@pip_deps//:requirements.bzl", "requirement") load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") load("@rules_python//python:py_test.bzl", "py_test") @@ -24,6 +22,7 @@ pybind_extension( deps = [ "//ortools/scheduling:rcpsp_cc_proto", "//ortools/scheduling:rcpsp_parser", + "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/strings", "@pybind11_protobuf//pybind11_protobuf:native_proto_caster", ], @@ -31,11 +30,12 @@ pybind_extension( py_test( name = "rcpsp_test", + size = "small", srcs = ["rcpsp_test.py"], data = ["//ortools/scheduling/testdata:j301_1.sm"], deps = [ ":rcpsp", - "//ortools/scheduling:rcpsp_py_proto", + "//ortools/scheduling:rcpsp_py_pb2", requirement("absl-py"), ], ) diff --git a/ortools/scheduling/python/rcpsp_test.py b/ortools/scheduling/python/rcpsp_test.py index 7678084083..931e6c2bc0 100644 --- a/ortools/scheduling/python/rcpsp_test.py +++ b/ortools/scheduling/python/rcpsp_test.py @@ -12,32 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -from absl import app -from absl import flags +import os from absl.testing import absltest from ortools.scheduling.python import rcpsp -FLAGS = flags.FLAGS - class RcpspTest(absltest.TestCase): def testParseAndAccess(self): - parser = rcpsp.RcpspParser() + test_srcdir = os.environ.get("TEST_SRCDIR") data = "ortools/scheduling/testdata/j301_1.sm" - try: - filename = f"{FLAGS.test_srcdir}/_main/{data}" - except flags._exceptions.UnparsedFlagAccessError: + if test_srcdir: + filename = f"{test_srcdir}/_main/{data}" + else: filename = f"../../../{data}" + parser = rcpsp.RcpspParser() self.assertTrue(parser.parse_file(filename)) problem = parser.problem() self.assertLen(problem.resources, 4) self.assertLen(problem.tasks, 32) -def main(unused_argv): - absltest.main() - - if __name__ == "__main__": - app.run(main) + absltest.main() diff --git a/ortools/set_cover/BUILD.bazel b/ortools/set_cover/BUILD.bazel index d1bd94d678..c209f86d86 100644 --- a/ortools/set_cover/BUILD.bazel +++ b/ortools/set_cover/BUILD.bazel @@ -114,7 +114,7 @@ cc_library( ":base_types", ":set_cover_cc_proto", ":set_cover_model", - "//ortools/base", + "//ortools/base:logging", "//ortools/base:mathutil", "@abseil-cpp//absl/log", "@abseil-cpp//absl/log:check",