Skip to content

Commit f1f813e

Browse files
committed
add error handling and log messages
1 parent 570babb commit f1f813e

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

scripts/automated_ingestion/eessi_task.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -526,15 +526,30 @@ def _handle_add_undetermined(self):
526526
target_dir = f"{repo_name}/{pr_number}/{sequence_number}/{task_file_name}"
527527
task_description_file_path = f"{target_dir}/TaskDescription"
528528
task_state_file_path = f"{target_dir}/TaskState.{TaskState.NEW_TASK.name}"
529-
self.git_repo.create_file(task_description_file_path,
530-
f"new task description for {repo_name} PR {pr_number} seq {sequence_number}",
531-
self.description.get_contents(), branch=branch)
532-
self.git_repo.create_file(task_state_file_path,
533-
f"new task state for {repo_name} PR {pr_number} seq {sequence_number}",
534-
"", branch=branch)
529+
try:
530+
self.git_repo.create_file(task_description_file_path,
531+
f"new task description for {repo_name} PR {pr_number} seq {sequence_number}",
532+
self.description.get_contents(), branch=branch)
533+
except Exception as err:
534+
log_message(LoggingScope.TASK_OPS, 'ERROR', "Error creating task description file: %s", err)
535+
return TaskState.UNDETERMINED
536+
log_message(LoggingScope.TASK_OPS, 'INFO',
537+
"task description file created: %s", task_description_file_path)
538+
539+
try:
540+
self.git_repo.create_file(task_state_file_path,
541+
f"new task state for {repo_name} PR {pr_number} seq {sequence_number}",
542+
"", branch=branch)
543+
except Exception as err:
544+
log_message(LoggingScope.TASK_OPS, 'ERROR', "Error creating task state file: %s", err)
545+
return TaskState.UNDETERMINED
546+
log_message(LoggingScope.TASK_OPS, 'INFO', "task state file created: %s", task_state_file_path)
547+
535548
self._create_symlink(self.description.task_object.remote_file_path, target_dir, branch=branch)
536-
# TODO: verify that the sequence number is still valid (PR corresponding to the sequence number is still open or
537-
# yet to be created); if it is not valid, perform corrective actions
549+
log_message(LoggingScope.TASK_OPS, 'INFO', "symlink created: %s -> %s",
550+
self.description.task_object.remote_file_path, target_dir)
551+
# TODO: verify that the sequence number is still valid (PR corresponding to the sequence number is still
552+
# open or yet to be created); if it is not valid, perform corrective actions
538553
return TaskState.NEW_TASK
539554

540555
@log_function_entry_exit()

0 commit comments

Comments
 (0)