bazel: export more math_opt py_test

This commit is contained in:
Corentin Le Molgat
2025-04-11 17:33:09 +02:00
parent aaead8839d
commit 940a79a3af
4 changed files with 367 additions and 1 deletions

View File

@@ -11,7 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@pip_deps//:requirements.bzl", "requirement")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_python//python:defs.bzl", "py_test")
package(default_visibility = ["//ortools/math_opt:__subpackages__"])
@@ -57,3 +59,23 @@ pybind_extension(
"@pybind11_protobuf//pybind11_protobuf:native_proto_caster",
],
)
py_test(
name = "solver_test",
size = "small",
srcs = ["solver_test.py"],
deps = [
":solver",
requirement("absl-py"),
"//ortools/math_opt:callback_py_pb2",
"//ortools/math_opt:model_parameters_py_pb2",
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt:parameters_py_pb2",
"//ortools/math_opt:result_py_pb2",
"//ortools/math_opt/solvers:cp_sat_solver",
"//ortools/math_opt/solvers:glop_solver",
"//ortools/math_opt/solvers:gscip_solver",
"@pybind11_abseil//pybind11_abseil:status",
],
)

View File

@@ -11,7 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@pip_deps//:requirements.bzl", "requirement")
load("@pybind11_bazel//:build_defs.bzl", "pybind_extension")
load("@rules_python//python:defs.bzl", "py_test")
package(default_visibility = ["//visibility:public"])
@@ -30,3 +32,15 @@ pybind_extension(
"@pybind11_protobuf//pybind11_protobuf:native_proto_caster",
],
)
py_test(
name = "mps_converter_test",
srcs = ["mps_converter_test.py"],
deps = [
":mps_converter",
requirement("absl-py"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt/python:mathopt",
"//ortools/math_opt/python/testing:compare_proto",
],
)

View File

@@ -12,7 +12,7 @@
# limitations under the License.
load("@pip_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
# External users should depend only on ":mathopt" and import "mathopt".
# Hence other libraries are private.
@@ -72,6 +72,45 @@ py_library(
],
)
py_test(
name = "hash_model_storage_test",
size = "small",
srcs = ["hash_model_storage_test.py"],
deps = [
":hash_model_storage",
requirement("absl-py"),
],
)
py_test(
name = "model_storage_test",
size = "small",
srcs = ["model_storage_test.py"],
deps = [
":hash_model_storage",
":model_storage",
requirement("absl-py"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_test(
name = "model_storage_update_test",
size = "small",
srcs = ["model_storage_update_test.py"],
deps = [
":hash_model_storage",
":model_storage",
requirement("absl-py"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "model",
srcs = ["model.py"],
@@ -91,6 +130,37 @@ py_library(
],
)
py_test(
name = "model_element_test",
size = "small",
srcs = ["model_element_test.py"],
deps = [
":indicator_constraints",
":linear_constraints",
":model",
":objectives",
":quadratic_constraints",
":variables",
requirement("absl-py"),
],
)
py_test(
name = "model_test",
size = "small",
srcs = ["model_test.py"],
deps = [
":linear_constraints",
":model",
":variables",
requirement("absl-py"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "linear_constraints",
srcs = ["linear_constraints.py"],
@@ -102,6 +172,18 @@ py_library(
],
)
py_test(
name = "linear_expression_test",
size = "small",
srcs = ["linear_expression_test.py"],
deps = [
":bounded_expressions",
":model",
":variables",
requirement("absl-py"),
],
)
py_library(
name = "sparse_containers",
srcs = ["sparse_containers.py"],
@@ -114,6 +196,22 @@ py_library(
],
)
py_test(
name = "sparse_containers_test",
size = "small",
srcs = ["sparse_containers_test.py"],
deps = [
":linear_constraints",
":model",
":quadratic_constraints",
":sparse_containers",
":variables",
requirement("absl-py"),
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "solution",
srcs = ["solution.py"],
@@ -128,6 +226,20 @@ py_library(
],
)
py_test(
name = "solution_test",
size = "small",
srcs = ["solution_test.py"],
deps = [
":model",
":solution",
requirement("absl-py"),
"//ortools/math_opt:solution_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "quadratic_constraints",
srcs = ["quadratic_constraints.py"],
@@ -139,6 +251,15 @@ py_library(
],
)
py_test(
name = "quadratic_constraints_test",
srcs = ["quadratic_constraints_test.py"],
deps = [
":model",
requirement("absl-py"),
],
)
py_library(
name = "indicator_constraints",
srcs = ["indicator_constraints.py"],
@@ -150,6 +271,17 @@ py_library(
],
)
py_test(
name = "indicator_constraints_test",
srcs = ["indicator_constraints_test.py"],
deps = [
":indicator_constraints",
":model",
":variables",
requirement("absl-py"),
],
)
py_library(
name = "result",
srcs = ["result.py"],
@@ -175,6 +307,35 @@ py_library(
],
)
py_test(
name = "objectives_test",
size = "small",
srcs = ["objectives_test.py"],
deps = [
":model",
":objectives",
":variables",
requirement("absl-py"),
"//ortools/math_opt/elemental/python:cpp_elemental",
],
)
py_test(
name = "model_objective_test",
size = "small",
srcs = ["model_objective_test.py"],
deps = [
":model",
":objectives",
":variables",
requirement("absl-py"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "parameters",
srcs = ["parameters.py"],
@@ -191,6 +352,26 @@ py_library(
],
)
py_test(
name = "parameters_test",
size = "small",
srcs = ["parameters_test.py"],
deps = [
":parameters",
requirement("absl-py"),
"//ortools/glop:parameters_py_pb2",
"//ortools/gscip:gscip_proto_py_pb2",
"//ortools/math_opt:parameters_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
"//ortools/math_opt/solvers:glpk_py_pb2",
"//ortools/math_opt/solvers:gurobi_py_pb2",
"//ortools/math_opt/solvers:highs_py_pb2",
"//ortools/math_opt/solvers:osqp_py_pb2",
"//ortools/pdlp:solvers_py_pb2",
"//ortools/sat:sat_parameters_py_pb2",
],
)
py_library(
name = "model_parameters",
srcs = ["model_parameters.py"],
@@ -205,6 +386,23 @@ py_library(
],
)
py_test(
name = "model_parameters_test",
size = "small",
srcs = ["model_parameters_test.py"],
deps = [
":model",
":model_parameters",
":solution",
":sparse_containers",
requirement("absl-py"),
"//ortools/math_opt:model_parameters_py_pb2",
"//ortools/math_opt:solution_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "callback",
srcs = ["callback.py"],
@@ -217,6 +415,21 @@ py_library(
],
)
py_test(
name = "callback_test",
size = "small",
srcs = ["callback_test.py"],
deps = [
":callback",
":model",
":sparse_containers",
requirement("absl-py"),
"//ortools/math_opt:callback_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "compute_infeasible_subsystem_result",
srcs = ["compute_infeasible_subsystem_result.py"],
@@ -230,6 +443,20 @@ py_library(
],
)
py_test(
name = "compute_infeasible_subsystem_result_test",
size = "small",
srcs = ["compute_infeasible_subsystem_result_test.py"],
deps = [
":compute_infeasible_subsystem_result",
":model",
":result",
requirement("absl-py"),
"//ortools/math_opt:infeasible_subsystem_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "solve",
srcs = ["solve.py"],
@@ -255,17 +482,46 @@ py_library(
deps = [requirement("absl-py")],
)
py_test(
name = "message_callback_test",
srcs = ["message_callback_test.py"],
deps = [
":message_callback",
requirement("absl-py"),
],
)
py_library(
name = "statistics",
srcs = ["statistics.py"],
deps = [":model"],
)
py_test(
name = "statistics_test",
srcs = ["statistics_test.py"],
deps = [
":model",
":statistics",
requirement("absl-py"),
],
)
py_library(
name = "bounded_expressions",
srcs = ["bounded_expressions.py"],
)
py_test(
name = "bounded_expressions_test",
size = "small",
srcs = ["bounded_expressions_test.py"],
deps = [
":bounded_expressions",
requirement("absl-py"),
],
)
py_library(
name = "variables",
srcs = ["variables.py"],
@@ -287,6 +543,19 @@ py_library(
],
)
py_test(
name = "normalized_inequality_test",
size = "small",
srcs = ["normalized_inequality_test.py"],
deps = [
":bounded_expressions",
":model",
":normalized_inequality",
":variables",
requirement("absl-py"),
],
)
py_library(
name = "normalize",
srcs = ["normalize.py"],
@@ -294,6 +563,22 @@ py_library(
deps = ["@com_google_protobuf//:protobuf_python"],
)
py_test(
name = "normalize_test",
srcs = ["normalize_test.py"],
deps = [
":normalize",
requirement("absl-py"),
"//ortools/math_opt:model_parameters_py_pb2",
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt:parameters_py_pb2",
"//ortools/math_opt:result_py_pb2",
"//ortools/math_opt:sparse_containers_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "expressions",
srcs = ["expressions.py"],
@@ -302,18 +587,50 @@ py_library(
],
)
py_test(
name = "expressions_test",
srcs = ["expressions_test.py"],
deps = [
":expressions",
":model",
":variables",
requirement("absl-py"),
],
)
py_library(
name = "solver_resources",
srcs = ["solver_resources.py"],
deps = ["//ortools/math_opt:rpc_py_pb2"],
)
py_test(
name = "solver_resources_test",
srcs = ["solver_resources_test.py"],
deps = [
":solver_resources",
requirement("absl-py"),
"//ortools/math_opt:rpc_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
],
)
py_library(
name = "errors",
srcs = ["errors.py"],
deps = ["//ortools/math_opt:rpc_py_pb2"],
)
py_test(
name = "errors_test",
srcs = ["errors_test.py"],
deps = [
":errors",
requirement("absl-py"),
"//ortools/math_opt:rpc_py_pb2",
],
)
py_library(
name = "init_arguments",
srcs = ["init_arguments.py"],
@@ -322,3 +639,15 @@ py_library(
"//ortools/math_opt/solvers:gurobi_py_pb2",
],
)
py_test(
name = "init_arguments_test",
srcs = ["init_arguments_test.py"],
deps = [
":init_arguments",
requirement("absl-py"),
"//ortools/math_opt:parameters_py_pb2",
"//ortools/math_opt/python/testing:compare_proto",
"//ortools/math_opt/solvers:gurobi_py_pb2",
],
)

View File

@@ -24,6 +24,7 @@ py_library(
srcs = ["elemental.py"],
deps = [
requirement("numpy"),
requirement("typing-extensions"),
"//ortools/math_opt:model_py_pb2",
"//ortools/math_opt:model_update_py_pb2",
"//ortools/math_opt/elemental/python:enums",