@@ -558,8 +558,7 @@ def __setgluestate__(cls, rec, context):
558558 return cls (masks = masks )
559559
560560
561- def get_cloud_fits (possible_uri , ext = None , cache = None , local_path = os .curdir , timeout = None ,
562- dryrun = False ):
561+ def get_cloud_fits (possible_uri , ext = None ):
563562 """
564563 Retrieve and open a FITS file from an S3 URI using fsspec. Return the input
565564 unchanged if it is not an S3 URI.
@@ -579,10 +578,6 @@ def get_cloud_fits(possible_uri, ext=None, cache=None, local_path=os.curdir, tim
579578 Extension(s) to load from the FITS file. Can be an integer index (e.g., 0),
580579 a string name (e.g., "SCI"), or a list of such values. If `None`, all extensions
581580 are loaded.
582- cache : None, bool, or str, optional
583- local_path : str, optional
584- timeout : float, optional
585- dryrun : bool, optional
586581
587582 Returns
588583 -------
@@ -594,24 +589,24 @@ def get_cloud_fits(possible_uri, ext=None, cache=None, local_path=os.curdir, tim
594589 parsed_uri = urlparse (possible_uri )
595590
596591 # TODO: Add caching logic
597- if parsed_uri .scheme .lower () == 's3' :
598- downloaded_hdus = []
599- # this loads the requested extensions into local memory:
600- with fits .open (possible_uri , fsspec_kwargs = {"anon" : True }) as hdul :
601- if ext is None :
602- ext_list = list (range (len (hdul )))
603- elif not isinstance (ext , list ):
604- ext_list = [ext ]
605- else :
606- ext_list = ext
607- for extension in ext_list :
608- hdu_obj = hdul [extension ]
609- downloaded_hdus .append (hdu_obj .copy ())
592+ if not parsed_uri .scheme .lower () == 's3' :
593+ raise ValueError ("Not an S3 URI: {}" .format (possible_uri ))
594+
595+ downloaded_hdus = []
596+ # this loads the requested extensions into local memory:
597+ with fits .open (possible_uri , fsspec_kwargs = {"anon" : True }) as hdul :
598+ if ext is None :
599+ ext_list = list (range (len (hdul )))
600+ elif not isinstance (ext , list ):
601+ ext_list = [ext ]
602+ else :
603+ ext_list = ext
604+ for extension in ext_list :
605+ hdu_obj = hdul [extension ]
606+ downloaded_hdus .append (hdu_obj .copy ())
610607
611608 file_obj = fits .HDUList (downloaded_hdus )
612609 return file_obj
613- # not s3 resource, return string as is
614- return possible_uri
615610
616611
617612def cached_uri (uri ):
0 commit comments