Skip to content

Commit

Permalink
mpc_game entity/repository migrate from fbpcp to fbpcs (#1909)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1909

## Why
In next couple weeks, I'm going to migrate mpc service from fbpcp to fbpcs.
This is the first guard to avoid any further changes in fbpcp's mpc realted files
detailed plan: https://docs.google.com/document/d/1qR1XVVCA2By95tldl2Ey9m__GKX3raodGAZ5yK9SCEw/edit?usp=sharing

## What
- hg copy `mpc_game_config.py` from fbpcp to fbpcs
- hg copy `mpc_game_repository.py` as as well
- change import to fbpcs

Reviewed By: musebc

Differential Revision: D41201899

fbshipit-source-id: 8a9de4f03188febcbfece0c8d9badd2c559b4d42
  • Loading branch information
joe1234wu authored and facebook-github-bot committed Nov 11, 2022
1 parent 0f1ea11 commit 2a47a09
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 8 deletions.
11 changes: 9 additions & 2 deletions fbpcs/private_computation/repository/private_computation_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions fbpcs/private_computation/service/mpc/entity/mpc_game_config.py
Original file line number Diff line number Diff line change
@@ -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]
7 changes: 5 additions & 2 deletions fbpcs/private_computation/service/mpc/mpc_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion fbpcs/private_computation/test/service/mpc/test_mpc_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
Expand Down

0 comments on commit 2a47a09

Please sign in to comment.