Skip to content

Commit 4b5c5c4

Browse files
Sunnie912facebook-github-bot
authored andcommitted
Transform fbcode/eden
Summary: This diff changes the struct initialization method from using positional arguments to keyword arguments, as indicated in the file title. Background: In thrift-python, user must use keyword arguments to initialize both mutable and immutable objects, meaning positional arguments are not allowed for this purpose. This behavior differs from py-deprecated, which permits both keyword and positional arguments for object initialization. To facilitate the migration from py-deprecated, we developed a tool that identifies all instances of struct initialization using positional arguments and converts them to keyword arguments. This will reduce the workload for users during the migration, and this diff is one of the outputs by using the tool. Reviewed By: dtolnay Differential Revision: D75805486 fbshipit-source-id: d99d6677c79ed3205c8741e1b401e80556a6d6d8
1 parent 0441ac0 commit 4b5c5c4

6 files changed

Lines changed: 44 additions & 22 deletions

File tree

eden/fs/cli/debug.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ def run(self, args: argparse.Namespace) -> int:
270270
with instance.get_thrift_client_legacy() as client:
271271
resp = client.debugGetTree(
272272
DebugGetScmTreeRequest(
273-
MountId(bytes(checkout.path)),
274-
tree_id,
275-
origin_flags,
273+
mountId=MountId(mountPoint=bytes(checkout.path)),
274+
id=tree_id,
275+
origins=origin_flags,
276276
)
277277
)
278278
if args.all:
@@ -566,9 +566,9 @@ def run(self, args: argparse.Namespace) -> int:
566566
with instance.get_thrift_client_legacy() as client:
567567
data = client.debugGetBlob(
568568
DebugGetScmBlobRequest(
569-
MountId(bytes(checkout.path)),
570-
blob_id,
571-
origin_flags,
569+
mountId=MountId(mountPoint=bytes(checkout.path)),
570+
id=blob_id,
571+
origins=origin_flags,
572572
)
573573
)
574574
if args.all:
@@ -617,9 +617,9 @@ def run(self, args: argparse.Namespace) -> int:
617617
with instance.get_thrift_client_legacy() as client:
618618
info = client.debugGetBlobMetadata(
619619
DebugGetBlobMetadataRequest(
620-
MountId(bytes(checkout.path)),
621-
blob_id,
622-
origin_flags,
620+
mountId=MountId(mountPoint=bytes(checkout.path)),
621+
id=blob_id,
622+
origins=origin_flags,
623623
)
624624
)
625625

@@ -646,7 +646,7 @@ def check_blob_and_size_match(
646646
try:
647647
response = client.debugGetBlob(
648648
DebugGetScmBlobRequest(
649-
mountId=MountId(bytes(checkout)),
649+
mountId=MountId(mountPoint=bytes(checkout)),
650650
id=identifying_hash,
651651
origins=DataFetchOrigin.LOCAL_BACKING_STORE, # We don't want to cause any network fetches.
652652
)
@@ -664,9 +664,9 @@ def check_blob_and_size_match(
664664
blobmeta = (
665665
client.debugGetBlobMetadata(
666666
DebugGetBlobMetadataRequest(
667-
MountId(bytes(checkout)),
668-
identifying_hash,
669-
DataFetchOrigin.DISK_CACHE,
667+
mountId=MountId(mountPoint=bytes(checkout)),
668+
id=identifying_hash,
669+
origins=DataFetchOrigin.DISK_CACHE,
670670
)
671671
)
672672
.metadatas[0]

eden/fs/cli/top.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,15 @@ def __init__(self, pid: int, cmd: bytes, mount: bytes) -> None:
10441044
self.pid = pid
10451045
self.cmd = format_cmd(cmd)
10461046
self.mount = format_mount(mount)
1047-
self.access_counts = AccessCounts(0, 0, 0, 0, 0, 0, 0)
1047+
self.access_counts = AccessCounts(
1048+
fsChannelTotal=0,
1049+
fsChannelReads=0,
1050+
fsChannelWrites=0,
1051+
fsChannelBackingStoreImports=0,
1052+
fsChannelDurationNs=0,
1053+
fsChannelMemoryCacheImports=0,
1054+
fsChannelDiskCacheImports=0,
1055+
)
10481056
self.fuseFetch = 0
10491057
self.last_access = time.monotonic()
10501058
self.is_running = True

eden/integration/hg/filteredhg_clone_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def test_eden_get_filter_empty(self) -> None:
148148

149149
with self.get_thrift_client_legacy() as client:
150150
result = client.getCurrentSnapshotInfo(
151-
GetCurrentSnapshotInfoRequest(MountId(os.fsencode(path)))
151+
GetCurrentSnapshotInfoRequest(
152+
mountId=MountId(mountPoint=os.fsencode(path))
153+
)
152154
)
153155
self.assertEqual("null", result.filterId)
154156

@@ -159,7 +161,9 @@ def test_eden_get_filter(self) -> None:
159161

160162
with self.get_thrift_client_legacy() as client:
161163
result = client.getCurrentSnapshotInfo(
162-
GetCurrentSnapshotInfoRequest(MountId(os.fsencode(path)))
164+
GetCurrentSnapshotInfoRequest(
165+
mountId=MountId(mountPoint=os.fsencode(path))
166+
)
163167
)
164168
self.assertNotEqual(None, result.filterId)
165169
if result.filterId is not None:
@@ -192,6 +196,8 @@ def test_eden_get_filter_nonfiltered(self) -> None:
192196

193197
with self.get_thrift_client_legacy() as client:
194198
result = client.getCurrentSnapshotInfo(
195-
GetCurrentSnapshotInfoRequest(MountId(os.fsencode(path)))
199+
GetCurrentSnapshotInfoRequest(
200+
mountId=MountId(mountPoint=os.fsencode(path))
201+
)
196202
)
197203
self.assertEqual(None, result.filterId)

eden/integration/lib/eden_server_inspector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def unload_inode_for_path(self, path: str = "") -> None:
3434
"""path: relative path to a directory under the mount."""
3535
with self.create_thrift_client() as client:
3636
client.unloadInodeForPath(
37-
os.fsencode(self._mount_point), os.fsencode(path), age=TimeSpec(0, 0)
37+
os.fsencode(self._mount_point),
38+
os.fsencode(path),
39+
age=TimeSpec(seconds=0, nanoSeconds=0),
3840
)
3941

4042
def get_inode_count(self, path: str = "") -> int:

eden/integration/lib/prjfs_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def getAllMaterialized(self, waitTime: int = 5) -> Set[Tuple[Path, int]]:
9898
self.mount_path_bytes,
9999
b"",
100100
DIS_REQUIRE_MATERIALIZED,
101-
SyncBehavior(waitTime),
101+
SyncBehavior(syncTimeoutSeconds=waitTime),
102102
)
103103

104104
for tree_inode in inodes:

eden/integration/lib/thrift_objects.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,16 @@ def buildSmallChange(
5151
if changeType == SmallChangeNotification.ADDED:
5252
assert path
5353
return ChangeNotification(
54-
SmallChangeNotification(added=Added(fileType=fileType, path=path))
54+
smallChange=SmallChangeNotification(
55+
added=Added(fileType=fileType, path=path)
56+
)
5557
)
5658
elif changeType == SmallChangeNotification.MODIFIED:
5759
assert path
5860
return ChangeNotification(
59-
SmallChangeNotification(modified=Modified(fileType=fileType, path=path))
61+
smallChange=SmallChangeNotification(
62+
modified=Modified(fileType=fileType, path=path)
63+
)
6064
)
6165
elif changeType == SmallChangeNotification.RENAMED:
6266
assert from_path
@@ -86,7 +90,9 @@ def buildSmallChange(
8690
elif changeType == SmallChangeNotification.REMOVED:
8791
assert path
8892
return ChangeNotification(
89-
SmallChangeNotification(removed=Removed(fileType=fileType, path=path))
93+
smallChange=SmallChangeNotification(
94+
removed=Removed(fileType=fileType, path=path)
95+
)
9096
)
9197
return ChangeNotification()
9298

0 commit comments

Comments
 (0)