diff --git a/fbpcs/private_computation/repository/private_computation_game.py b/fbpcs/private_computation/repository/private_computation_game.py index d31361dd9..c3064df73 100644 --- a/fbpcs/private_computation/repository/private_computation_game.py +++ b/fbpcs/private_computation/repository/private_computation_game.py @@ -11,10 +11,17 @@ from enum import Enum from typing import Dict, List, TypedDict -from fbpcp.entity.mpc_game_config import MPCGameArgument, MPCGameConfig -from fbpcp.repository.mpc_game_repository import MPCGameRepository from fbpcs.onedocker_binary_names import OneDockerBinaryNames +from fbpcs.private_computation.service.mpc.entity.mpc_game_config import ( + MPCGameArgument, + MPCGameConfig, +) + +from fbpcs.private_computation.service.mpc.repository.mpc_game_repository import ( + MPCGameRepository, +) + class GameNames(Enum): SECURE_RANDOM_SHARDER = "secure_random_sharder" diff --git a/fbpcs/private_computation/service/mpc/entity/mpc_game_config.py b/fbpcs/private_computation/service/mpc/entity/mpc_game_config.py new file mode 100644 index 000000000..2d9fe5695 --- /dev/null +++ b/fbpcs/private_computation/service/mpc/entity/mpc_game_config.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# pyre-strict + +from dataclasses import dataclass +from typing import List + + +@dataclass +class MPCGameArgument: + name: str + required: bool + + +@dataclass +class MPCGameConfig: + game_name: str + onedocker_package_name: str + arguments: List[MPCGameArgument] diff --git a/fbpcs/private_computation/service/mpc/mpc_game.py b/fbpcs/private_computation/service/mpc/mpc_game.py index 9f5e759c4..004455b5d 100644 --- a/fbpcs/private_computation/service/mpc/mpc_game.py +++ b/fbpcs/private_computation/service/mpc/mpc_game.py @@ -9,11 +9,14 @@ import logging from typing import Any, Dict, Optional, Tuple -from fbpcp.entity.mpc_game_config import MPCGameConfig from fbpcp.entity.mpc_instance import MPCParty -from fbpcp.repository.mpc_game_repository import MPCGameRepository from fbpcp.util.arg_builder import build_cmd_args +from fbpcs.private_computation.service.mpc.entity.mpc_game_config import MPCGameConfig +from fbpcs.private_computation.service.mpc.repository.mpc_game_repository import ( + MPCGameRepository, +) + LIFT_GAME_NAME = "lift" LIFT_AGGREGATOR_GAME_NAME = "aggregator" diff --git a/fbpcs/private_computation/service/mpc/repository/mpc_game_repository.py b/fbpcs/private_computation/service/mpc/repository/mpc_game_repository.py new file mode 100644 index 000000000..a3a9147a8 --- /dev/null +++ b/fbpcs/private_computation/service/mpc/repository/mpc_game_repository.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# pyre-strict + +import abc + +from fbpcs.private_computation.service.mpc.entity.mpc_game_config import MPCGameConfig + + +class MPCGameRepository(abc.ABC): + @abc.abstractmethod + def get_game(self, name: str) -> MPCGameConfig: + pass diff --git a/fbpcs/private_computation/test/repository/test_private_computation_game.py b/fbpcs/private_computation/test/repository/test_private_computation_game.py index d82b09f44..dfdb411b4 100644 --- a/fbpcs/private_computation/test/repository/test_private_computation_game.py +++ b/fbpcs/private_computation/test/repository/test_private_computation_game.py @@ -10,12 +10,13 @@ from typing import List from unittest.mock import patch -from fbpcp.entity.mpc_game_config import MPCGameArgument from fbpcs.private_computation.repository.private_computation_game import ( OneDockerArgument, PrivateComputationGameRepository, ) +from fbpcs.private_computation.service.mpc.entity.mpc_game_config import MPCGameArgument + class TestPrivateComputationGameRepository(unittest.TestCase): @patch( diff --git a/fbpcs/private_computation/test/service/mpc/test_mpc_game.py b/fbpcs/private_computation/test/service/mpc/test_mpc_game.py index 0ec739574..62c3d7b9d 100644 --- a/fbpcs/private_computation/test/service/mpc/test_mpc_game.py +++ b/fbpcs/private_computation/test/service/mpc/test_mpc_game.py @@ -8,8 +8,12 @@ from typing import List from unittest.mock import MagicMock, Mock -from fbpcp.entity.mpc_game_config import MPCGameArgument, MPCGameConfig from fbpcp.entity.mpc_instance import MPCParty + +from fbpcs.private_computation.service.mpc.entity.mpc_game_config import ( + MPCGameArgument, + MPCGameConfig, +) from fbpcs.private_computation.service.mpc.mpc_game import MPCGameService diff --git a/fbpcs/private_computation_cli/private_computation_service_wrapper.py b/fbpcs/private_computation_cli/private_computation_service_wrapper.py index 87f4872f2..48e88c183 100644 --- a/fbpcs/private_computation_cli/private_computation_service_wrapper.py +++ b/fbpcs/private_computation_cli/private_computation_service_wrapper.py @@ -10,7 +10,6 @@ from typing import Any, DefaultDict, Dict, List, Optional, Type from fbpcp.entity.mpc_instance import MPCInstance -from fbpcp.repository.mpc_game_repository import MPCGameRepository from fbpcp.repository.mpc_instance import MPCInstanceRepository from fbpcp.service.container import ContainerService from fbpcp.service.onedocker import OneDockerService @@ -43,6 +42,9 @@ ) from fbpcs.private_computation.service.mpc.mpc import MPCService from fbpcs.private_computation.service.mpc.mpc_game import MPCGameService +from fbpcs.private_computation.service.mpc.repository.mpc_game_repository import ( + MPCGameRepository, +) from fbpcs.private_computation.service.private_computation import ( PrivateComputationService, ) diff --git a/fbpcs/private_computation_cli/tests/test_private_computation_service_wrapper.py b/fbpcs/private_computation_cli/tests/test_private_computation_service_wrapper.py index 812cf288f..dd3eccbcc 100644 --- a/fbpcs/private_computation_cli/tests/test_private_computation_service_wrapper.py +++ b/fbpcs/private_computation_cli/tests/test_private_computation_service_wrapper.py @@ -7,7 +7,6 @@ from unittest import TestCase from unittest.mock import ANY, call, MagicMock, patch -from fbpcp.repository.mpc_game_repository import MPCGameRepository from fbpcp.repository.mpc_instance import MPCInstanceRepository from fbpcp.service.container import ContainerService from fbpcp.service.storage import StorageService @@ -22,6 +21,10 @@ PrivateComputationInstanceRepository, ) from fbpcs.private_computation.service.mpc.mpc_game import MPCGameService + +from fbpcs.private_computation.service.mpc.repository.mpc_game_repository import ( + MPCGameRepository, +) from fbpcs.private_computation.service.private_computation import ( PrivateComputationService, )