Environment views
From the left sidebar you can navigate to several environment views: Outline, Files, Data sources, Environment, and Variables (including Secrets and Environment variables).
Files
Upload files for use in a given project. You can load in source data, figures, images, etc.
Compute Profiles
Image
By default, projects use Python 3.9. You can change which version of Python the project uses via the Image dropdown. If your organization uses custom images, you can use the same dropdown to select a custom image to be used in your projects.
Size
Available kernel sizes depend on which plan your workspace is on. Community plans are limited to small kernels, Professional plans can select up to medium kernels, and workspaces with Teams or Enterprise plans can use any kernel size.
Depending on the needs of your project, you can opt into more (or less!) memory and processing power by changing the size of your kernel.
Compute Profiles can be changed in the Environment section on the left side panel by adjusting the Size dropdown under Compute Profile. Profiles range from 2-32 GB of memory and 0.25 - 4 CPUs.
Size | RAM (GB) | CPU |
---|---|---|
X Small | 2 | 0.25 |
Small | 4 | 0.5 |
Medium (default) | 8 | 1 |
Large | 16 | 2 |
X Large | 32 | 4 |
By default, projects are created with a Medium profile. Note that if you have configured scheduled runs of a project, those will run with the compute profile as set in the latest published version of your project.
You can find a memory tracker in the lower right of your project's logic view that will show you exactly how much memory the kernel has used. Note that this tracker will be updated after each cell has run; it will not update while a given cell is running.
For more info on kernel size availability see Hex's pricing page. Also note that projects using Custom images are limited to large kernels.
Variables
Secrets
Keep your sensitive values, like API tokens or passwords, secret by adding them as Secrets. We store all Secrets in a highly-encrypted vault, which is only visible to other users with "Full Access" or "Can Edit" project permissions. Secrets can be referenced in Python cells, but an attempt to display them in the Logic View or App Builder will return [SECRET VALUE]
.
You can add a Secret to a project by clicking the +Add button in the Secrets tab of the left sidebar. If you want to use a Secret which is defined as a shareable, workspace Secret, choose Import workspace secret from the menu to be presented with Secrets which are available for import. If you want to create a Secret for use only in the given project select Create project secret.
To access your Secrets, call them directly in place of where you would hard-code your credentials. In the example below, we're setting up a Snowflake connection and passing the database details as Secrets.
Environment variables
You can configure environment variables to be used in your projects. Environment variables aren't kept in the encrypted vault, nor are they redacted. Setting an environment variable in the left side panel is equivalent to using the python os
library directly in your logic.
See more documentation for the os
library here.
Built-in variables
We also have some variables which are automatically included in your project. These variables can be referenced in any logic cell.
Variable | Value | Description |
---|---|---|
hex_scheduled | False/True | If the run is being executed as part of a scheduled run, this variable is set to True . If the run is executed in any other context, the variable is set to False . |
hex_run_context | "logic", "app", "scheduled", "api-triggered" | Describes the context that the project is being run in. Helpful if you want to restrict certain logic to only run in particular run contexts. For example, use this if you have some debug code that you want to run in the logic, but don't want to run while a user is interacting with the published app. |
hex_user_email | If a user is logged in and viewing a published app, this variable is equal to the email address associated with their user account. Helpful if you want to customize what a given user sees in the app. Check out this tutorial for an example. | |
hex_timezone | "America/Los_Angeles" , "Australia/Sydney" , etc. | The timezone selected for the project. By default this is the workspace timezone, but can also be overridden at the project level, as well as for specific app sessions. See Chart cell timezones for more information. |
hex_color_palette | ['#4C78A8', '#F58518', '#E45756', ... ] | An array of CSS color codes that map to the currently active workspace color palette. Using this variable can help create consistently themed visualizations when using both the native Chart cell and visualizations created via Python packages. |
Mute cells
If there are cells in your project that you only want to execute in specific contexts (e.g. on project runs in Logic view, only during scheduled runs, etc.), you can do so using the built-in hex_run_context
and hex_scheduled
variables. With these variables, you can check the context for when each cell is run and execute the desired logic accordingly. See the below code snippets for some examples code!
if hex_run_context == 'logic':
## Something that only needs to happen during a Logic run
else:
## otherwise this cell will be muted
Similarly, you can do the same in an SQL cell via Jinja.
{% if hex_run_context == 'logic' %}
-- Something that only needs to happen during a Logic run
{% endif %}
Variable explorer
The Variable explorer allows you to browse the objects generated by your code. For each object, we show you its name, type, and value.