Skip to content
This repository was archived by the owner on Jun 20, 2025. It is now read-only.

Commit 905c8ba

Browse files
jrodal98facebook-github-bot
authored andcommitted
anonymizer stage flow (#2202)
Summary: Pull Request resolved: #2202 ## What - Create a stageflow for running the anonymizer game ## Why - As part of the Q1 PD "orchestration of workflows" prototype, I am creating some skeletons inside of PCS such that the PCF team would be able to integrate with PCS with minimal assistance from the PCA and/or PSI teams (assuming MPC infra is used in the future) - PD "orchestration of workflows" doc: https://docs.google.com/document/d/1Nnn3rrXB1PokGl8a_fhB2JulXbLyHxpZe3-fPGqJO30/edit Reviewed By: adshastri Differential Revision: D44149317 Privacy Context Container: L416713 fbshipit-source-id: 285be083d6e1555ac5ad47fdc70c0139a5f6a32f
1 parent 5cf7597 commit 905c8ba

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

fbpcs/bolt/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from fbpcs.private_computation.entity.private_computation_status import (
1414
PrivateComputationInstanceStatus,
1515
)
16+
from fbpcs.private_computation.stage_flows.private_computation_anonymizer_stage_flow import (
17+
PrivateComputationAnonymizerStageFlow,
18+
)
1619
from fbpcs.private_computation.stage_flows.private_computation_base_stage_flow import (
1720
PrivateComputationBaseStageFlow,
1821
)
@@ -33,6 +36,7 @@
3336
PrivateComputationGameType.ATTRIBUTION: PrivateComputationPCF2StageFlow,
3437
PrivateComputationGameType.LIFT: PrivateComputationStageFlow,
3538
PrivateComputationGameType.PRIVATE_ID_DFCA: PrivateComputationPrivateIdDfcaStageFlow,
39+
PrivateComputationGameType.ANONYMIZER: PrivateComputationAnonymizerStageFlow,
3640
}
3741
DEFAULT_MAX_PARALLEL_RUNS = 10
3842
DEFAULT_NUM_TRIES = 4

fbpcs/private_computation/stage_flows/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"private_computation_private_id_dfca_stage_flow",
2929
"private_computation_pid_continuous_measurement_stage_flow",
3030
"private_computation_pa_for_pd_stage_flow",
31+
"private_computation_anonymizer_stage_flow",
3132
]
3233

3334
from . import * # noqa: ignore=F403
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
from fbpcs.private_computation.entity.private_computation_status import (
8+
PrivateComputationInstanceStatus,
9+
)
10+
from fbpcs.private_computation.service.anonymizer_stage_service import (
11+
AnonymizerStageService,
12+
)
13+
from fbpcs.private_computation.service.private_computation_stage_service import (
14+
PrivateComputationStageService,
15+
PrivateComputationStageServiceArgs,
16+
)
17+
from fbpcs.private_computation.stage_flows.private_computation_base_stage_flow import (
18+
PrivateComputationBaseStageFlow,
19+
PrivateComputationStageFlowData,
20+
)
21+
22+
23+
class PrivateComputationAnonymizerStageFlow(PrivateComputationBaseStageFlow):
24+
"""
25+
This enum lists all of the supported stage types and maps to their possible statuses.
26+
It also provides methods to get information about the next or previous stage.
27+
28+
This should only be used to run the anonymizer with routine advertisers
29+
"""
30+
31+
# Specifies the order of the stages. Don't change this unless you know what you are doing.
32+
# pyre-fixme[15]: `_order_` overrides attribute defined in `Enum` inconsistently.
33+
_order_ = "CREATED ANONYMIZER"
34+
# Regarding typing fixme above, Pyre appears to be wrong on this one. _order_ only appears in the EnumMeta metaclass __new__ method
35+
# and is not actually added as a variable on the enum class. I think this is why pyre gets confused.
36+
37+
CREATED = PrivateComputationStageFlowData(
38+
initialized_status=PrivateComputationInstanceStatus.CREATION_INITIALIZED,
39+
started_status=PrivateComputationInstanceStatus.CREATION_STARTED,
40+
completed_status=PrivateComputationInstanceStatus.CREATED,
41+
failed_status=PrivateComputationInstanceStatus.CREATION_FAILED,
42+
is_joint_stage=False,
43+
)
44+
ANONYMIZER = PrivateComputationStageFlowData(
45+
initialized_status=PrivateComputationInstanceStatus.ANONYMIZER_INITIALIZED,
46+
started_status=PrivateComputationInstanceStatus.ANONYMIZER_STARTED,
47+
completed_status=PrivateComputationInstanceStatus.ANONYMIZER_COMPLETED,
48+
failed_status=PrivateComputationInstanceStatus.ANONYMIZER_FAILED,
49+
is_joint_stage=True,
50+
)
51+
52+
def get_stage_service(
53+
self, args: PrivateComputationStageServiceArgs
54+
) -> PrivateComputationStageService:
55+
"""
56+
Maps PrivateComputationStageFlow instances to StageService instances
57+
58+
Arguments:
59+
args: Common arguments initialized in PrivateComputationService that are consumed by stage services
60+
61+
Returns:
62+
An instantiated StageService object corresponding to the StageFlow enum member caller.
63+
64+
Raises:
65+
NotImplementedError: The subclass doesn't implement a stage service for a given StageFlow enum member
66+
"""
67+
if self is self.ANONYMIZER:
68+
return AnonymizerStageService(
69+
args.onedocker_svc,
70+
args.onedocker_binary_config_map,
71+
)
72+
else:
73+
return self.get_default_stage_service(args)

0 commit comments

Comments
 (0)