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: ensure we update job attachments action no matter what #12

Merged
merged 1 commit into from
Aug 30, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from threading import Event
from typing import Any, TYPE_CHECKING, Optional

from deadline.job_attachments.errors import AssetSyncError, AssetSyncCancelledError
from deadline.job_attachments.errors import AssetSyncCancelledError
from openjobio.sessions import ActionState, ActionStatus

from ..session import Session
Expand Down Expand Up @@ -117,42 +117,26 @@ def _on_done(
session : Session
The session that the aciton is running in
"""
action_status: ActionStatus = ActionStatus(state=ActionState.SUCCESS)
try:
future.result()
except (FutureCancelledError, AssetSyncCancelledError):
session.update_action(
action_status=ActionStatus(
state=ActionState.CANCELED,
fail_message="Canceled",
),
)
except AssetSyncError as e:
# Already logged to the session log.
# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
),
action_status = ActionStatus(
state=ActionState.CANCELED,
fail_message="Canceled",
)
except Exception as e:
session.logger.exception(e)

# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
),
action_status = ActionStatus(
state=ActionState.FAILED,
fail_message=str(e),
)
else:
finally:
# We need to directly complete the action. Other actions rely on the OpenJobIO session's
# callback to complete the action
session.update_action(
action_status=ActionStatus(state=ActionState.SUCCESS),
)
session.update_action(action_status=action_status)

def human_readable(self) -> str:
return "job.sync_input_job_attachments()"
Expand Down
5 changes: 2 additions & 3 deletions src/deadline_worker_agent/sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ def run(self) -> None:
try:
self._cleanup()
except Exception as error:
logger.exception(error)
logger.error(
"Unexpected exception while performing cleanup of Session %s.", self._id
logger.exception(
f"Unexpected exception while performing cleanup of Session {self._id}: {error}."
)
finally:
self._stopped_running.set()
Expand Down