Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs in retrying of operations #58

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datalab/datalab_session/data_operations/data_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def perform_operation(self):

def generate_cache_key(self) -> str:
""" Generate a unique cache key hashed from the input_data and operation name """
string_key = f'{self.name()}_{json.dumps(sorted(self.input_data.items()))}'
string_key = f'{self.name()}_{json.dumps(sorted(self.input_data.items()), sort_keys=True)}'
return hashlib.sha256(string_key.encode('utf-8')).hexdigest()

def set_status(self, status: str):
Expand Down
28 changes: 16 additions & 12 deletions datalab/datalab_session/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ def should_retry(retries_so_far, exception):

@dramatiq.actor(retry_when=should_retry)
def execute_data_operation(data_operation_name: str, input_data: dict):
operation_class = available_operations().get(data_operation_name)
if operation_class is None:
raise NotImplementedError("Operation not implemented!")
else:
try:
operation_class(input_data).operate()
except ClientAlertException as error:
log.error(f"Client Error executing {data_operation_name}: {error}")
operation_class(input_data).set_failed(str(error))
except Exception as error:
log.exception(error)
operation_class(input_data).set_failed("An unknown error ocurred, contact developers if this persists.")
try:
operation_class = available_operations().get(data_operation_name)
if operation_class is None:
raise NotImplementedError("Operation not implemented!")
else:
try:
operation_class(input_data).operate()
except ClientAlertException as error:
log.error(f"Client Error executing {data_operation_name}: {error}")
operation_class(input_data).set_failed(str(error))
except Exception as error:
log.exception(error)
operation_class(input_data).set_failed("An unknown error ocurred, contact developers if this persists.")
except dramatiq.middleware.TimeLimitExceeded as error:
log.exception(error)
available_operations().get(data_operation_name)(input_data).set_failed("The operation timed out, contact developers if this persists.")
Binary file not shown.