Desktop application wrapper for the Opentrons App using Electron
This directory contains the code for the Electron main process that runs the Opentrons application.
The app uses electron-store to store its configuration in a JSON file located at:
%APPDATA%\Opentrons\config.jsonon Windows~/.config/Opentrons/config.jsonon Linux~/Library/Application Support/Opentrons/config.jsonon macOS
Configuration values will be determined by:
- Checking for a CLI argument
- If no CLI argument, checking for an environment variable
- If no environment variable, checking the
config.jsonfile - If no value in
config.json, default value from code will be used- Default value will also be written to
config.json
- Default value will also be written to
Configuration values may be specified via:
- A CLI argument of the format
--configName.nestedValue - An environment variable of the format
OT_APP_CONFIG_NAME__NESTED_VALUE - The configuration JSON file with the path
configName.nestedValue
If overriding boolean values:
- For CLI arguments, use
--valuefor true, and--disable_valuefor false - For environment variables, use
OT_APP_VALUE=1for true, andOT_APP_VALUE=0for false
During development, we develop new features behind "feature flags", so that we can continue to release software while keeping anything that's still a work-in-progress safely disabled.
The feature flags are part of the configuration under the path devInternal. To enable a feature flag, set the configuration value to true:
- CLI:
--devInternal.nameOfFlag - Environment variable:
OT_APP_DEV_INTERNAL__NAME_OF_FLAG - Configuration JSON:
devInternal.nameOfFlag
The app also presents UI for enabling these flags when the devtools setting is enabled.
To override config in macOS, launch the app from Terminal instead of clicking on Opentrons.app.
# example: launch with devtools enabled
/Applications/Opentrons.app/Contents/MacOS/Opentrons --devtoolsReplace /Applications with whatever directory you have placed Opentrons.app in.
To override config in Linux, launch the app from the terminal. If you installed the Opentrons deb package, you should already have an opentrons executable in your $PATH.
# example: launch with devtools enabled
opentrons --devtoolsThe easiest way to override config on Windows is to modify the Opentrons desktop shortcut. Create a desktop shortcut to Opentrons if you don't have one already, then:
- Right click the "Opentrons" shortcut
- Select "Properties" and go to the "Shortcut" tab
- In the "Target" field, append any desired options
- CLI argument:
--devtools - Environment variable:
OT_APP_DEVTOOLS - JSON path:
devtools - Default:
false
Enables and opens the Chrome devtools with the React and Redux devtools extensions installed.
- CLI argument:
--reinstallDevtools - Environment variable:
OT_APP_REINSTALL_DEVTOOLS - JSON path:
reinstallDevtools - Default:
false
Forces the devtools extensions to be re-installed. Make sure you enable both -devtools and --reinstallDevtools
- CLI argument:
--update.channel - Environment variable:
OT_APP_UPDATE__CHANNEL - JSON path:
update.channel - Default:
"latest"
Sets the app's self-update channel. Options are alpha, beta, or latest. alpha is the least tested/stable, followed by beta, followed by latest. alpha and beta get new features earlier than latest.
- CLI argument:
--buildroot.manifestUrl - Environment variable:
OT_APP_BUILDROOT__MANIFEST_URL - JSON path:
buildroot.manifestUrl - Default:
"https://opentrons-buildroot-ci.s3.us-east-2.amazonaws.com/releases.json"
Sets the file that the app checks for its corresponding robot update.
- CLI argument:
--log.level.file - Environment variable:
OT_APP_LOG__LEVEL__FILE - JSON path:
log.level.file - Default:
"debug"
Default log level of the combined.log log file. See logging section below.
- CLI argument:
--log.level.console - Environment variable:
OT_APP_LOG__LEVEL__CONSOLE - JSON path:
log.level.console - Default:
"info"
Default log level of the console log. See logging section below.
- CLI argument:
--ui.webPreferences.webSecurityor--disable_ui.webPreferences.webSecurity - Environment variable:
OT_APP_UI__WEB_PREFERENCES__WEB_SECURITY - JSON path:
ui.webPreferences.webSecurity - Default:
true
Sets the webPreferences.webSecurity option of the Electron BrowserWindow created for the UI. When disabled, the browsers same-origin policy will be disabled. This should only be disabled in development / testing environments.
- CLI argument:
--ui.width - Environment variable:
OT_APP_UI__WIDTH - JSON path:
ui.width - Default:
800
BrowserWindow width at launch.
- CLI argument:
--ui.minWidth - Environment variable:
OT_APP_UI__MIN_WIDTH - JSON path:
ui.minWidth - Default:
600
BrowserWindow minWidth at launch.
- CLI argument:
--ui.height - Environment variable:
OT_APP_UI__HEIGHT - JSON path:
ui.height - Default:
760
BrowserWindow height at launch.
- CLI argument:
--ui.url.protocol - Environment variable:
OT_APP_UI__URL__PROTOCOL - JSON path:
ui.url.protocol - Default:
"file:"
Protocol used to fetch the UI's index.html. If you want to fetch the UI from the dev server in app, set this to http:.
- CLI argument:
--ui.url.path - Environment variable:
OT_APP_UI__URL__PATH - JSON path:
ui.url.path - Default:
"ui/index.html"
Path to index.html. If ui.url.protocol is file:, this path is relative to the application directory. This path will be combined with the protocol to get the full path to index.html. If you want to fetch the UI from the dev server in app, set this to localhost:8090.
- CLI argument:
--analytics.appId - Environment variable:
OT_APP_ANALYTICS__APP_ID - JSON path:
analytics.appId - Default: Random UUID generated at first launch
Random, persistent ID to use for anonymous analytics tracking if opted in.
- CLI argument:
--analytics.optedIn - Environment variable:
OT_APP_ANALYTICS__OPTED_IN - JSON path:
analytics.optedIn - Default:
false
Whether or not the user has opted into anonymous analytics tracking.
- CLI argument:
--analytics.seenOptIn - Environment variable:
OT_APP_ANALYTICS__SEEN_OPT_IN - JSON path:
analytics.seenOptIn - Default:
false
Whether or not the user has seen the initial analytics description pop-up.
- CLI argument:
--support.userId - Environment variable:
OT_APP_SUPPORT__USER_ID - JSON path:
support.userId - Default: Random UUID generated at first launch
Random, persistent ID to use for support tracking. Different than analytics.appId.
- CLI argument:
--support.createdAt - Environment variable:
OT_APP_SUPPORT__CREATED_AT - JSON path:
support.createdAt - Default: Current Unix time at first launch
Timestamp of first app launch.
- CLI argument:
--support.name - Environment variable:
OT_APP_SUPPORT__NAME - JSON path:
support.name - Default:
"App User"
Full name of app user to populate "Name" in support conversations.
- CLI argument:
--support.email - Environment variable:
OT_APP_SUPPORT__EMAIL - JSON path:
support.email - Default:
null
Email of app user to populate "Email" in support conversations.
- CLI argument:
--discovery.candidates - Environment variable:
OT_APP_DISCOVERY__CANDIDATES - JSON path:
discovery.candidates - Default:
[]
Array<string> of extra IP address(es)/hosts for the discovery client to track. For example, to get the discovery client to find an instance of the API server running on your own computer.
Currently this config only allows one hostname/IP address as the value.
- CLI argument:
--labware.directory - Environment variable:
OT_APP_LABWARE__DIRECTORY - JSON path:
labware.directory - Default:
%APPDATA%\Opentrons\labwareon Windows~/.config/Opentrons/labwareon Linux~/Library/Application Support/Opentrons/labwareon macOS
Folder that the app stores and retrieves custom labware definitions from
Logs from both the main and renderer processes are logged to rolling files as well as the terminal by winston. The logs are stored in a logs directory at:
%APPDATA%\Opentrons\logson Windows~/.config/Opentrons/logson Linux~/Library/Application Support/Opentrons/logson macOS
- error
- warn
- info
- http
- verbose
- debug
- silly
logs/combined.log- JSON logs at levellog.level.fileand abovelogs/error.log- JSON logs at levelerrorand above- Console - Human-readable logs at level
log.level.consoleand above
To get started: clone the Opentrons/opentrons repository, set up your computer for development as specified in the project readme, and then:
# prerequisite: install dependencies as specified in project setup
make setup
# change into the app-shell directory
cd app-shell
# install dependencies
make setup
# launch the electron app in dev mode
make devYou probably want to be developing from the app directory instead. Its make dev task will automatically call make dev here in app-shell.
The desktop application shell uses:
The desktop shell has no tests at this time.
This section details production build instructions for the desktop application.
electron-builder requires some native dependencies to build and package the app (see the electron-builder docs).
-
macOS - None
-
Windows - None
-
Linux - icnsutils, graphicsmagick, and xz-utils
sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils
make- Default target is "clean package"make clean- Delete the dist foldermake package- Creates a production package of the app for running and inspection (does not create a distributable)
All packages and/or distributables will be placed in app-shell/dist. After running make package, you can launch the production app with:
- macOS:
./dist/mac/Opentrons.app/Contents/MacOS/Opentrons - Linux:
./dist/linux-unpacked/opentrons - Windows:
./dist/win-unpacked/Opentrons.exe
To run the production app in debug mode, set the DEBUG environment variable. For example, on macOS:
DEBUG=1 ./dist/mac/Opentrons.app/Contents/MacOS/OpentronsThere are a series of tasks designed to be run in CI to create distributable versions of the app.
# Create a macOS distributable of the app
make dist-osx OT_APP_DEPLOY_BUCKET=opentrons-app OT_APP_DEPLOY_FOLDER=builds
# Create a Linux distributable of the app
make dist-linux OT_APP_DEPLOY_BUCKET=opentrons-app OT_APP_DEPLOY_FOLDER=builds
# Create macOS and Linux apps simultaneously
make dist-posix OT_APP_DEPLOY_BUCKET=opentrons-app OT_APP_DEPLOY_FOLDER=builds
# Create a Windows distributable of the app
make dist-win OT_APP_DEPLOY_BUCKET=opentrons-app OT_APP_DEPLOY_FOLDER=buildsThese tasks use the following environment variables defined:
| name | description | required | description |
|---|---|---|---|
| OT_APP_DEPLOY_BUCKET | AWS S3 bucket | yes | Artifact deploy bucket |
| OT_APP_DEPLOY_FOLDER | AWS S3 folder | yes | Artifact deploy folder in bucket |
| OT_BRANCH | Branch name | no | Sometimes added to the artifact name |
| OT_BUILD | Build number | no | Appended to the artifact name |
| OT_TAG | Tag name | no | Flags autoupdate files to be published |
The release channel is set according to the version string:
vM.m.p-alpha.x- "alpha" channelvM.m.p-beta.x- "beta" channelvM.m.p- "latest" channel
The electron-updater autoupdate files (e.g. beta-mac.yml) will only be copied to the publish directory if OT_TAG is set.
