Skip to content

Commit

Permalink
Adding DeprecationWarning for mpc services in fbpcp (facebookresearch…
Browse files Browse the repository at this point in the history
…#464)

Summary:
Pull Request resolved: facebookresearch#464

## Why
welcome_to_meta_road_deprecated

Differential Revision: D41228073

fbshipit-source-id: 79b4b69cb2e25b37366f901f96a690a316d5cb0e
  • Loading branch information
joe1234wu authored and facebook-github-bot committed Nov 14, 2022
1 parent 36dd167 commit 1a717da
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 7 deletions.
8 changes: 8 additions & 0 deletions fbpcp/entity/mpc_game_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

from dataclasses import dataclass
from typing import List
from warnings import warn


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


@dataclass
Expand Down
8 changes: 8 additions & 0 deletions fbpcp/entity/mpc_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional
from warnings import warn

from fbpcp.entity.container_instance import ContainerInstance


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


class MPCParty(Enum):
SERVER = "SERVER"
CLIENT = "CLIENT"
Expand Down
8 changes: 8 additions & 0 deletions fbpcp/repository/mpc_game_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
# pyre-strict

import abc
from warnings import warn

from fbpcp.entity.mpc_game_config import MPCGameConfig


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


class MPCGameRepository(abc.ABC):
@abc.abstractmethod
def get_game(self, name: str) -> MPCGameConfig:
Expand Down
8 changes: 8 additions & 0 deletions fbpcp/repository/mpc_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
# pyre-strict

import abc
from warnings import warn

from fbpcp.entity.mpc_instance import MPCInstance


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


class MPCInstanceRepository(abc.ABC):
@abc.abstractmethod
def create(self, instance: MPCInstance) -> None:
Expand Down
16 changes: 16 additions & 0 deletions fbpcp/service/mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import logging
from typing import Any, Dict, List, Optional

from warnings import warn

from fbpcp.entity.certificate_request import CertificateRequest

from fbpcp.entity.container_instance import ContainerInstance, ContainerInstanceStatus
Expand All @@ -24,6 +26,13 @@
DEFAULT_BINARY_VERSION = "latest"


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


class MPCService:
"""MPCService is responsible for distributing a larger MPC game to multiple
MPC workers
Expand All @@ -43,6 +52,13 @@ def __init__(
task_definition -- containers task definition
mpc_game_svc -- service to generate package name and game arguments.
"""

warn(
f"{self.__class__.__name__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)

if container_svc is None or instance_repository is None or mpc_game_svc is None:
raise ValueError(
f"Dependency is missing. container_svc={container_svc}, mpc_game_svc={mpc_game_svc}, "
Expand Down
13 changes: 13 additions & 0 deletions fbpcp/service/mpc_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import logging
from typing import Any, Dict, Optional, Tuple
from warnings import warn

from fbpcp.entity.mpc_game_config import MPCGameConfig
from fbpcp.entity.mpc_instance import MPCParty
Expand All @@ -18,8 +19,20 @@
LIFT_AGGREGATOR_GAME_NAME = "aggregator"


warn(
f"{__file__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)


class MPCGameService:
def __init__(self, mpc_game_repository: MPCGameRepository) -> None:
warn(
f"{self.__class__.__name__} has been moved to fbpcs repo. Please use fbpcs/private_computation/service/mpc/ instead.",
DeprecationWarning,
stacklevel=2,
)
self.logger: logging.Logger = logging.getLogger(__name__)
self.mpc_game_repository: MPCGameRepository = mpc_game_repository

Expand Down
15 changes: 8 additions & 7 deletions tests/service/test_mpc_do_not_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# This test file is a short-term to freeze the file change during migration.
# After migration completed, we shall delete this ut test
# TODO: T137598681 clean up FBPCS mpc related files after migration complete
# NOTE: please make further change on fbcode/fbpcs/private_computation/service/mpc/
#############################################################################
import hashlib
import inspect
Expand All @@ -27,35 +28,35 @@
NO_CHANGE_FILES = (
{
"cls": MPCService,
"file_md5": "35dbe2a73b1016d6d631b03abc612929",
"file_md5": "6496cdbc9baffc3d853932bb1eef0cc4",
},
{
"cls": TestMPCService,
"file_md5": "6a1c7a74f28d164e113b68dbcab29962",
},
{
"cls": MPCGameService,
"file_md5": "36a2142e36759e382855e970f12c7403",
"file_md5": "2adfdc845a3c81e7df92c728eb347d97",
},
{
"cls": TestMPCGameService,
"file_md5": "e1e4517471ff5630a7a7dc5db645ed5f",
},
{
"cls": MPCGameConfig,
"file_md5": "39326c1de0bb8795313ce84560d25c97",
"file_md5": "fabbe10df0d2d25664536329be609418",
},
{
"cls": MPCGameRepository,
"file_md5": "d2d09421e3ab8c612a2208d7a0269996",
"file_md5": "f78b873cb10e4c9c41ec37fd95a07cd1",
},
{
"cls": MPCInstance,
"file_md5": "4a52cc896d438cb8900649265eb46b71",
"file_md5": "990f5ee7290539555c6a488967d86d2b",
},
{
"cls": MPCInstanceRepository,
"file_md5": "251b27ef762c7421a43fe1e8062ce86b",
"file_md5": "32b1d8c9e67bb8bc77804352d10a2137",
},
)

Expand All @@ -68,7 +69,7 @@ def test_mpc_service_no_change(self):
self.assertEqual(
no_change_file["file_md5"],
self.gen_file_md5(file_name),
msg=f"assertion on file: {file_name}",
msg=f"assertion on file: {file_name}. you should change mpc in fbcode/fbpcs/private_computation/service/mpc/",
)

def gen_file_md5(self, file_name):
Expand Down

0 comments on commit 1a717da

Please sign in to comment.