Using Datasets
We'll take you from importing Foundry all the way to seeing your data.
Last updated
We'll take you from importing Foundry all the way to seeing your data.
Last updated
We have example notebooks using material science data that illustrate how to load data or publish datasets using Foundry. These notebooks are compatible with Google Colab and with Jupyter Notebook. However, some of the datasets are quite large and cannot be loaded into Google Colab without the pro version.
The Foundry client provides access to all of the methods described here for listing, loading, and publishing datasets and models. The code below will create a Foundry client. If you'd like to use https instead of Globus when downloading data, specify that here with Globus=False
.
If you are running your script on cloud resources (e.g. Google Colab, Binder), see: Using Foundry on Cloud Computing Resources
To show all available Foundry datasets, you can use the Foundry list()
method as follows. The method returns a pandas DataFrame with details on the available datasets.
The Foundry client can be used to search for datasets using a source_id
or a digital object identifier (DOI) e.g. here "foundry_wei_atom_locating_benchmark"
or "10.18126/e73h-3w6n"
. You can retrieve the source_id
from the list()
method.
The search method will return a list of FoundryDataset
objects. If searching by DOI, you can expect that it will be the first result and select that FoundryDataset
object by specifying the first index.
Instead of using search
, you can use the get_dataset()
method. This method returns a FoundryDataset associated with the given name or DOI.
To load the dataset, you can use the get_as_dict()
method appended to the FoundryDataset
object. From the example above, this looks like:
This will remotely load the metadata (e.g., data location, data keys, etc.) and download the data to local storage if it is not already cached.
All datasets are accessible via HTTPS and Globus by authenticated download. HTTPS is the default. Read about the FoundryDataset object to use Globus.
To learn more about the dataset, you can access the metadata. The get_metadata_by_doi()
method returns a JSON object with all the metadata.
The image below is what the metadata looks like when the dataset variable is printed in a notebook. This table contains the dataset's metadata.
This is an example of accessing data in a specified split that is defined for the dataset, here we use train
.
Foundry works with common cloud computing providers (e.g., the NSF sponsored Jetstream and Google Colab). On these resources, simply add the following arguments to use a cloud-compatible authentication flow.