remove exc_info from LOG.exception (#246)

This commit is contained in:
Shuchang Zheng 2024-04-30 00:27:32 -07:00 committed by GitHub
parent 45d11e5a7f
commit b6a85cf3a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 20 additions and 22 deletions

View file

@ -302,7 +302,6 @@ class ForgeAgent:
except FailedToSendWebhook: except FailedToSendWebhook:
LOG.exception( LOG.exception(
"Failed to send webhook", "Failed to send webhook",
exc_info=True,
task_id=task.task_id, task_id=task.task_id,
step_id=step.step_id, step_id=step.step_id,
task=task, task=task,

View file

@ -41,7 +41,7 @@ class AsyncAWSClient:
error_code = e.response["Error"]["Code"] # type: ignore error_code = e.response["Error"]["Code"] # type: ignore
except Exception: except Exception:
error_code = "failed-to-get-error-code" error_code = "failed-to-get-error-code"
LOG.exception("Failed to get secret.", secret_name=secret_name, error_code=error_code, exc_info=True) LOG.exception("Failed to get secret.", secret_name=secret_name, error_code=error_code)
return None return None
@execute_with_async_client(client_type=AWSClientType.S3) @execute_with_async_client(client_type=AWSClientType.S3)

View file

@ -165,10 +165,10 @@ class AgentDB:
await session.refresh(new_artifact) await session.refresh(new_artifact)
return convert_to_artifact(new_artifact, self.debug_enabled) return convert_to_artifact(new_artifact, self.debug_enabled)
except SQLAlchemyError: except SQLAlchemyError:
LOG.exception("SQLAlchemyError", exc_info=True) LOG.exception("SQLAlchemyError")
raise raise
except Exception: except Exception:
LOG.exception("UnexpectedError", exc_info=True) LOG.exception("UnexpectedError")
raise raise
async def get_task(self, task_id: str, organization_id: str | None = None) -> Task | None: async def get_task(self, task_id: str, organization_id: str | None = None) -> Task | None:
@ -580,10 +580,10 @@ class AgentDB:
else: else:
return None return None
except SQLAlchemyError: except SQLAlchemyError:
LOG.exception("SQLAlchemyError", exc_info=True) LOG.exception("SQLAlchemyError")
raise raise
except Exception: except Exception:
LOG.exception("UnexpectedError", exc_info=True) LOG.exception("UnexpectedError")
raise raise
async def get_artifact( async def get_artifact(
@ -662,10 +662,10 @@ class AgentDB:
return artifacts[0] return artifacts[0]
return None return None
except SQLAlchemyError: except SQLAlchemyError:
LOG.exception("SQLAlchemyError", exc_info=True) LOG.exception("SQLAlchemyError")
raise raise
except Exception: except Exception:
LOG.exception("UnexpectedError", exc_info=True) LOG.exception("UnexpectedError")
raise raise
async def get_latest_n_artifacts( async def get_latest_n_artifacts(
@ -693,10 +693,10 @@ class AgentDB:
return [convert_to_artifact(artifact, self.debug_enabled) for artifact in artifacts] return [convert_to_artifact(artifact, self.debug_enabled) for artifact in artifacts]
return None return None
except SQLAlchemyError: except SQLAlchemyError:
LOG.exception("SQLAlchemyError", exc_info=True) LOG.exception("SQLAlchemyError")
raise raise
except Exception: except Exception:
LOG.exception("UnexpectedError", exc_info=True) LOG.exception("UnexpectedError")
raise raise
async def get_latest_task_by_workflow_id( async def get_latest_task_by_workflow_id(

View file

@ -85,7 +85,6 @@ class Block(BaseModel, abc.ABC):
except Exception: except Exception:
LOG.exception( LOG.exception(
"Block execution failed", "Block execution failed",
exc_info=True,
workflow_run_id=workflow_run_id, workflow_run_id=workflow_run_id,
block_label=self.label, block_label=self.label,
block_type=self.block_type, block_type=self.block_type,
@ -657,7 +656,7 @@ class UploadToS3Block(Block):
uri=self._get_s3_uri(workflow_run_id, self.path), file_path=self.path uri=self._get_s3_uri(workflow_run_id, self.path), file_path=self.path
) )
except Exception as e: except Exception as e:
LOG.exception("UploadToS3Block: Failed to upload file to S3", file_path=self.path, exc_info=True) LOG.exception("UploadToS3Block: Failed to upload file to S3", file_path=self.path)
raise e raise e
LOG.info("UploadToS3Block: File(s) uploaded to S3", file_path=self.path) LOG.info("UploadToS3Block: File(s) uploaded to S3", file_path=self.path)

View file

@ -192,7 +192,6 @@ class WorkflowService:
LOG.exception( LOG.exception(
f"Error while executing workflow run {workflow_run.workflow_run_id}", f"Error while executing workflow run {workflow_run.workflow_run_id}",
workflow_run_id=workflow_run.workflow_run_id, workflow_run_id=workflow_run.workflow_run_id,
exc_info=True,
) )
await self.mark_workflow_run_as_failed(workflow_run_id=workflow_run.workflow_run_id) await self.mark_workflow_run_as_failed(workflow_run_id=workflow_run.workflow_run_id)
raise e raise e

View file

@ -228,7 +228,9 @@ async def handle_download_file_action(
await download.save_as(full_file_path) await download.save_as(full_file_path)
except Exception as e: except Exception as e:
LOG.exception( LOG.exception(
"DownloadFileAction: Failed to download file", action=action, full_file_path=full_file_path, exc_info=True "DownloadFileAction: Failed to download file",
action=action,
full_file_path=full_file_path,
) )
return [ActionFailure(e)] return [ActionFailure(e)]
@ -363,7 +365,7 @@ async def handle_select_option_action(
if action.option.index is not None: if action.option.index is not None:
LOG.warning( LOG.warning(
"Failed to click on the option by label, trying by index", "Failed to click on the option by label, trying by index",
exc_info=e, exc_info=True,
action=action, action=action,
xpath=xpath, xpath=xpath,
) )
@ -667,7 +669,7 @@ async def click_sibling_of_input(
interacted_with_sibling=True, interacted_with_sibling=True,
) )
except Exception as e: except Exception as e:
LOG.warning("Failed to click sibling label of input element", exc_info=e) LOG.warning("Failed to click sibling label of input element", exc_info=True)
return ActionFailure(exception=e, javascript_triggered=javascript_triggered) return ActionFailure(exception=e, javascript_triggered=javascript_triggered)

View file

@ -181,7 +181,7 @@ class BrowserState:
await self.page.goto(url) await self.page.goto(url)
await asyncio.sleep(3) await asyncio.sleep(3)
except Error as playright_error: except Error as playright_error:
LOG.exception(f"Error while navigating to url: {str(playright_error)}", exc_info=True) LOG.exception(f"Error while navigating to url: {str(playright_error)}")
raise FailedToNavigateToUrl(url=url, error_message=str(playright_error)) raise FailedToNavigateToUrl(url=url, error_message=str(playright_error))
success = True success = True
LOG.info(f"Successfully went to {url}") LOG.info(f"Successfully went to {url}")
@ -190,13 +190,12 @@ class BrowserState:
except Exception as e: except Exception as e:
LOG.exception( LOG.exception(
f"Error while creating or navigating to a new page. Waiting for 5 seconds. Error: {str(e)}", f"Error while creating or navigating to a new page. Waiting for 5 seconds. Error: {str(e)}",
exc_info=True,
) )
retries += 1 retries += 1
# Wait for 5 seconds before retrying # Wait for 5 seconds before retrying
await asyncio.sleep(5) await asyncio.sleep(5)
if retries >= 3: if retries >= 3:
LOG.exception(f"Failed to create a new page after 3 retries: {str(e)}", exc_info=True) LOG.exception(f"Failed to create a new page after 3 retries: {str(e)}")
raise e raise e
LOG.info(f"Retrying to create a new page. Retry count: {retries}") LOG.info(f"Retrying to create a new page. Retry count: {retries}")
@ -236,8 +235,8 @@ class BrowserState:
animations="disabled", animations="disabled",
) )
except TimeoutError as e: except TimeoutError as e:
LOG.exception(f"Timeout error while taking screenshot: {str(e)}", exc_info=True) LOG.exception(f"Timeout error while taking screenshot: {str(e)}")
raise FailedToTakeScreenshot(error_message=str(e)) from e raise FailedToTakeScreenshot(error_message=str(e)) from e
except Exception as e: except Exception as e:
LOG.exception(f"Unknown error while taking screenshot: {str(e)}", exc_info=True) LOG.exception(f"Unknown error while taking screenshot: {str(e)}")
raise FailedToTakeScreenshot(error_message=str(e)) from e raise FailedToTakeScreenshot(error_message=str(e)) from e

View file

@ -49,7 +49,7 @@ def load_js_script() -> str:
with open(path, "r") as f: with open(path, "r") as f:
return f.read() return f.read()
except FileNotFoundError as e: except FileNotFoundError as e:
LOG.exception("Failed to load the JS script", exc_info=True, path=path) LOG.exception("Failed to load the JS script", path=path)
raise e raise e