Created on
03-24-2020
02:46 AM
- edited on
09-02-2020
03:57 PM
by
cjervis
With the recent addition of Analytical Applications, data scientists and data engineers can now deploy their own custom applications and share them with other users.
Whilst simple applications may have all necessary code already baked into one script file, more complicated applications may require custom launchers, run flags that are set on execution and parameters that may be instance specific. In order to run these applications, we can leverage the Python subprocess module to run the commands that we would normally have manually entered into the terminal.
For this demonstration, I will show how to run Tensorboard and Hiplot, where both allow for the visualization of parameters from multiple runs of deep learning models.
Both applications rely on a custom command to trigger them as standalone applications: tensorboard for Tensorboard and hiplot for Hiplot.
bash !pip3 install -r requirements.txt
# Hiplot
import os
import subprocess
subprocess.call(['hiplot', '--host', '127.0.0.1', '--port', os.environ['CDSW_APP_PORT'] ])
I save this out in the run-hiplot.py script. The os.environ["CDSW_APP_PORT] command calls the environment variable CDSW_APP_PORT which specifies which port the application must use in order to run successfully.# Tensorboard
import os
import subprocess
subprocess.call(["tensorboard", " --logdir=logs/fit", "--host", "127.0.0.1", "--port", os.environ["CDSW_APP_PORT"]])
I save this out in the run-tensorboard.py script.For this demonstration, I will generate some data to populate tensorboard first.
Now that we have the script, we can go ahead and trigger it as an application:
The new Analytical Applications function rolled out in CDSW 1.7.x and available in CML - Public Cloud enables the deployment of third-party and custom applications on Cloudera Machine Learning infrastructure.
Through the use of the Python subprocess module, it is possible to execute arbitrary code and set runtime flags for applications as well.
Happy Coding!