Community Articles

Find and share helpful community-sourced technical articles.
Announcements
Celebrating as our community reaches 100,000 members! Thank you!
avatar

Throughout my seven years working with Cloudera/Hortonworks, I'm always learning new things.  One thing I've learned from the Cloudera/Hortonoworks merger was how amazing CDSW/CML is as a product.  CML isn't only for Data Scientists, it's for anyone that needs an IDE (Integrated Development Environment).  Coming from a development background working with Eclipse and IntelliJ, you become dependent on a solid IDE.

 

In the past, I've used IDEs to develop applications, and then a build process would eventually deploy to a run environment.  This is where CML shines, you're able to run your applications within CDP at scale with enormous amounts of data.  Anyone using CML is over the moon running their applications/projects within CML because of the simplicity, as I'll demonstrate below.  The tagline of CML is "BYOL" (Bring your own libraries), meaning ALL libraries are welcome (outside of the Cloudera ecosystem).  This differentiates Cloudera from others such as native Azure, where native Azure is HIGHLY dependent on all things Microsoft (unless the application owner created something native Azure-specific).  I'll demonstrate how easy deploying a third party such as Django "The web framework for perfectionists with deadlines." where the installation/run feels like you're running on your local laptop, instead of a highly scalable IDE that runs anywhere.  

 

Remember that CML runs ANYWHERE, within the cloud providers such as Azure, AWS, or GCP, and on-premise.  Cloudera abstracts out the complexities.  Using CML, we'll go from installing Django and then running Django in a matter of minutes.  

 

Step 1: Find the read-only URL to run your embedded application (Django)

 

import os
url=os.environ["CDSW_ENGINE_ID"]+"."+os.environ["CDSW_DOMAIN"]
print("http://read-only-%s"%url)

 

 

Step 2: Install Django

 

!pip install django

 

 

Step 3: Create a Django project as instructed here

 

!django-admin startproject mysite
cd mysite

 

 

Step 4: Modify the settings.py file adding the 'read-only-%s' value from step 1 and localhost

 

ALLOWED_HOSTS = ['localhost','read-only-yourhostnamefromstep1']

 

 

Step 5: Run Django

 

!python manage.py runserver localhost:$CDSW_READONLY_PORT

 

 

That's IT!  If you'd like to access your Django page, navigate to the URL in step 1!  Nothing specialized for CML, as we say BYOL!

django_ready.png

632 Views
0 Kudos