foundry/foundry.py
def load(self, name, download=True, globus=True, verbose=False, metadata=None, authorizers=None, **kwargs):
        """Load the metadata for a Foundry dataset into the client
        Args:
            name (str): Name of the foundry dataset
            download (bool): If True, download the data associated with the package (default is True)
            globus (bool): If True, download using Globus, otherwise https
            verbose (bool): If True print additional debug information
            metadata (dict): **For debug purposes.** A search result analog to prepopulate metadata.

        Keyword Args:
            interval (int): How often to poll Globus to check if transfers are complete

        Returns
        -------
            self
        """

        # handle empty dataset name (was returning all the datasets)
        if not name:
            raise ValueError("load: No dataset name is given")

        if metadata:
            res = metadata

        if metadata:
            res = metadata

        # MDF specific logic
        if is_doi(name) and not metadata:
            res = self.forge_client.match_resource_types("dataset")
            res = res.match_dois(name).search()

        else:
            res = self.forge_client.match_field(
                "mdf.organizations", self.config.organization
            ).match_resource_types("dataset")
            res = res.match_field("mdf.source_id", name).search()

        # unpack res, handle if empty
        try:
            # if search returns multiple results, this automatically uses first result
            res = res[0]
        except IndexError as e:
            raise Exception("load: No metadata found for given dataset") from e

        try:
            res["dataset"] = res["projects"][self.config.metadata_key]
        except KeyError as e:
            raise Exception(f"load: not able to index with metadata key {self.config.metadata_key}") from e

        del res["projects"][self.config.metadata_key]

        # TODO: Creating a new Foundry instance is a problematic way to update the metadata,
        # we should find a way to abstract this.

        fdataset = FoundryDataset(**res['dataset'])
        self.dc = res['dc']
        self.mdf = res['mdf']
        self.dataset = fdataset


        if download is True:  # Add check for package existence
            self.download(
                interval=kwargs.get("interval", 10), globus=globus, verbose=verbose
            )

        return self
Load the metadata for a Foundry dataset into the client
        Args:
            name (str): Name of the foundry dataset
            download (bool): If True, download the data associated with the package (default is True)
            globus (bool): If True, download using Globus, otherwise https
            verbose (bool): If True print additional debug information
            metadata (dict): **For debug purposes.** A search result analog to prepopulate metadata.

        Keyword Args:
            interval (int): How often to poll Globus to check if transfers are complete

        Returns
        -------
            self
        
Load the metadata for a Foundry dataset into the client
Load the metadata for a Foundry dataset into the client
def load(self, name, download=True, globus=True, verbose=False, metadata=None, authorizers=None, **kwargs):
        if not name:
            raise ValueError("load: No dataset name is given")
        if metadata:
            res = metadata
        if metadata:
            res = metadata
        if is_doi(name) and not metadata:
            res = self.forge_client.match_resource_types("dataset")
            res = res.match_dois(name).search()
        else:
            res = self.forge_client.match_field(
                "mdf.organizations", self.config.organization
            ).match_resource_types("dataset")
            res = res.match_field("mdf.source_id", name).search()
        try:
            res = res[0]
        except IndexError as e:
            raise Exception("load: No metadata found for given dataset") from e
        try:
            res["dataset"] = res["projects"][self.config.metadata_key]
        except KeyError as e:
            raise Exception(f"load: not able to index with metadata key {self.config.metadata_key}") from e
        del res["projects"][self.config.metadata_key]
        fdataset = FoundryDataset(**res['dataset'])
        self.dc = res['dc']
        self.mdf = res['mdf']
        self.dataset = fdataset
        if download is True:  
            self.download(
                interval=kwargs.get("interval", 10), globus=globus, verbose=verbose
            )
        return self
def load ( self , name , download = True , globus = True , verbose = False , metadata = None , authorizers = None , ** kwargs ) : if not name : raise ValueError ( "load: No dataset name is given" ) if metadata : res = metadata if metadata : res = metadata if is_doi ( name ) and not metadata : res = self . forge_client . match_resource_types ( "dataset" ) res = res . match_dois ( name ) . search ( ) else : res = self . forge_client . match_field ( "mdf.organizations" , self . config . organization ) . match_resource_types ( "dataset" ) res = res . match_field ( "mdf.source_id" , name ) . search ( ) try : res = res [ 0 ] except IndexError as e : raise Exception ( "load: No metadata found for given dataset" ) from e try : res [ "dataset" ] = res [ "projects" ] [ self . config . metadata_key ] except KeyError as e : raise Exception ( f"load: not able to index with metadata key {self.config.metadata_key}" ) from e del res [ "projects" ] [ self . config . metadata_key ] fdataset = FoundryDataset ( ** res [ 'dataset' ] ) self . dc = res [ 'dc' ] self . mdf = res [ 'mdf' ] self . dataset = fdataset if download is True : self . download ( interval = kwargs . get ( "interval" , 10 ) , globus = globus , verbose = verbose ) return self
Load the metadata for a Foundry dataset into the client
Load the metadata for a Foundry dataset into the client
"""Load the metadata for a Foundry dataset into the client
        Args:
            name (str): Name of the foundry dataset
            download (bool): If True, download the data associated with the package (default is True)
            globus (bool): If True, download using Globus, otherwise https
            verbose (bool): If True print additional debug information
            metadata (dict): **For debug purposes.** A search result analog to prepopulate metadata.

        Keyword Args:
            interval (int): How often to poll Globus to check if transfers are complete

        Returns
        -------
            self
        """ # handle empty dataset name (was returning all the datasets) # MDF specific logic # unpack res, handle if empty # if search returns multiple results, this automatically uses first result # TODO: Creating a new Foundry instance is a problematic way to update the metadata, # we should find a way to abstract this. # Add check for package existence
self
name
Name of the foundry dataset
Name of the foundry dataset
download
If True, download the data associated with the package (default is True)
If True download the data associated with the package ( default is True )
globus
If True, download using Globus, otherwise https
If True download using Globus otherwise https
verbose
If True print additional debug information
If True print additional debug information
metadata
For debug purposes.** A search result analog to prepopulate metadata.
For debug purposes . ** A search result analog to prepopulate metadata .
authorizers