Data

Overview

The data node of the Davinci VSCode Extension navigation tree shows that data that is hosted within the workspace. Data is placed into the workspace through two methods.

  • Files located in the data folder within the workspace are automatically included as datasets available in the workspace
  • Scripts that call the val.set function can place data within the workspace. This method can be used by user defined scripts, as well as apps that are run within the workspace.

Workspace Data

The primary way to create data in your workspace is through the use of the val function in a script. Call set on val will create a dataset in your workspace that is available to other scripts and tools.

The following code imports the val function, creates a dataset and puts it to the workspace. It then retrieves it by calling val again.

from davinci.python import val val.set('data', [{"age":24}]) data = val('data')

Local Data

When you initialize your davinci workspace, a folder named data is created in your workspace root folder. Any file that is placed in that folder will automatically appear in your workspace as a dataset.

Data Components

One way to create data in your workspace is through visual controls in a page.

Mapping Dependencies

When a component sets or reads data from the data cache using val, the dependency is tracked by your workspace so that changes to the dataset can be propagated. When a script reads or sets a dataset using val, the dependencies are also saved when the script is run, if you have set your configuration to infer dependencies. Then, if automatic updates is set, (see below) your workspace will automatically re-run any scripts that depend on a dataset when that dataset changes within the workspace.

To chane the infer dependencies setting for your current workapce, open your workspace settings and the click the "infer dependencies" checkbox.

Autmoatic Updates

When a dataset changes, either because the val.set function is called, or a file in the data folder changes, the system tracks the change. If you have configured the system to propagate automatic updates in your workspace settings the framework will automatically run any scripts or components that depend on the changed data.