Virtualitics Predict 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, it's possible to make any pickle-able Python object available for download in Virtualitics Predict using a Custom Event Button.
Creating a Custom Event Button
Here is a process to make a Virtualitics Predict Asset available for download via a configurable Custom Event Button. This allows you to create arbitrary download links for:
-
text files (create an Asset with a
str
value for itsobject
parameter) -
pickle-able Python objects (the asset persistence uses
dill
to 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
.
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
When you click on the Custom Event Button, a download should start in your browser.
Previous Article |
Next Article |