Skip to content

Commit 64c17f3

Browse files
committed
Remove extract_file_size function
1 parent fe55d80 commit 64c17f3

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

src/ghga_connector/core/downloading/api_calls.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@
3030

3131
from .structs import RetryResponse, UrlAndHeaders
3232

33-
__all__ = [
34-
"DownloadClient",
35-
"extract_download_url",
36-
"extract_file_size",
37-
]
33+
__all__ = ["DownloadClient", "extract_download_url"]
3834

3935
DrsObject = dict[str, Any]
4036

@@ -280,8 +276,6 @@ def _handle_drs_object_response(
280276
file_id = url.rsplit("/", 1)[1]
281277
raise exceptions.FileNotRegisteredError(file_id=file_id)
282278
case _:
283-
# this includes 404 because the file's existence should be verified
284-
# earlier when getting the file envelope
285279
raise exceptions.BadResponseCodeError(url=url, response_code=status_code)
286280

287281

@@ -296,16 +290,3 @@ def extract_download_url(drs_object: DrsObject) -> str:
296290
if access_method["type"] == "s3":
297291
return access_method["access_url"]["url"]
298292
raise exceptions.NoS3AccessMethodError(file_id=drs_object["id"])
299-
300-
301-
def extract_file_size(drs_object: DrsObject) -> int:
302-
"""Extract the file size from a DRS Object
303-
304-
Raises:
305-
NoS3AccessMethodError: If the DRS object doesn't have an S3 access method.
306-
"""
307-
access_methods = drs_object["access_methods"]
308-
for access_method in access_methods:
309-
if access_method["type"] == "s3":
310-
return drs_object["size"]
311-
raise exceptions.NoS3AccessMethodError(file_id=drs_object["id"])

src/ghga_connector/core/downloading/batch_processing.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@
2121
from ghga_connector import exceptions
2222
from ghga_connector.config import Config, get_download_api_url
2323
from ghga_connector.constants import C4GH
24-
from ghga_connector.core import (
25-
CLIMessageDisplay,
26-
WorkPackageClient,
27-
)
24+
from ghga_connector.core import CLIMessageDisplay, WorkPackageClient
2825
from ghga_connector.core.api_calls import is_service_healthy
2926

30-
from .api_calls import DownloadClient, extract_file_size
27+
from .api_calls import DownloadClient
3128
from .structs import RetryResponse
3229

3330

@@ -181,7 +178,7 @@ async def _check_file_is_in_download_bucket(self, file_id: str) -> None:
181178

182179
# File is staged and ready for download - add FileInfo instance to dict.
183180
# Also, response is a DRS object -- get file size from it
184-
file_size = extract_file_size(drs_object=response)
181+
file_size = response["size"]
185182
del self._unstaged_retry_times[file_id]
186183
self._staged_files.append(
187184
FileInfo(

0 commit comments

Comments
 (0)