Running Python scripts in sandbox container by using developer utilities

You can use the sandbox container to develop various functions by using python and connecting to a Presto (Java) engine.

watsonx.data Developer edition

About this task

To work with the sandbox container, complete the following steps:

Procedure

  1. Set the variable "LH_SANDBOX_DIR" with the folder path. For example: export LH_SANDBOX_DIR=/home/jmouse/mysandbox. For more information, see on how to setup sandbox directory, see Sandbox directory.
    export LH_SANDBOX_DIR=<folder_path>
  2. Run the following command to start the sandbox environment.
     bin/dev-sandbox
    Note: The environment variables are set inside the sandbox container to help you with scripting and to avoid hardcoding.
  3. Run the following commands to get the details of the engine host and engine password:
    • In the Python environment, import os and check for the engine host and engine password from the following commands:
      import os
      os.environ['ENG_HOST']
      os.environ['ENG_PASSWORD']
  4. Use sandbox to run python file from the sandbox directory by using the command python3 <path of python file to be run> as shown in the following example where 'sample.py' is the python file:
     python3 /home/jmouse/mysandbox/sample.py
    Note: Type 'exit' to exit from the sandbox container.