Creating Bundles with the Python API
Install examples, use API to version your data
This step of the tutorial will teach you about:
How to use the Disdat Python API to create and clear a local context
How to use the API to create simple bundles that store scalars, lists, or dictionaries
How to use Disdat to create managed output paths so you can store output files in your bundles.
Set up our example Python project
Clone the examples github repo (https://github.com/seanr15/disdat-examples) here.
We'll assume you've installed it in
$CODE
Change directories into your project:
cd $CODE
Assuming you are in your virtual environment, install the example project:
pip install -e .
Bundle basics
Bundles collect a set of literals and files as a versioned unit
The Python Bundle API can present your bundle as basic Python types, see here.
Bundles can store any number of user tags
Bundles can also track parameters, git information, timing, and lineage
Creating bundles
This notebook (from the git repo above) has more examples than just the ones below. Follow along and explore those as well!
Create example data and a context
Create a bundle to hold our dictionary
Create a bundle that holds existing files
Bundles can also hold links to files. These are strings that look like file paths. You can add external files by simply adding the path to the bundle. Note that this will make a copy of the file -- you're versioning this particular output.
Use managed paths to version files with zero copies
But Disdat can create managed output paths -- you only need to provide the name of the output file, not where it's stored! Here we version two output files in a bundle.
Disdat can also manage S3 files. If you bind your local context to a remote, you can place S3 files into a bundle in the same way as local files. You can either add an S3 path directly, or you can call Bundle.get_remote_file
to get a path on S3 at which to store your file. You can also ask for and add local and remote directories by using Bundle.get_directory
and Bundle.get_remote_directory
Search for versioned data!
Here we use the api search method to find all versions of the bundle "example_data" . We print out the creation date as well as the Bundle.data
field.
Check out another notebook ("5_store_models_using_bundle_api") that shows how to use the API to store pickled scikit learn models, retrieve them, and use them for prediction.
Last updated
Was this helpful?