Skip to content

Commit 99c0083

Browse files
committed
skipped _run_multi_process() and fixed run issue on wait()
1 parent d6d757c commit 99c0083

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/sagemaker/feature_store/feature_group.py

+10-13
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,8 @@ def wait(self, timeout=None):
240240
"""
241241
results = None
242242
try:
243-
self._async_result.wait(timeout=timeout)
244-
if self._async_result.ready() and self._async_result._success:
245-
results = self._async_result._value
246-
except KeyboardInterrupt as i:
243+
results = self._async_result.get(timeout=timeout)
244+
except KeyboardInterrupt or NotImplementedError as i:
247245
# terminate workers abruptly on keyboard interrupt.
248246
self._processing_pool.terminate()
249247
self._processing_pool.close()
@@ -254,20 +252,20 @@ def wait(self, timeout=None):
254252
self._processing_pool.close()
255253
self._processing_pool.clear()
256254

257-
if not results or results == NotImplementedError:
255+
if results == None:
258256
return
259-
260-
self._failed_indices = [
261-
failed_index for failed_indices in results for failed_index in failed_indices
262-
]
257+
else:
258+
self._failed_indices = [
259+
failed_index for failed_indices in results for failed_index in failed_indices
260+
]
263261

264262
if len(self._failed_indices) > 0:
265263
raise IngestionError(
266264
self._failed_indices,
267265
f"Failed to ingest some data into FeatureGroup {self.feature_group_name}",
268266
)
269267

270-
def _run_multi_process(self, data_frame: DataFrame, wait=True, timeout=None):
268+
def _run_multi_process(self, data_frame: DataFrame, wait=True, timeout=None): # Not in use
271269
"""Start the ingestion process with the specified number of processes.
272270
273271
Args:
@@ -313,7 +311,6 @@ def _run_multi_threaded(self, data_frame: DataFrame, row_offset=0, timeout=None)
313311
"""
314312
executor = ThreadPoolExecutor(max_workers=self.max_workers)
315313
batch_size = math.ceil(data_frame.shape[0] / self.max_workers)
316-
317314
futures = {}
318315
for i in range(self.max_workers):
319316
start_index = min(i * batch_size, data_frame.shape[0])
@@ -338,7 +335,6 @@ def _run_multi_threaded(self, data_frame: DataFrame, row_offset=0, timeout=None)
338335
else:
339336
logger.info("Successfully ingested row %d to %d", start, end)
340337
failed_indices += result
341-
342338
executor.shutdown(wait=False)
343339

344340
return failed_indices
@@ -352,7 +348,8 @@ def run(self, data_frame: DataFrame, wait=True, timeout=None):
352348
timeout (Union[int, float]): ``concurrent.futures.TimeoutError`` will be raised
353349
if timeout is reached.
354350
"""
355-
self._run_multi_process(data_frame=data_frame, wait=wait, timeout=timeout)
351+
#self._run_multi_process(data_frame=data_frame, wait=wait, timeout=timeout)
352+
self._run_multi_threaded(data_frame=data_frame, timeout=timeout)
356353

357354

358355
class IngestionError(Exception):

0 commit comments

Comments
 (0)