-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from EGA-archive/EE-1405
EE-1405 Python client support for new Data API
- Loading branch information
Showing
8 changed files
with
76 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,10 @@ def list_authorized_datasets(data_client): | |
" If you believe you should have access please contact helpdesk on [email protected]") | ||
sys.exit() | ||
|
||
return [DataSet(data_client, dataset_id) for dataset_id in reply] | ||
if data_client.api_version == 1: | ||
return [DataSet(data_client, dataset_id) for dataset_id in reply] | ||
|
||
return [DataSet(data_client, dataset['datasetId']) for dataset in reply] | ||
|
||
def list_files(self): | ||
if self.id in LEGACY_DATASETS: | ||
|
@@ -42,8 +45,9 @@ def list_files(self): | |
|
||
authorized_datasets = DataSet.list_authorized_datasets(self.data_client) | ||
|
||
if self.id not in [dataset.id for dataset in authorized_datasets]: | ||
logging.error(f"Dataset '{self.id}' is not in the list of your authorized datasets.") | ||
authorized_dataset_ids = [dataset.id for dataset in authorized_datasets] | ||
if self.id not in authorized_dataset_ids: | ||
logging.error(f"Dataset '{self.id}' is not in the list of your authorized datasets ({authorized_dataset_ids})") | ||
sys.exit() | ||
|
||
reply = self.data_client.get_json(f"/datasets/{self.id}/files") | ||
|
@@ -52,19 +56,7 @@ def list_files(self): | |
logging.error(f"List files in dataset {self.id} failed") | ||
sys.exit() | ||
|
||
def make_data_file(res): | ||
display_file_name = res['displayFileName'] if 'displayFileName' in res else None | ||
file_name = res['fileName'] if 'fileName' in res else None | ||
size = res['fileSize'] if 'fileSize' in res else None | ||
unencrypted_checksum = res['unencryptedChecksum'] if 'unencryptedChecksum' in res else None | ||
return data_file.DataFile(self.data_client, res['fileId'], | ||
display_file_name=display_file_name, | ||
file_name=file_name, | ||
size=size, | ||
unencrypted_checksum=unencrypted_checksum, | ||
status=res['fileStatus']) | ||
|
||
return [make_data_file(res) for res in reply] | ||
return [data_file.DataFile.from_metadata(self.data_client, res) for res in reply] | ||
|
||
def download(self, num_connections, output_dir, genomic_range_args, max_retries=5, retry_wait=5, | ||
max_slice_size=DataFile.DEFAULT_SLICE_SIZE): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters