@@ -16,7 +16,7 @@ def download(table: str, table_type: str, release: str, output: str = ".") -> st
1616 table : str
1717 The AncientMetagenomeDir table to download.
1818 table_type : str
19- The type of table to download. Allowed values are ['samples', 'libraries'].
19+ The type of table to download. Allowed values are ['samples', 'libraries', 'dates' ].
2020 release : str
2121 The release of the table to download. Must be a valid release tag.
2222 output: str
@@ -47,16 +47,21 @@ def download(table: str, table_type: str, release: str, output: str = ".") -> st
4747 if check_allowed_values (tables , table ) is False :
4848 raise ValueError (f"Invalid table: { table } . Allowed values are { tables } " )
4949
50- if check_allowed_values (["samples" , "libraries" ], table_type ) is False :
50+ if check_allowed_values (["samples" , "libraries" , "dates" ], table_type ) is False :
5151 raise ValueError (
52- f"Invalid table type: { table_type } . Allowed values are ['samples', 'libraries']"
52+ f"Invalid table type: { table_type } . Allowed values are ['samples', 'libraries', 'dates' ]"
5353 )
5454 table_filename = f"{ table } _{ table_type } _{ release } .tsv"
5555 logger .info (
5656 f"Downloading { table } { table_type } table from { release } release, saving to { output } /{ table_filename } "
5757 )
58- t = requests .get (resources [table_type ][table ].replace ("master" , release ))
59- with open (table_filename , "w" ) as fh :
60- fh .write (t .text )
58+ try :
59+ t = requests .get (resources [table_type ][table ].replace ("master" , release ))
60+ with open (f"{ output } /{ table_filename } " , "w" ) as fh :
61+ fh .write (t .text )
62+ except KeyError :
63+ logger .warning (
64+ f"Invalid table: { table } . { table } currently does not have any { table_type } information."
65+ )
6166
6267 return table_filename
0 commit comments