-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mpc_instance entity/repository migrate from fbpcp to fbpcs (#1910)
Summary: Pull Request resolved: #1910 ## 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_instance.py` from fbpcp to fbpcs - hg copy `repository/mpc_instance` as as well - change import to fbpcs Reviewed By: YigeZhu Differential Revision: D41204111 fbshipit-source-id: 899c98e3f4fbb5321848fe936c3248931fe8ed50
- Loading branch information
1 parent
2a47a09
commit d7114ca
Showing
29 changed files
with
160 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
fbpcs/private_computation/service/mpc/entity/mpc_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/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 enum import Enum | ||
from typing import Any, Dict, List, Optional | ||
|
||
from fbpcp.entity.container_instance import ContainerInstance | ||
|
||
|
||
class MPCParty(Enum): | ||
SERVER = "SERVER" | ||
CLIENT = "CLIENT" | ||
|
||
|
||
class MPCInstanceStatus(Enum): | ||
UNKNOWN = "UNKNOWN" | ||
CREATED = "CREATED" | ||
STARTED = "STARTED" | ||
COMPLETED = "COMPLETED" | ||
FAILED = "FAILED" | ||
CANCELED = "CANCELED" | ||
|
||
|
||
@dataclass | ||
class MPCInstance: | ||
instance_id: str | ||
game_name: str | ||
mpc_party: MPCParty | ||
num_workers: int | ||
server_ips: Optional[List[str]] | ||
containers: List[ContainerInstance] | ||
status: MPCInstanceStatus | ||
game_args: Optional[List[Dict[str, Any]]] | ||
server_uris: Optional[List[str]] = None | ||
|
||
def get_instance_id(self) -> str: | ||
return self.instance_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
fbpcs/private_computation/service/mpc/repository/mpc_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/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_instance import MPCInstance | ||
|
||
|
||
class MPCInstanceRepository(abc.ABC): | ||
@abc.abstractmethod | ||
def create(self, instance: MPCInstance) -> None: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def read(self, instance_id: str) -> MPCInstance: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def update(self, instance: MPCInstance) -> None: | ||
pass | ||
|
||
@abc.abstractmethod | ||
def delete(self, instance_id: str) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.