2929import typer
3030from ghga_service_commons .utils import crypt
3131
32- from ghga_connector .config import CONFIG
32+ from ghga_connector import exceptions
33+ from ghga_connector .config import CONFIG , set_runtime_config
3334from ghga_connector .core import (
3435 CLIMessageDisplay ,
3536 WorkPackageAccessor ,
3637 async_client ,
37- exceptions ,
3838)
39- from ghga_connector .core .api_calls import WKVSCaller
4039from ghga_connector .core .downloading .batch_processing import FileStager
4140from ghga_connector .core .main import (
4241 decrypt_file ,
5049class DownloadParameters :
5150 """Contains parameters returned by API calls to prepare information needed for download"""
5251
53- dcs_api_url : str
5452 file_ids_with_extension : dict [str , str ]
5553 work_package_accessor : WorkPackageAccessor
5654
5755
58- @dataclass
59- class UploadParameters :
60- """Contains parameters returned by API calls to prepare information needed for upload"""
61-
62- ucs_api_url : str
63- server_pubkey : str
64-
65-
6656@dataclass
6757class WorkPackageInformation :
6858 """Wraps decrypted work package token and id to pass to other functions"""
@@ -103,15 +93,6 @@ def modify_for_debug(debug: bool):
10393 sys .excepthook = partial (exception_hook )
10494
10595
106- async def retrieve_upload_parameters (client : httpx .AsyncClient ) -> UploadParameters :
107- """Configure httpx client and retrieve necessary parameters from WKVS"""
108- wkvs_caller = WKVSCaller (client = client , wkvs_url = CONFIG .wkvs_api_url )
109- ucs_api_url = await wkvs_caller .get_ucs_api_url ()
110- server_pubkey = await wkvs_caller .get_server_pubkey ()
111-
112- return UploadParameters (server_pubkey = server_pubkey , ucs_api_url = ucs_api_url )
113-
114-
11596async def retrieve_download_parameters (
11697 * ,
11798 client : httpx .AsyncClient ,
@@ -120,23 +101,16 @@ async def retrieve_download_parameters(
120101 work_package_information : WorkPackageInformation ,
121102) -> DownloadParameters :
122103 """Run necessary API calls to configure file download"""
123- wkvs_caller = WKVSCaller (client = client , wkvs_url = CONFIG .wkvs_api_url )
124- dcs_api_url = await wkvs_caller .get_dcs_api_url ()
125- wps_api_url = await wkvs_caller .get_wps_api_url ()
126-
127104 work_package_accessor = WorkPackageAccessor (
128105 access_token = work_package_information .decrypted_token ,
129- api_url = wps_api_url ,
130106 client = client ,
131- dcs_api_url = dcs_api_url ,
132107 package_id = work_package_information .package_id ,
133108 my_private_key = my_private_key ,
134109 my_public_key = my_public_key ,
135110 )
136111 file_ids_with_extension = await work_package_accessor .get_package_files ()
137112
138113 return DownloadParameters (
139- dcs_api_url = dcs_api_url ,
140114 file_ids_with_extension = file_ids_with_extension ,
141115 work_package_accessor = work_package_accessor ,
142116 )
@@ -199,14 +173,11 @@ async def async_upload(
199173 passphrase : str | None = None ,
200174):
201175 """Upload a file asynchronously"""
202- async with async_client () as client :
203- parameters = await retrieve_upload_parameters (client )
176+ async with async_client () as client , set_runtime_config (client = client ):
204177 await upload_file (
205- api_url = parameters .ucs_api_url ,
206178 client = client ,
207179 file_id = file_id ,
208180 file_path = file_path ,
209- server_public_key = parameters .server_pubkey ,
210181 my_public_key_path = my_public_key_path ,
211182 my_private_key_path = my_private_key_path ,
212183 passphrase = passphrase ,
@@ -303,7 +274,7 @@ async def async_download(
303274 my_private_key = my_private_key
304275 )
305276
306- async with async_client () as client :
277+ async with async_client () as client , set_runtime_config ( client = client ) :
307278 CLIMessageDisplay .display ("Retrieving API configuration information..." )
308279 parameters = await retrieve_download_parameters (
309280 client = client ,
@@ -315,7 +286,6 @@ async def async_download(
315286 CLIMessageDisplay .display ("Preparing files for download..." )
316287 stager = FileStager (
317288 wanted_file_ids = list (parameters .file_ids_with_extension ),
318- dcs_api_url = parameters .dcs_api_url ,
319289 output_dir = output_dir ,
320290 work_package_accessor = parameters .work_package_accessor ,
321291 client = client ,
@@ -326,7 +296,6 @@ async def async_download(
326296 for file_id in staged_files :
327297 CLIMessageDisplay .display (f"Downloading file with id '{ file_id } '..." )
328298 await download_file (
329- api_url = parameters .dcs_api_url ,
330299 client = client ,
331300 file_id = file_id ,
332301 file_extension = parameters .file_ids_with_extension [file_id ],
0 commit comments