DeepSea allows you to upload Python code and run it in a contained environment in the cloud. Users can run the code easily without needing to see your code or configuration.

In DeepSea, each group of code files and dependencies is called a package. From an uploaded package, you can create models which allow users to run a function from that package. 

This function can take a variety of possible input types, and should return either a single value, list of values, or one or more pandas DataFrames. 

The output data can then be visualized in DeepSea, fed into another model, or exported.

Prepare & Upload Your Code

There are a few important steps to follow before you upload your code to DeepSea.

Write a Function

The first step is to create one or more functions that you will run from DeepSea. These functions should take any input values you want to set from DeepSea, either when running the function or in its default configuration.

Any script you want to run in DeepSea must be inside a function. The main body of a file cannot currently be used as a model in DeepSea. These functions can call other functions, access other files, use libraries, and connect to the internet to hit API points. 

Return Values:

Your function should return any output data, which is most likely one or more pandas DataFrames, but could also be a primitive type value (str, int, etc). DeepSea does not directly support output files or images.

Dependencies:

If your code has dependencies on libraries, you can specify the versions of the libraries you are using by providing a requirements.txt file. This is optional, and if not provided then the current version of all libraries will be used.

Default Parameter Values:

If you would like to set default values for the function’s input parameters, it is recommended to do so now in Python. DeepSea will automatically populate those default values in its user interface if they are provided.

Upload Code

You are now ready to upload your code! DeepSea will only accept code that is inside a .zip file of a folder (not a file). Even if you have just one file, create a folder containing all the files you would like to upload for this package. 

Then, on Mac or Linux you can compress that folder into a zip file by right-clicking on it and selecting “Compress”. 

On Windows, you will need to create an empty compressed folder by right clicking in a blank space and clicking “New” > “Compressed (zipped) folder”, and then moving or copying your file(s) into it. It is also possible to create .zip files directly from an existing folder using 3rd-party software on Windows such as WinZip or 7-Zip.

To upload your zipped code folder, navigate to the Models page and then click “Add package”. Select or drag the file into the box, give the package a name, and click “Create”.

Your package will then be built in its own environment on our server, which can take a few minutes. While this is happening, status updates will appear by the new package’s name. You will have to wait for this to finish before moving on to the next step.

Create a Model

Once you have uploaded a package, you can use it to create a model, which will allow you to run your code from DeepSea. During this process you will configure any inputs into the function, then run it in DeepSea for the first time and see the outputs.

On the main models page, choose “Add model”, and select the function from your package to configure as a DeepSea model. 

From this point on, you can leave the process and your work will be saved if you want to come back to it later. Click “Continue” to go to the next step. 

Configure Inputs

This step is where you specify the input types, values, and options for your function as well as how you want DeepSea users to be able to interact with the inputs.

If your function’s parameters have default values, the type and value of those will be populated automatically. For any parameters that do not have a default value, you have to specify the type and default value.

There are a variety of python types that DeepSea can take as inputs. It can accept any primitive type: integer & float numbers, strings, or boolean values. It can also accept dates (Python datetimes), lists of strings, dictionaries provided as JSON, or pandas DataFrames. 

Any dataset in DeepSea can be input into a model as a pandas DataFrame from DeepSea. This allows you to chain models together, and generally load any data you want. The column names in these dataframes will be snake_cased versions of the original CSV or pandas column names. Each space is replaced by an underscore (_) character, and all alphabetic characters are converted to lowercase.

Input Settings

To configure an input, click its name in the top list. Then, choose the python type that it should be, and then a few more inputs will appear. 

The model bar & panel display options allow you to choose whether users will be able to change that input from the bar and/or panel on the dashboard. 

It is recommended to show the most important or frequently changed inputs in the bar, and all the inputs in the panel (except any that you don’t want dashboard users to be able to control).

The input style option allows you to choose from multiple types of input display in DeepSea where relevant. For example, a string can be input when running a model from a text input, or by choosing a pre-configured value from a dropdown menu. This depends on how you would like your input to be displayed.

Lastly, you must select a default value for each input based on the rest of its configuration.

While working on this, you can see a preview of the model bar and panel as they will appear in the dashboard. You can also view your source code by clicking the code icon on the right side.

Once all of the inputs have types and default values, you can click “Continue” to go to the final step.

Run the Code & Configure Outputs

On this page, you should make sure the input values look right and click “Run” in the model panel. Once your model is done running, the output data will appear if it was successful.

If the model run failed, an error message will appear. In this case, you may need to change your input configuration, or otherwise there is likely an error in your code.

The model must successfully run once to be fully configured. Once it has run, you can see all the output datasets to make sure they look right. You can give them names using the Dataset Name input (or keep the default names shown), and if there are multiple datasets you can navigate between them by clicking their names.

If everything looks good, you must click “Done” in the top right corner in order to approve the final configuration of the model. Now you are ready to use it in DeepSea!

Managing Existing Packages & Models

On the main models page in DeepSea, you can view or delete your existing packages & models.

To view a package or model, click on the bar with its name. This will take you to a summary page with some information about it. 

For models, from this page you can change any of the input or output configuration.

To delete a model or package, click the “...” menu icon and choose delete.

You can also update the source code of a model to a newly uploaded package, by clicking “Update Source” in the model menu.

Connecting a Model to a Dashboard

To show a model on a dashboard tab, at least one card must be using data from the model’s output dataset. Then, the model bar will automatically appear for that model.

Up Next: