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

Commit 5529356

Browse files
dluofacebook-github-bot
authored andcommitted
upgrade fbpcs to per-target typechecking
Summary: We're migrating fbcode to use Pyre's new architecture. To type check your project: ``` arc pyre check //fbpcs/... ``` You can enable this by adding `typing = True` to individual buck targets OR ``` # in a PACKAGE file load("fbcode_macros//build_defs:python.bzl", "python") python.set_typing(True) ``` will type check all buck targets nested underneath. This diff removes the configuration and replaces it with our new buck based architecture and silences any resulting errors. The test failure is preexisting. Reviewed By: joe1234wu Differential Revision: D64347224
1 parent aee6278 commit 5529356

20 files changed

Lines changed: 221 additions & 3 deletions

fbpcs/bolt/bolt_runner.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ async def _run_hooks(
341341
{stage, None}, {role, None}, {when, None}, {event, None}
342342
)
343343
for hook in job.hooks.get(
344-
BoltHookKey(event=e, when=w, stage=s.name if s else s, role=r), []
344+
# pyre-fixme[6]: For 3rd argument expected `Optional[str]` but got
345+
# `Union[None, PrivateComputationBaseStageFlow, str]`.
346+
BoltHookKey(event=e, when=w, stage=s.name if s else s, role=r),
347+
[],
345348
)
346349
)
347350

fbpcs/bolt/read_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
from fbpcs.bolt.bolt_runner import BoltRunner
1515
from fbpcs.bolt.constants import DEFAULT_POLL_INTERVAL_SEC
1616
from fbpcs.bolt.oss_bolt_pcs import BoltPCSClient, BoltPCSCreateInstanceArgs
17+
18+
# pyre-fixme[21]: Could not find module
19+
# `fbpcs.private_computation_cli.private_computation_service_wrapper`.
1720
from fbpcs.private_computation_cli.private_computation_service_wrapper import (
1821
build_private_computation_service,
1922
)
@@ -45,6 +48,7 @@ def create_bolt_runner(
4548
runner_config["partner_client_config"]
4649
)
4750
publisher_client = BoltPCSClient(
51+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation_cli`.
4852
build_private_computation_service(
4953
publisher_client_config["private_computation"],
5054
publisher_client_config["mpc"],
@@ -54,6 +58,7 @@ def create_bolt_runner(
5458
)
5559
)
5660
partner_client = BoltPCSClient(
61+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation_cli`.
5762
build_private_computation_service(
5863
partner_client_config["private_computation"],
5964
partner_client_config["mpc"],

fbpcs/common/feature/pcs_feature_gate_utils.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,90 @@
77
# pyre-strict
88
from typing import Optional, Set, Type
99

10+
# pyre-fixme[21]: Could not find module `fbpcs.private_computation.entity.infra_config`.
1011
from fbpcs.private_computation.entity.infra_config import PrivateComputationGameType
12+
13+
# pyre-fixme[21]: Could not find module `fbpcs.private_computation.entity.pcs_feature`.
1114
from fbpcs.private_computation.entity.pcs_feature import PCSFeature
15+
16+
# pyre-fixme[21]: Could not find module
17+
# `fbpcs.private_computation.stage_flows.private_computation_base_stage_flow`.
1218
from fbpcs.private_computation.stage_flows.private_computation_base_stage_flow import (
1319
PrivateComputationBaseStageFlow,
1420
)
21+
22+
# pyre-fixme[21]: Could not find module `fbpcs.private_computation.stage_flows.privat...
1523
from fbpcs.private_computation.stage_flows.private_computation_mr_pid_pcf2_lift_stage_flow import (
1624
PrivateComputationMrPidPCF2LiftStageFlow,
1725
)
26+
27+
# pyre-fixme[21]: Could not find module
28+
# `fbpcs.private_computation.stage_flows.private_computation_mr_stage_flow`.
1829
from fbpcs.private_computation.stage_flows.private_computation_mr_stage_flow import (
1930
PrivateComputationMRStageFlow,
2031
)
32+
33+
# pyre-fixme[21]: Could not find module
34+
# `fbpcs.private_computation.stage_flows.private_computation_pcf2_lift_udp_stage_flow`.
2135
from fbpcs.private_computation.stage_flows.private_computation_pcf2_lift_udp_stage_flow import (
2236
PrivateComputationPCF2LiftUDPStageFlow,
2337
)
38+
39+
# pyre-fixme[21]: Could not find module
40+
# `fbpcs.private_computation.stage_flows.private_computation_pcf2_stage_flow`.
2441
from fbpcs.private_computation.stage_flows.private_computation_pcf2_stage_flow import (
2542
PrivateComputationPCF2StageFlow,
2643
)
44+
45+
# pyre-fixme[21]: Could not find module
46+
# `fbpcs.private_computation.stage_flows.private_computation_stage_flow`.
2747
from fbpcs.private_computation.stage_flows.private_computation_stage_flow import (
2848
PrivateComputationStageFlow,
2949
)
3050
from fbpcs.utils.optional import unwrap_or_default
3151

3252

3353
def get_stage_flow(
54+
# pyre-fixme[11]: Annotation `PrivateComputationGameType` is not defined as a type.
3455
game_type: PrivateComputationGameType,
56+
# pyre-fixme[11]: Annotation `PCSFeature` is not defined as a type.
3557
pcs_feature_enums: Set[PCSFeature],
58+
# pyre-fixme[11]: Annotation `PrivateComputationBaseStageFlow` is not defined as
59+
# a type.
3660
stage_flow_cls: Optional[Type[PrivateComputationBaseStageFlow]] = None,
3761
) -> Type[PrivateComputationBaseStageFlow]:
3862
selected_stage_flow_cls = unwrap_or_default(
3963
optional=stage_flow_cls,
4064
default=(
65+
# pyre-fixme[16]: Module `private_computation` has no attribute
66+
# `stage_flows`.
4167
PrivateComputationPCF2StageFlow
68+
# pyre-fixme[16]: Module `entity` has no attribute `infra_config`.
4269
if game_type is PrivateComputationGameType.ATTRIBUTION
70+
# pyre-fixme[16]: Module `private_computation` has no attribute
71+
# `stage_flows`.
4372
else PrivateComputationStageFlow
4473
),
4574
)
4675

4776
# warning, enabled feature gating will override stage flow, Please contact PSI team to have a similar adoption
4877
if PCSFeature.PRIVATE_ATTRIBUTION_MR_PID in pcs_feature_enums:
4978
selected_stage_flow_cls = (
79+
# pyre-fixme[16]: Module `private_computation` has no attribute
80+
# `stage_flows`.
5081
PrivateComputationMRStageFlow
82+
# pyre-fixme[16]: Module `entity` has no attribute `infra_config`.
5183
if game_type is PrivateComputationGameType.ATTRIBUTION
84+
# pyre-fixme[16]: Module `private_computation` has no attribute
85+
# `stage_flows`.
5286
else PrivateComputationMrPidPCF2LiftStageFlow
5387
)
5488
if PCSFeature.PRIVATE_LIFT_UNIFIED_DATA_PROCESS in pcs_feature_enums:
5589
selected_stage_flow_cls = (
90+
# pyre-fixme[16]: Module `private_computation` has no attribute
91+
# `stage_flows`.
5692
PrivateComputationPCF2LiftUDPStageFlow
93+
# pyre-fixme[16]: Module `entity` has no attribute `infra_config`.
5794
if game_type is PrivateComputationGameType.LIFT
5895
else selected_stage_flow_cls
5996
)

fbpcs/data_processing/pid_preparer/preparer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
import pathlib
1212
from typing import Optional
1313

14+
# pyre-fixme[21]: Could not find module `fbpcp.entity.container_instance`.
1415
from fbpcp.entity.container_instance import ContainerInstance
16+
17+
# pyre-fixme[21]: Could not find module `fbpcp.service.onedocker`.
1518
from fbpcp.service.onedocker import OneDockerService
19+
20+
# pyre-fixme[21]: Could not find module `fbpcp.service.storage`.
1621
from fbpcp.service.storage import StorageService
1722

1823

@@ -24,6 +29,7 @@ def prepare(
2429
output_path: str,
2530
log_path: Optional[pathlib.Path] = None,
2631
log_level: int = logging.INFO,
32+
# pyre-fixme[11]: Annotation `StorageService` is not defined as a type.
2733
storage_svc: Optional[StorageService] = None,
2834
) -> None:
2935
pass
@@ -34,10 +40,12 @@ def prepare_on_container(
3440
input_path: str,
3541
output_path: str,
3642
# TODO: Support custom log path
43+
# pyre-fixme[11]: Annotation `OneDockerService` is not defined as a type.
3744
onedocker_svc: OneDockerService,
3845
binary_version: str,
3946
tmp_directory: str = "/tmp/",
4047
wait_for_container: bool = True,
48+
# pyre-fixme[11]: Annotation `ContainerInstance` is not defined as a type.
4149
) -> ContainerInstance:
4250
pass
4351

fbpcs/data_processing/pid_preparer/union_pid_preparer_cpp.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,27 @@
1515
import tempfile
1616
from typing import Dict, Optional
1717

18+
# pyre-fixme[21]: Could not find module `fbpcp.entity.container_instance`.
1819
from fbpcp.entity.container_instance import ContainerInstance, ContainerInstanceStatus
20+
21+
# pyre-fixme[21]: Could not find module `fbpcp.error.pcp`.
1922
from fbpcp.error.pcp import ThrottlingError
23+
24+
# pyre-fixme[21]: Could not find module `fbpcp.service.onedocker`.
2025
from fbpcp.service.onedocker import OneDockerService
26+
27+
# pyre-fixme[21]: Could not find module `fbpcp.service.storage`.
2128
from fbpcp.service.storage import PathType, StorageService
2229

30+
# pyre-fixme[21]: Could not find module `fbpcs.common.service.retry_handler`.
2331
from fbpcs.common.service.retry_handler import RetryHandler
2432
from fbpcs.data_processing.pid_preparer.preparer import UnionPIDDataPreparerService
33+
34+
# pyre-fixme[21]: Could not find module `fbpcs.onedocker_binary_names`.
2535
from fbpcs.onedocker_binary_names import OneDockerBinaryNames
36+
37+
# pyre-fixme[21]: Could not find module
38+
# `fbpcs.private_computation.service.run_binary_base_service`.
2639
from fbpcs.private_computation.service.run_binary_base_service import (
2740
RunBinaryBaseService,
2841
)
@@ -43,6 +56,7 @@ def prepare(
4356
output_path: str,
4457
log_path: Optional[pathlib.Path] = None,
4558
log_level: int = logging.INFO,
59+
# pyre-fixme[11]: Annotation `StorageService` is not defined as a type.
4660
storage_svc: Optional[StorageService] = None,
4761
) -> None:
4862
if log_path is not None:
@@ -95,13 +109,15 @@ def prepare_on_container(
95109
self,
96110
input_path: str,
97111
output_path: str,
112+
# pyre-fixme[11]: Annotation `OneDockerService` is not defined as a type.
98113
onedocker_svc: OneDockerService,
99114
binary_version: str,
100115
max_column_count: int = 1,
101116
tmp_directory: str = "/tmp/",
102117
container_timeout: Optional[int] = None,
103118
wait_for_container: bool = True,
104119
env_vars: Optional[Dict[str, str]] = None,
120+
# pyre-fixme[11]: Annotation `ContainerInstance` is not defined as a type.
105121
) -> ContainerInstance:
106122
return asyncio.run(
107123
self.prepare_on_container_async(
@@ -145,6 +161,7 @@ async def prepare_on_container_async(
145161

146162
current_retry = 0
147163
status = ContainerInstanceStatus.UNKNOWN
164+
# pyre-fixme[16]: Module `fbpcs` has no attribute `onedocker_binary_names`.
148165
exe = OneDockerBinaryNames.UNION_PID_PREPARER.value
149166
container = None
150167
while status is not ContainerInstanceStatus.COMPLETED:
@@ -162,6 +179,7 @@ async def prepare_on_container_async(
162179
env_vars=env_vars,
163180
)
164181

182+
# pyre-fixme[16]: Module `fbpcs` has no attribute `common`.
165183
with RetryHandler(
166184
ThrottlingError, logger=logger, backoff_seconds=30
167185
) as retry_handler:
@@ -175,6 +193,8 @@ async def prepare_on_container_async(
175193
# Busy wait until the container is finished
176194
if wait_for_container:
177195
container = (
196+
# pyre-fixme[16]: Module `fbpcs` has no attribute
197+
# `private_computation`.
178198
await RunBinaryBaseService.wait_for_containers_async(
179199
onedocker_svc, [container]
180200
)

fbpcs/data_processing/service/id_spine_combiner.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,17 @@
88

99
from typing import List, Optional
1010

11+
# pyre-fixme[21]: Could not find module `fbpcp.util.arg_builder`.
1112
from fbpcp.util.arg_builder import build_cmd_args
1213

14+
# pyre-fixme[21]: Could not find module `fbpcs.private_computation.service.constants`.
1315
from fbpcs.private_computation.service.constants import DEFAULT_SORT_STRATEGY
16+
17+
# pyre-fixme[21]: Could not find module `fbpcs.private_computation.service.pid_utils`.
1418
from fbpcs.private_computation.service.pid_utils import get_sharded_filepath
19+
20+
# pyre-fixme[21]: Could not find module
21+
# `fbpcs.private_computation.service.run_binary_base_service`.
1522
from fbpcs.private_computation.service.run_binary_base_service import (
1623
RunBinaryBaseService,
1724
)
@@ -21,6 +28,7 @@
2128
DEFAULT_CONTAINER_TIMEOUT_IN_SEC = 10800
2229

2330

31+
# pyre-fixme[11]: Annotation `RunBinaryBaseService` is not defined as a type.
2432
class IdSpineCombinerService(RunBinaryBaseService):
2533
@staticmethod
2634
def build_args(
@@ -31,6 +39,7 @@ def build_args(
3139
tmp_directory: str,
3240
protocol_type: str,
3341
max_id_column_cnt: int = 1,
42+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation`.
3443
sort_strategy: str = DEFAULT_SORT_STRATEGY,
3544
# TODO T106159008: padding_size and run_name are only temporarily optional
3645
# because Lift does not use them. It should and will be required to use them.
@@ -46,8 +55,11 @@ def build_args(
4655
# own ThreadPoolExecutor here and instead use async primitives
4756
cmd_args_list = []
4857
for shard in range(num_shards):
58+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation`.
4959
next_spine_path = get_sharded_filepath(spine_path, shard)
60+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation`.
5061
next_data_path = get_sharded_filepath(data_path, shard)
62+
# pyre-fixme[16]: Module `fbpcs` has no attribute `private_computation`.
5163
next_output_path = get_sharded_filepath(output_path, shard)
5264
cmd_args = build_cmd_args(
5365
spine_path=next_spine_path,

fbpcs/data_processing/service/pid_run_protocol_binary_service.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
from fbpcs.onedocker_binary_names import OneDockerBinaryNames
1313

1414
from fbpcs.pid.entity.pid_instance import PIDProtocol
15+
16+
# pyre-fixme[21]: Could not find module
17+
# `fbpcs.private_computation.entity.private_computation_instance`.
1518
from fbpcs.private_computation.entity.private_computation_instance import (
1619
PrivateComputationRole,
1720
)
@@ -35,6 +38,7 @@ def build_args(
3538
output_path: str,
3639
port: int,
3740
tls_args: TlsArgs,
41+
# pyre-fixme[11]: Annotation `PrivateComputationRole` is not defined as a type.
3842
pc_role: PrivateComputationRole,
3943
use_row_numbers: bool = False,
4044
server_endpoint: Optional[str] = None,
@@ -66,12 +70,18 @@ def build_args(
6670
if use_row_numbers:
6771
cmd_ls.append("--use-row-numbers")
6872

73+
# pyre-fixme[16]: Module `entity` has no attribute
74+
# `private_computation_instance`.
6975
if tls_args.ca_cert_path and pc_role is PrivateComputationRole.PARTNER:
7076
cmd_ls.append(f"--tls-ca {tls_args.ca_cert_path}")
7177

78+
# pyre-fixme[16]: Module `entity` has no attribute
79+
# `private_computation_instance`.
7280
if tls_args.server_cert_path and pc_role is PrivateComputationRole.PUBLISHER:
7381
cmd_ls.append(f"--tls-cert {tls_args.server_cert_path}")
7482

83+
# pyre-fixme[16]: Module `entity` has no attribute
84+
# `private_computation_instance`.
7585
if tls_args.private_key_path and pc_role is PrivateComputationRole.PUBLISHER:
7686
cmd_ls.append(f"--tls-key {tls_args.private_key_path}")
7787

@@ -82,10 +92,14 @@ def build_args(
8292

8393
@staticmethod
8494
def get_binary_name(protocol: PIDProtocol, pc_role: PrivateComputationRole) -> str:
95+
# pyre-fixme[16]: Module `entity` has no attribute
96+
# `private_computation_instance`.
8597
if pc_role is PrivateComputationRole.PUBLISHER:
8698
binary_name = OneDockerBinaryNames.PID_SERVER.value
8799
if protocol is PIDProtocol.UNION_PID_MULTIKEY:
88100
binary_name = OneDockerBinaryNames.PID_MULTI_KEY_SERVER.value
101+
# pyre-fixme[16]: Module `entity` has no attribute
102+
# `private_computation_instance`.
89103
elif pc_role is PrivateComputationRole.PARTNER:
90104
binary_name = OneDockerBinaryNames.PID_CLIENT.value
91105
if protocol is PIDProtocol.UNION_PID_MULTIKEY:

fbpcs/infra/certificate/pc_instance_ca_certificate_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from typing import Optional
1010

1111
from fbpcs.infra.certificate.certificate_provider import CertificateProvider
12+
13+
# pyre-fixme[21]: Could not find module
14+
# `fbpcs.private_computation.entity.private_computation_instance`.
1215
from fbpcs.private_computation.entity.private_computation_instance import (
1316
PrivateComputationInstance,
1417
)
@@ -20,7 +23,9 @@ class PCInstanceCaCertificateProvider(CertificateProvider):
2023
from PC instance repo.
2124
"""
2225

26+
# pyre-fixme[11]: Annotation `PrivateComputationInstance` is not defined as a type.
2327
def __init__(self, pc_instance: PrivateComputationInstance) -> None:
28+
# pyre-fixme[4]: Attribute must be annotated.
2429
self.pc_instance = pc_instance
2530

2631
def get_certificate(self) -> Optional[str]:

fbpcs/infra/certificate/pc_instance_server_certificate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from typing import Optional
1010

1111
from fbpcs.infra.certificate.certificate_provider import CertificateProvider
12+
13+
# pyre-fixme[21]: Could not find module
14+
# `fbpcs.private_computation.entity.private_computation_instance`.
1215
from fbpcs.private_computation.entity.private_computation_instance import (
1316
PrivateComputationInstance,
1417
)
@@ -20,7 +23,9 @@ class PCInstanceServerCertificateProvider(CertificateProvider):
2023
from PC instance repo.
2124
"""
2225

26+
# pyre-fixme[11]: Annotation `PrivateComputationInstance` is not defined as a type.
2327
def __init__(self, pc_instance: PrivateComputationInstance) -> None:
28+
# pyre-fixme[4]: Attribute must be annotated.
2429
self.pc_instance = pc_instance
2530

2631
def get_certificate(self) -> Optional[str]:

fbpcs/pc_pre_validation/tests/pc_pre_validation_cli_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def test_parsing_all_args(
9191
expected_access_key_id = "access_key_id2"
9292
expected_access_key_data = "access_key_data3"
9393
expected_binary_version = "binary_version"
94+
# pyre-fixme[9]: expected_pc_computation_role has type
95+
# `PrivateComputationRole`; used as `str`.
9496
expected_pc_computation_role: PrivateComputationRole = (
9597
PrivateComputationRole.PARTNER.name
9698
)

0 commit comments

Comments
 (0)