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

[SYNPY-1442] Log update to capture exception when download-list fails #1071

Merged

Conversation

BryanFauble
Copy link
Contributor

Problem:

  1. If an exception was raised during get-download-list we did not print it out anywhere (Exception Swallowing)

Solution:

  1. use .exception on the logger which will capture the exception being raised

Testing:

  1. Verified functionality in a unit test
  2. Also verified by manually placing temporary code in .get() that the exception is logged to console:
Downloading  [####################]100.00%   418.0bytes/418.0bytes (227.4kB/s) manifest.csv Done...
    [ERROR] Unable to download file
Traceback (most recent call last):
  File "/home/bfauble/BryansGreatWorkspace/synapsePythonClient/synapseclient/client.py", line 2195, in get_download_list
    entity = self.get(row["ID"], downloadLocation=downloadLocation)
  File "/home/bfauble/.pyenv/versions/3.8.18/lib/python3.8/contextlib.py", line 75, in inner
    return func(*args, **kwds)
  File "/home/bfauble/BryansGreatWorkspace/synapsePythonClient/synapseclient/client.py", line 1098, in get
    raise SynapseError("This is a test error")
synapseclient.core.exceptions.SynapseError: This is a test error
[WARNING] A manifest was created, but no files were downloaded
Manifest file: manifest_1708712431265684147.csv

@BryanFauble BryanFauble requested a review from a team as a code owner February 23, 2024 18:47
Copy link

sonarcloud bot commented Feb 24, 2024

Copy link
Member

@thomasyu888 thomasyu888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 LGTM!

@@ -2204,7 +2204,7 @@ def get_download_list(self, downloadLocation: str = None) -> str:
except Exception:
row["path"] = ""
row["error"] = "DOWNLOAD FAILED"
self.logger.error("Unable to download file")
self.logger.exception("Unable to download file")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL : I did not know you could do this!

@BryanFauble BryanFauble merged commit 9753472 into develop Feb 26, 2024
38 checks passed
@BryanFauble BryanFauble deleted the SYNPY-1442-log-exception-when-download-list-fails branch February 26, 2024 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants