Project Environment Variables
Sometimes your code needs to use secrets, such as passwords and authentication tokens, in order to access external resources.
In general, Cloudera recommends that you not paste secrets into your code. Anyone with read access to your project would be able to view the secrets. Even if you did not give anyone read access, you would have to remember to carefully check any code that you copy and paste into another project, or add to a Git repository.
These environment variables are set in every engine that runs in your project. The code samples that follow show how to access the environment variable DATABASE_PASSWORD from your code.
database.password <- Sys.getenv("DATABASE_PASSWORD")
import os database_password = os.environ["DATABASE_PASSWORD"]
Engine Environment Variables
The following table lists environment variables that can be set by default in every engine.
The project to which this engine belongs.
The username of the creator of this engine.
The ID of this engine. For sessions, this appears in your browser's URL bar.
If this engine is a worker, this is the CDSW_ENGINE_ID of its master.
If this engine is a worker, this is the IP address of its master.
A port on which you can expose HTTP services in the engine to users' browsers. HTTP services that bind CDSW_PUBLIC_PORT will be available in users' browsers at: http(s)://<$CDSW_ENGINE_ID>.<$CDSW_DOMAIN>.
The domain on which Cloudera Data Science Workbench is being served. This can be useful for iframing services, as in the Shiny example.
The number of CPU cores allocated to this engine, expressed in thousandths of a core.
The number of megabytes of memory allocated to this engine.
Other engines in the Cloudera Data Science Workbench cluster can contact this engine on this IP address.