Skip to content

Commit 3a5f18e

Browse files
casteryhfacebook-github-bot
authored andcommitted
fix controller endpoint
Summary: Monarch is enforcing the following check. This diff is a fix. ValueError: <class 'torchstore.controller.Controller'> mixes both async and sync endpoints.Synchronous endpoints cannot be mixed with async endpoints because they can cause the asyncio loop to deadlock if they wait.sync: ['get_controller_strategy', 'keys', 'locate_volumes', 'notify_delete', 'notify_put'] async: ['init', 'teardown'] Differential Revision: D86155590
1 parent 9dd276c commit 3a5f18e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

torchstore/controller.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ async def init(
120120
self.is_initialized = True
121121

122122
@endpoint
123-
def get_controller_strategy(self) -> TorchStoreStrategy:
123+
async def get_controller_strategy(self) -> TorchStoreStrategy:
124124
self.assert_initialized()
125125
assert self.strategy is not None, "Strategy is not set"
126126
return self.strategy
127127

128128
@endpoint
129-
def locate_volumes(
129+
async def locate_volumes(
130130
self,
131131
key: str,
132132
) -> Dict[str, StorageInfo]:
@@ -178,7 +178,7 @@ def locate_volumes(
178178
return volume_map
179179

180180
@endpoint
181-
def notify_put(self, key: str, request: Request, storage_volume_id: str) -> None:
181+
async def notify_put(self, key: str, request: Request, storage_volume_id: str) -> None:
182182
"""Notify the controller that data has been stored in a storage volume.
183183
184184
This should called after a successful put operation to
@@ -220,13 +220,13 @@ async def teardown(self) -> None:
220220
self.num_storage_volumes = None
221221

222222
@endpoint
223-
def keys(self, prefix=None) -> List[str]:
223+
async def keys(self, prefix=None) -> List[str]:
224224
if prefix is None:
225225
return list(self.keys_to_storage_volumes.keys())
226226
return self.keys_to_storage_volumes.keys().filter_by_prefix(prefix)
227227

228228
@endpoint
229-
def notify_delete(self, key: str, storage_volume_id: str) -> None:
229+
async def notify_delete(self, key: str, storage_volume_id: str) -> None:
230230
"""
231231
Notify the controller that deletion of data is initiated in a storage volume.
232232

0 commit comments

Comments
 (0)