-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: Can't use curl to download a single manifest in one invocation (#5918) #6099
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
base: develop
Are you sure you want to change the base?
Changes from all commits
59e3513
ae86094
09089d8
7b3e7c5
9a773bd
c7f7f10
1f0e9db
237ff75
c923904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,16 @@ | |
) | ||
import json | ||
import logging | ||
import time | ||
from math import ( | ||
ceil, | ||
) | ||
from typing import ( | ||
Any, | ||
Callable, | ||
TYPE_CHECKING, | ||
cast, | ||
) | ||
|
||
import attr | ||
import attrs | ||
from chalice import ( | ||
BadRequestError, | ||
|
@@ -25,7 +26,6 @@ | |
R, | ||
cache, | ||
cached_property, | ||
config, | ||
) | ||
from azul.auth import ( | ||
Authentication, | ||
|
@@ -56,6 +56,7 @@ | |
Mandatory, | ||
validate_catalog, | ||
validate_params, | ||
validate_wait, | ||
) | ||
from azul.service.elasticsearch_service import ( | ||
IndexNotFoundError, | ||
|
@@ -214,7 +215,7 @@ def download_file(self, | |
validate_params(query_params, | ||
catalog=str, | ||
requestIndex=int, | ||
wait=self._validate_wait, | ||
wait=validate_wait, | ||
replica=self._validate_replica, | ||
token=str, | ||
**self._file_param_validators(catalog, request_index)) | ||
|
@@ -239,7 +240,7 @@ def download_file(self, | |
if file is None: | ||
raise NotFoundError(f'Unable to find file {file_uuid!r}, ' | ||
f'version {file_version!r} in catalog {catalog!r}') | ||
file = attr.evolve(file, **adict(name=file_name, drs_uri=drs_uri)) | ||
file = attrs.evolve(file, **adict(name=file_name, drs_uri=drs_uri)) | ||
else: | ||
file = self._file_from_request(catalog, file_uuid, query_params) | ||
|
||
|
@@ -275,14 +276,8 @@ def download_file(self, | |
if wait == '0': | ||
pass | ||
elif wait == '1': | ||
# Sleep in the lambda but ensure that we wake up before it | ||
# runs out of execution time (and before API Gateway times | ||
# out) so we get a chance to return a response to the client | ||
remaining_time = self.lambda_context.get_remaining_time_in_millis() / 1000 | ||
server_side_sleep = min(float(retry_after), | ||
remaining_time - config.api_gateway_timeout_padding - 3) | ||
time.sleep(server_side_sleep) | ||
retry_after = round(retry_after - server_side_sleep) | ||
time_slept = self.server_side_sleep(float(retry_after)) | ||
retry_after = ceil(retry_after - time_slept) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved change to commit |
||
else: | ||
assert False, wait | ||
query_params = self._file_to_request(download.file) | adict( | ||
|
@@ -338,10 +333,6 @@ def field_types(self, catalog: CatalogName) -> Mapping[str, FieldType]: | |
result[accessible] = pass_thru_bool | ||
return result | ||
|
||
def _validate_wait(self, wait: str | None): | ||
if wait not in ('0', '1', None): | ||
raise ValueError | ||
|
||
def _validate_replica(self, replica: str): | ||
if replica not in ('aws', 'gcp'): | ||
raise ValueError | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add validation of type and range of the argument.