Skip to content

Commit

Permalink
fixes for F541 F712 F841
Browse files Browse the repository at this point in the history
  • Loading branch information
sametd committed Aug 19, 2024
1 parent 322191d commit e49bf7d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions polytope_server/common/staging/s3_boto3_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def __init__(self, config):

for name in ["boto", "urllib3", "s3transfer", "boto3", "botocore", "nose"]:
logging.getLogger(name).setLevel(logging.WARNING)
logger = logging.getLogger(__name__)

prefix = "https" if self.use_ssl else "http"

Expand Down Expand Up @@ -148,7 +147,7 @@ def create(self, name, data, content_type):
if not parts:
logging.warning(f"No parts uploaded for {name}. Aborting upload.")
self.s3_client.abort_multipart_upload(Bucket=self.bucket, Key=name, UploadId=upload_id)
raise ValueError(f"No data retrieved")
raise ValueError("No data retrieved")

self.s3_client.complete_multipart_upload(
Bucket=self.bucket, Key=name, UploadId=upload_id, MultipartUpload={"Parts": parts}
Expand Down
4 changes: 2 additions & 2 deletions polytope_server/common/staging/s3_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, config):
access_key = config.get("access_key", "")
secret_key = config.get("secret_key", "")
self.bucket = config.get("bucket", "default")
secure = config.get("secure", False) == True
secure = config.get("secure", False)
self.url = config.get("url", None)
internal_url = "{}:{}".format(self.host, self.port)
secure = config.get("use_ssl", False)
Expand Down Expand Up @@ -156,7 +156,7 @@ def create(self, name, data, content_type):
logging.info(parts)
try:
self.client._complete_multipart_upload(self.bucket, name, upload_id, parts)
except:
except Exception:
time.sleep(5)
self.client._complete_multipart_upload(self.bucket, name, upload_id, parts)

Expand Down
2 changes: 1 addition & 1 deletion polytope_server/frontend/flask_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def uploads(request_id):
@handler.route("/api/v1/collections", methods=["GET"])
def list_collections():
auth_header = get_auth_header(request)
collection_config = authorized_collections = []
authorized_collections = []
for name, collection in collections.items():
try:
if auth.can_access_collection(auth_header, collection):
Expand Down
6 changes: 3 additions & 3 deletions polytope_server/worker/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def run(self):
self.update_status("processing")

# self.update_metric()
except:
except Exception:
# We must force threads to shutdown in case of failure, otherwise the worker won't exit
self.thread_pool.shutdown(wait=False)
raise
Expand Down Expand Up @@ -245,9 +245,9 @@ def process_request(self, request):
request.url = self.staging.create(id, datasource.result(request), datasource.mime_type())

except Exception as e:
request.user_message += "Failed to finalize request"
request.user_message += f"Failed to finalize request: {str(e)}"
logging.info(request.user_message, extra={"request_id": id})
logging.exception("Failed to finalize request", extra={"request_id": id})
logging.exception("Failed to finalize request", extra={"request_id": id, "exception": str(e)})
raise

# Guarantee destruction of the datasource
Expand Down

0 comments on commit e49bf7d

Please sign in to comment.