When is this applicable?
This article explains how to download Python objects from Flows.
The Virtualitics AI Platform has support for persisting data in the Asset Store, which is helpful for accessing the persisted data in runs of other Flows (or the same Flow again if desired). Additionally, its possible to make any pickle-able Python object available for download in the Virtualitics AI Platform using a Custom Event Button.
Here is a process to make a Predict Asset available for download via a configurable Custom Event Button. This allows the Flow writer to create arbitrary download links for:
- text files (create an Asset with a
strvalue for its
- pickle-able Python objects (the asset persistence uses
dillto pickle and then persist Assets for future retrieval)
- Any byte string able to be wrapped in a BytesIO object can be persisted as an Asset
x = torch.tensor([0, 1, 2, 3, 4]) torch.save(x, 'tensor.pt') buffer = io.BytesIO() torch.save(x, buffer) asset = Asset(buffer, label='pytorch-tensor-asset')
Asset Download Custom Events have three mandatory parameters:
label, asset_type, extension, and three optional parameters:
mime_type, alias, time_created.
Please note: be sure to persist the asset before assigning it to a Custom Event Button:
store_interface.save_asset(asset) download_event = AssetDownloadCustomEvent("Download Results", asset, "pkl") current_page.add_content_to_section(download_event, self.section_title)
What to Expect (Validation)
When you click on the Custom Event Button, a download should start in your browser.