1# Copyright 2022 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("@rules_python//python:defs.bzl", "py_library", "py_test") 16 17# The public interface for this package, providing the various Federated Program platform 18# components needed to run a Federated Program using Federated Compute clients. 19py_library( 20 name = "demo", 21 srcs = ["__init__.py"], 22 srcs_version = "PY3", 23 visibility = ["//visibility:public"], 24 deps = [ 25 ":federated_computation", 26 ":federated_context", 27 ":federated_data_source", 28 ], 29) 30 31py_library( 32 name = "aggregations", 33 srcs = ["aggregations.py"], 34 data = ["@pybind11_abseil//pybind11_abseil:status.so"], 35 srcs_version = "PY3", 36 deps = [ 37 ":http_actions", 38 ":media", 39 "//fcp/aggregation/protocol:configuration_py_pb2", 40 "//fcp/aggregation/protocol:py_pb2", 41 "//fcp/aggregation/protocol/python:aggregation_protocol", 42 "//fcp/aggregation/tensorflow/python:aggregation_protocols", 43 "//fcp/protos:plan_py_pb2", 44 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 45 "@com_google_googleapis//google/rpc:code_py_proto", 46 "@googleapis_for_longrunning//google/longrunning:longrunning_py_proto", 47 ], 48) 49 50py_test( 51 name = "aggregations_test", 52 srcs = ["aggregations_test.py"], 53 data = ["@pybind11_abseil//pybind11_abseil:status.so"], 54 python_version = "PY3", 55 srcs_version = "PY3", 56 deps = [ 57 ":aggregations", 58 ":http_actions", 59 ":media", 60 ":test_utils", 61 "//fcp/aggregation/protocol:py_pb2", 62 "//fcp/aggregation/protocol/python:aggregation_protocol", 63 "//fcp/aggregation/tensorflow/python:aggregation_protocols", 64 "//fcp/protos:plan_py_pb2", 65 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 66 ], 67) 68 69py_library( 70 name = "checkpoint_tensor_reference", 71 srcs = ["checkpoint_tensor_reference.py"], 72 srcs_version = "PY3", 73) 74 75py_test( 76 name = "checkpoint_tensor_reference_test", 77 srcs = ["checkpoint_tensor_reference_test.py"], 78 python_version = "PY3", 79 srcs_version = "PY3", 80 deps = [ 81 ":checkpoint_tensor_reference", 82 ":test_utils", 83 ], 84) 85 86py_library( 87 name = "eligibility_eval_tasks", 88 srcs = ["eligibility_eval_tasks.py"], 89 srcs_version = "PY3", 90 deps = [ 91 ":http_actions", 92 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 93 "@com_google_googleapis//google/rpc:code_py_proto", 94 ], 95) 96 97py_test( 98 name = "eligibility_eval_tasks_test", 99 srcs = ["eligibility_eval_tasks_test.py"], 100 python_version = "PY3", 101 srcs_version = "PY3", 102 deps = [ 103 ":eligibility_eval_tasks", 104 ":http_actions", 105 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 106 "@com_google_googleapis//google/rpc:code_py_proto", 107 ], 108) 109 110py_library( 111 name = "federated_computation", 112 srcs = ["federated_computation.py"], 113 srcs_version = "PY3", 114) 115 116py_test( 117 name = "federated_computation_test", 118 srcs = ["federated_computation_test.py"], 119 python_version = "PY3", 120 srcs_version = "PY3", 121 deps = [":federated_computation"], 122) 123 124py_library( 125 name = "federated_context", 126 srcs = ["federated_context.py"], 127 srcs_version = "PY3", 128 deps = [ 129 ":checkpoint_tensor_reference", 130 ":federated_computation", 131 ":federated_data_source", 132 ":server", 133 "//fcp/artifact_building:artifact_constants", 134 "//fcp/artifact_building:checkpoint_utils", 135 "//fcp/artifact_building:data_spec", 136 "//fcp/artifact_building:federated_compute_plan_builder", 137 "//fcp/artifact_building:plan_utils", 138 "//fcp/artifact_building:variable_helpers", 139 "//fcp/protos:plan_py_pb2", 140 ], 141) 142 143py_test( 144 name = "federated_context_test", 145 size = "medium", 146 srcs = ["federated_context_test.py"], 147 python_version = "PY3", 148 srcs_version = "PY3", 149 deps = [ 150 ":federated_computation", 151 ":federated_context", 152 ":federated_data_source", 153 ":server", 154 ":test_utils", 155 "//fcp/artifact_building:artifact_constants", 156 "//fcp/artifact_building:federated_compute_plan_builder", 157 "//fcp/artifact_building:plan_utils", 158 "//fcp/artifact_building:variable_helpers", 159 "//fcp/protos:plan_py_pb2", 160 ], 161) 162 163py_library( 164 name = "federated_data_source", 165 srcs = ["federated_data_source.py"], 166 srcs_version = "PY3", 167 deps = [ 168 "//fcp/protos:plan_py_pb2", 169 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 170 ], 171) 172 173py_test( 174 name = "federated_data_source_test", 175 srcs = ["federated_data_source_test.py"], 176 python_version = "PY3", 177 srcs_version = "PY3", 178 deps = [ 179 ":federated_data_source", 180 "//fcp/protos:plan_py_pb2", 181 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 182 ], 183) 184 185py_test( 186 name = "federated_program_test", 187 size = "medium", 188 srcs = ["federated_program_test.py"], 189 data = ["//fcp/client:client_runner_main"], 190 python_version = "PY3", 191 srcs_version = "PY3", 192 deps = [ 193 ":demo", 194 "//fcp/client:client_runner_example_data_py_pb2", 195 "//fcp/protos:plan_py_pb2", 196 ], 197) 198 199py_library( 200 name = "http_actions", 201 srcs = ["http_actions.py"], 202 srcs_version = "PY3", 203 deps = ["@com_google_googleapis//google/api:annotations_py_proto"], 204) 205 206py_test( 207 name = "http_actions_test", 208 size = "medium", 209 srcs = ["http_actions_test.py"], 210 python_version = "PY3", 211 srcs_version = "PY3", 212 deps = [ 213 ":http_actions", 214 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 215 ], 216) 217 218py_library( 219 name = "media", 220 srcs = ["media.py"], 221 srcs_version = "PY3", 222 deps = [ 223 ":http_actions", 224 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 225 ], 226) 227 228py_test( 229 name = "media_test", 230 srcs = ["media_test.py"], 231 python_version = "PY3", 232 srcs_version = "PY3", 233 deps = [ 234 ":http_actions", 235 ":media", 236 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 237 ], 238) 239 240py_library( 241 name = "plan_utils", 242 srcs = ["plan_utils.py"], 243 srcs_version = "PY3", 244 deps = [ 245 "//fcp/protos:plan_py_pb2", 246 "//fcp/tensorflow:serve_slices_py", 247 ], 248) 249 250py_test( 251 name = "plan_utils_test", 252 size = "medium", 253 srcs = ["plan_utils_test.py"], 254 python_version = "PY3", 255 srcs_version = "PY3", 256 deps = [ 257 ":plan_utils", 258 ":test_utils", 259 "//fcp/protos:plan_py_pb2", 260 "//fcp/tensorflow:serve_slices_py", 261 ], 262) 263 264py_library( 265 name = "server", 266 srcs = ["server.py"], 267 srcs_version = "PY3", 268 deps = [ 269 ":aggregations", 270 ":eligibility_eval_tasks", 271 ":http_actions", 272 ":media", 273 ":plan_utils", 274 ":task_assignments", 275 "//fcp/protos:plan_py_pb2", 276 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 277 ], 278) 279 280py_test( 281 name = "server_test", 282 size = "medium", 283 srcs = ["server_test.py"], 284 data = ["//fcp/client:client_runner_main"], 285 python_version = "PY3", 286 srcs_version = "PY3", 287 deps = [ 288 ":plan_utils", 289 ":server", 290 ":test_utils", 291 "//fcp/protos:plan_py_pb2", 292 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 293 "//fcp/tensorflow:external_dataset_py", 294 "@googleapis_for_longrunning//google/longrunning:longrunning_py_proto", 295 ], 296) 297 298py_library( 299 name = "task_assignments", 300 srcs = ["task_assignments.py"], 301 srcs_version = "PY3", 302 deps = [ 303 ":aggregations", 304 ":http_actions", 305 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 306 "@com_google_googleapis//google/rpc:code_py_proto", 307 "@googleapis_for_longrunning//google/longrunning:longrunning_py_proto", 308 ], 309) 310 311py_test( 312 name = "task_assignments_test", 313 srcs = ["task_assignments_test.py"], 314 python_version = "PY3", 315 srcs_version = "PY3", 316 deps = [ 317 ":aggregations", 318 ":http_actions", 319 ":task_assignments", 320 "//fcp/protos/federatedcompute:federated_compute_py_pb2", 321 "@com_google_googleapis//google/rpc:code_py_proto", 322 ], 323) 324 325py_library( 326 name = "test_utils", 327 testonly = True, 328 srcs = ["test_utils.py"], 329) 330 331py_test( 332 name = "test_utils_test", 333 size = "medium", 334 srcs = ["test_utils_test.py"], 335 python_version = "PY3", 336 srcs_version = "PY3", 337 deps = [":test_utils"], 338) 339