Desktops
Overview
A desktop on the davinci site represents a set of scripts and components that can be run to accomplish
a given analysis. They are bundled together and accessible through either a copy button or a desktop button.
- Copy
- the copy button will copy the scripts and other components in the desktop to your clipboard. You can
either paste them into your web desktop, or you can import them into VSCode by clicking the import
link in the extension tree (left panel)
- Desktop
- the desktop button will open the desktop in the browser in your online davinci workspace. Note,
there are some desktops that cannot be run in the browser. For example, any desktop that depends on a library
such as Quantlib
for which there does not exist a browser port can only be run locally after installing the library.
Example Code
Small example scripts may be presented in the following format.
print('hello world')
Right clicking on the code will open a context menu with the following options.
- copy as text
- copies the code as text and places it in your clipboard
- copy as code
- copies the code as a code object, which can then pasted into the davinci page canvas or online desktop,
or imported ino the visual studio extension
- copy as html
- will copy the code as the formatted HTML component (same as is displayed)
which can then be pasted into the davinci canvas or wiki page.
- run
- will open a browser tab with a code editor where you can run the script.
(NOTE some scripts may not be runnable within the browser, or are just snippets of code that require
the rest to run properly)
Example Runnable Code
For scripts or desktops that can be run in the browwser, you may see a code editor as in the following:
Clicking the run button will execute the code, which may take some time to run before anything is printed to the console.
The clipboard underneath the editor, when clicked, will copy the code to your clipboard, where it can be pasted into a
davinci page
or imported into Visual Studio.
Example Code without Run
When code is presented without a run button or a console, it typically means that the code is not able to be run within the browser,
but can still be copied and imported into
Visual Studio.
Sample Data and Mapping Data Inputs
Most provided scripts or desktops include utilities for providing different types of analysis. The sample code
is typically provided with a sample dataset (usually randomly generated) that the analysis is run on, to provide
an example of the analysis.
To simplify the mapping process, most scripts are designed to use
pydantic data classes
as inputs. This allows users to easily see the definitions of the data inputs and to opitimize the use
of IDE provided help such as Intellisense.
VSCode Setup
To run a desktop in VSCode, you install the
VSCode davinci extension.
Then run the davinci initialization command
from the command menu (ctrl-shift-p). This will do the following.
- Create a folder named "data" in the workspace folder
- Create a folder named "cache" in the workspace folder
- Installs the necessary python libraries
- requests
- python-dotenv
- websockets