Skip to content

Commit 5d5503d

Browse files
committed
fix travelling credentials parameter
a travelling parameter is a parameter that is passed through multiple function before being used
1 parent 03cacf8 commit 5d5503d

File tree

2 files changed

+5
-29
lines changed

2 files changed

+5
-29
lines changed

cosmotech/coal/cosmotech_api/runner/datasets.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import multiprocessing
1313
import tempfile
1414
from pathlib import Path
15-
from typing import Dict, List, Any, Optional, Union, Tuple
15+
from typing import Dict, List, Any, Optional, Union
1616

1717
from azure.identity import DefaultAzureCredential
1818
from cosmotech_api.api.dataset_api import DatasetApi
@@ -54,7 +54,6 @@ def download_dataset(
5454
workspace_id: str,
5555
dataset_id: str,
5656
read_files: bool = True,
57-
credentials: Optional[DefaultAzureCredential] = None,
5857
) -> Dict[str, Any]:
5958
"""
6059
Download a single dataset by ID.
@@ -64,7 +63,6 @@ def download_dataset(
6463
workspace_id: Workspace ID
6564
dataset_id: Dataset ID
6665
read_files: Whether to read file contents
67-
credentials: Azure credentials (if None, uses DefaultAzureCredential if needed)
6866
6967
Returns:
7068
Dataset information dictionary
@@ -91,7 +89,7 @@ def download_dataset(
9189
if is_adt:
9290
content, folder_path = download_adt_dataset(
9391
adt_address=parameters["AZURE_DIGITAL_TWINS_URL"],
94-
credentials=credentials,
92+
credentials=DefaultAzureCredential(),
9593
)
9694
return {
9795
"type": "adt",
@@ -160,7 +158,7 @@ def download_dataset(
160158

161159

162160
def download_dataset_process(
163-
_dataset_id, organization_id, workspace_id, read_files, credentials, _return_dict, _error_dict
161+
_dataset_id, organization_id, workspace_id, read_files, _return_dict, _error_dict
164162
):
165163
"""
166164
Process function for downloading a dataset in a separate process.
@@ -174,7 +172,6 @@ def download_dataset_process(
174172
organization_id: Organization ID
175173
workspace_id: Workspace ID
176174
read_files: Whether to read file contents
177-
credentials: Azure credentials (if None, uses DefaultAzureCredential if needed)
178175
_return_dict: Shared dictionary to store successful download results
179176
_error_dict: Shared dictionary to store error messages
180177
@@ -187,7 +184,6 @@ def download_dataset_process(
187184
workspace_id=workspace_id,
188185
dataset_id=_dataset_id,
189186
read_files=read_files,
190-
credentials=credentials,
191187
)
192188
_return_dict[_dataset_id] = _c
193189
except Exception as e:
@@ -200,7 +196,6 @@ def download_datasets_parallel(
200196
workspace_id: str,
201197
dataset_ids: List[str],
202198
read_files: bool = True,
203-
credentials: Optional[DefaultAzureCredential] = None,
204199
) -> Dict[str, Dict[str, Any]]:
205200
"""
206201
Download multiple datasets in parallel.
@@ -210,7 +205,6 @@ def download_datasets_parallel(
210205
workspace_id: Workspace ID
211206
dataset_ids: List of dataset IDs
212207
read_files: Whether to read file contents
213-
credentials: Azure credentials (if None, uses DefaultAzureCredential if needed)
214208
215209
Returns:
216210
Dictionary mapping dataset IDs to dataset information
@@ -225,7 +219,7 @@ def download_datasets_parallel(
225219
dataset_id,
226220
multiprocessing.Process(
227221
target=download_dataset_process,
228-
args=(dataset_id, organization_id, workspace_id, read_files, credentials, return_dict, error_dict),
222+
args=(dataset_id, organization_id, workspace_id, read_files, return_dict, error_dict),
229223
),
230224
)
231225
for dataset_id in dataset_ids
@@ -251,7 +245,6 @@ def download_datasets_sequential(
251245
workspace_id: str,
252246
dataset_ids: List[str],
253247
read_files: bool = True,
254-
credentials: Optional[DefaultAzureCredential] = None,
255248
) -> Dict[str, Dict[str, Any]]:
256249
"""
257250
Download multiple datasets sequentially.
@@ -261,7 +254,6 @@ def download_datasets_sequential(
261254
workspace_id: Workspace ID
262255
dataset_ids: List of dataset IDs
263256
read_files: Whether to read file contents
264-
credentials: Azure credentials (if None, uses DefaultAzureCredential if needed)
265257
266258
Returns:
267259
Dictionary mapping dataset IDs to dataset information
@@ -279,7 +271,6 @@ def download_datasets_sequential(
279271
workspace_id=workspace_id,
280272
dataset_id=dataset_id,
281273
read_files=read_files,
282-
credentials=credentials,
283274
)
284275
except Exception as e:
285276
error_dict[dataset_id] = f"{type(e).__name__}: {str(e)}"
@@ -294,7 +285,6 @@ def download_datasets(
294285
dataset_ids: List[str],
295286
read_files: bool = True,
296287
parallel: bool = True,
297-
credentials: Optional[DefaultAzureCredential] = None,
298288
) -> Dict[str, Dict[str, Any]]:
299289
"""
300290
Download multiple datasets, either in parallel or sequentially.
@@ -305,7 +295,6 @@ def download_datasets(
305295
dataset_ids: List of dataset IDs
306296
read_files: Whether to read file contents
307297
parallel: Whether to download in parallel
308-
credentials: Azure credentials (if None, uses DefaultAzureCredential if needed)
309298
310299
Returns:
311300
Dictionary mapping dataset IDs to dataset information
@@ -319,15 +308,13 @@ def download_datasets(
319308
workspace_id=workspace_id,
320309
dataset_ids=dataset_ids,
321310
read_files=read_files,
322-
credentials=credentials,
323311
)
324312
else:
325313
return download_datasets_sequential(
326314
organization_id=organization_id,
327315
workspace_id=workspace_id,
328316
dataset_ids=dataset_ids,
329317
read_files=read_files,
330-
credentials=credentials,
331318
)
332319

333320

cosmotech/coal/cosmotech_api/runner/download.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,8 @@
1212
import os
1313
import pathlib
1414
import shutil
15-
from typing import Dict, List, Any, Optional
15+
from typing import Dict, Any, Optional
1616

17-
from azure.identity import DefaultAzureCredential
18-
from cosmotech_api.api.runner_api import RunnerApi
19-
from cosmotech_api.exceptions import ApiException
20-
21-
from cosmotech.coal.cosmotech_api.connection import get_api_client
2217
from cosmotech.coal.cosmotech_api.runner.data import get_runner_data
2318
from cosmotech.coal.cosmotech_api.runner.parameters import (
2419
format_parameters_list,
@@ -65,11 +60,6 @@ def download_runner_data(
6560
"""
6661
LOGGER.info(T("coal.cosmotech_api.runner.starting_download"))
6762

68-
# Get credentials if needed
69-
credentials = None
70-
if get_api_client()[1] == "Azure Entra Connection":
71-
credentials = DefaultAzureCredential()
72-
7363
# Get runner data
7464
runner_data = get_runner_data(organization_id, workspace_id, runner_id)
7565

@@ -100,7 +90,6 @@ def download_runner_data(
10090
dataset_ids=dataset_ids,
10191
read_files=read_files,
10292
parallel=parallel,
103-
credentials=credentials,
10493
)
10594

10695
result["datasets"] = datasets

0 commit comments

Comments
 (0)