File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ class IDCClient:
4141 CITATION_FORMAT_BIBTEX = "application/x-bibtex"
4242
4343 # Singleton pattern
44- # NOTE: In the future, one may want to use multiple clients e.g. for sub-datasets so a attribute-singleton as shown bewlo seems a better option.
44+ # NOTE: In the future, one may want to use multiple clients e.g. for sub-datasets so a attribute-singleton as shown below seems a better option.
4545 # _instance: IDCClient
4646 # def __new__(cls):
4747 # if not hasattr(cls, "_instance") or getattr(cls, "_instance") is None:
@@ -74,6 +74,8 @@ def __init__(self):
7474 {"Modality" : pd .Series .unique , "series_size_MB" : "sum" }
7575 )
7676
77+ idc_version = f"v{ Version (idc_index_data .__version__ ).major } "
78+
7779 self .indices_overview = {
7880 "index" : {
7981 "description" : "Main index containing one row per DICOM series." ,
@@ -95,6 +97,11 @@ def __init__(self):
9597 "installed" : False ,
9698 "url" : f"{ asset_endpoint_url } /sm_instance_index.parquet" ,
9799 },
100+ "clinical_index" : {
101+ "description" : "Index of clinical data accompanying the available images." ,
102+ "installed" : False ,
103+ "url" : f"https://idc-open-metadata.s3.amazonaws.com/bigquery_export/idc_{ idc_version } _clinical/column_metadata/000000000000.parquet" ,
104+ },
98105 }
99106
100107 # Lookup s5cmd
Original file line number Diff line number Diff line change 99
1010import pandas as pd
1111import pytest
12+ import requests
1213from click .testing import CliRunner
1314from idc_index import IDCClient , cli
1415
1819logging .basicConfig (level = logging .DEBUG )
1920
2021
22+ def remote_file_exists (url ):
23+ try :
24+ response = requests .head (url , allow_redirects = True )
25+ # Check if the status code indicates success
26+ return response .status_code == 200
27+ except requests .RequestException as e :
28+ # Handle any exceptions (e.g., network issues)
29+ print (f"An error occurred: { e } " )
30+ return False
31+
32+
2133@pytest .fixture (autouse = True )
2234def _change_test_dir (request , monkeypatch ):
2335 monkeypatch .chdir (request .fspath .dirname )
@@ -494,6 +506,12 @@ def test_fetch_index(self):
494506 assert i .indices_overview ["sm_index" ]["installed" ] is True
495507 assert hasattr (i , "sm_index" )
496508
509+ def test_indices_urls (self ):
510+ i = IDCClient ()
511+ for index in i .indices_overview :
512+ if i .indices_overview [index ]["url" ] is not None :
513+ assert remote_file_exists (i .indices_overview [index ]["url" ])
514+
497515
498516if __name__ == "__main__" :
499517 unittest .main ()
You can’t perform that action at this time.
0 commit comments