SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
OPENSHIFT
Workshop
PRESENTED
BY
Shekhar
Gulati
Bringing Spatial Love to your
Python Application
WHO AM I
•
Shekhar Gulati – Works at Red Hat
•
Principal OpenShift Developer Evangelist
•
Java / Python/ JavaScript / NoSQL / Cloud Guy
•
Twitter Handle : shekhargulati
•
Github https://github.com/shekhargulati
•
Slides http://www.slideshare.net/shekhargulati
AGENDA
➔ Learn a bit about Flask
➔ Learn some MongoDB basics
➔ Build a location aware Job search application
➔ Go live with a Flask MongoDB powered app in ~ 50
mins
Write an application and host it on internet
http://localjobsdemo-shekhargulati.rhcloud.com/
GOAL
CODE DU JOUR
https://github.com/shekhargulati/localjobs-python2.7
● You know Python
● You know Git
● You like to write code rather than managing
servers.
ASSUMPTIONS
The Tools
Flask , MongoDB , and OpenShift
FLASK
● Flask is a microframework for web application
development in Python
● Microframework refers to simplicity and small size of
framework
● It is inspired by Sinatra(Ruby framework to create
web apps with minimum fuss)
● Built on Werkzeug , Jinja2 , WSGI
● Good sensible defaults
FLASK
● Easy to learn – dead simple
● Simple but extensible
● Excellent documentation spread over 280 pages with
lots of examples
● Very active community
● It has minimal footprint
● Does not make choice for you
● Unit testing support
WHY FLASK?
$ mkdir flask-demo
$ cd flask-demo
$ virtualenv venv
--python=python2.7
$ . venv/bin/activate
$ pip install flask
$ touch app.py
$ python app.py
FLASK : GETTING STARTED
● Look under templates
for templates (default
jinja2)
● Look under static for
assets (CSS , JS , etc.)
FLASK DEFAULTS
RESTFUL REQUEST DISPATCHING
MONGODB
15

Open Source NoSQL document datastore
– JSON style documents

Schema-less
– Each document is heterogeneous, and may have completely unique
structure compared to other documents

Fast and horizontally scalable

Rich query language

Rich documents

Easy to get running

Geospatial indexing
WHAT IS MONGODB
Database → Database
Table → Collection
Row → JSON Document
Index → Index
Join → Embedding
STEP 4 :
MONGODB TERMINOLOGY
17

What is it for?

Find all the MongoDB jobs near me – Proximity Queries

Find all the MongoDB jobs within Tokyo – Bounded Queries

Find all the MongoDB job at this location – Exact Queries
●
Supports only two dimensional indexes.

You can only have one geospatial index per collection.

By default, 2d geospatial indexes assume longitude and
latitude have boundaries of -180 inclusive and 180 non-
inclusive (i.e. [-180, 180))
GEOSPATIAL INDEXING
BASICS
18
1) Put your coordinates into an array
{ loc : [ 50 , 30 ] } //SUGGESTED OPTION
{ loc : { x : 50 , y : 30 } }
{ loc : { foo : 50 , y : 30 } }
1) { loc : { lon : 40.739037, lat: 73.992964 } }
2) Make a 2d index
db.jobs.ensureIndex( { loc : "2d" } )
3) If you use latitude and longitude as your coordinate system,
always store longitude first. MongoDB’s 2d spherical index
operators only recognize [ longitude, latitude] ordering.
HOW TO MAKE IT WORK
19
// Find all the jobs with skill as mongodb
db.jobs.find({"skills":"mongodb"})
// Find all the jobs with python as skill and
near to given location
db.jobs.find({"lngLat":{$near :
[139.69 , 35.68]},
"skills":"python"})
// Find all the python or mongodb jobs
near to given location
db.jobs.find({"lngLat":{$near :
[139.69 , 35.68]},
"skills":{$in :
["mongodb","python"]}})
SOME QUERIES
Platform as a Service delivers
• Application run-time environment in the cloud
• Configures & manages both the cloud & stack for your
application
“The cloud is now useful!”
origin
Public
Cloud
Service
On-
premise
or Private
Cloud
Software
Open
Source
Project
FLAVORS OF OPENSHIFT
23
OUR STACK
24
https://openshift.redhat.com/app/account/new
Promo code is PYCONAPAC
CREATING OPENSHIFT
ACCOUNT
● Free! No time limit
● 3 gears (like servers) - each 512 Mb RAM, 1 Gb disk
● Auto-scaling
● Simple pricing
BUT WAIT – THERE's MORE
1) Create Python 2.7 OpenShift
Application
2) Add MongoDB database
3) Pull source code from github
4) Import data into MongoDB
5) Push the changes to
Application
DEMO
rhc app create localjobs python-2.7
CREATE APPLICATION
rhc cartridge add mongodb-2.2 --app localjobs
ADD CARTRIDGE
git remote add upstream -m master
https://github.com/shekhargulati/localjobs-python2.7.git
git pull -s recursive -X theirs upstream master
PULL SOURCECODE
● Step 1 : Application Setup , User Registration , User login
– git checkout 005ce14038f489b16249a28be84c035cad99b2b8
● Step 2 : Create New Job
– git checkout e96e5d19f28ae8aaa33c1cce283daef98c4ff124
● Step 3 : Search with Near
– git checkout 06a388f003fbfec51c6cee1763bae3cf96b58185
● Step 4 : Search with GeoNear
– git checkout 653e830dfecf5e7df31016be14e89d5daadb84ee
● Step 5 : OpenShift Application
– git checkout master
CODE WALKTHROUGH
$ rhc show-app
$ scp jobs-data.json <ssh url>:app-root/data
$ rhc ssh
$ cd app-root/data
$ mongoimport -d localjobs -c jobs --file jobs-data.json -u
$OPENSHIFT_MONGODB_DB_USERNAME -p
$OPENSHIFT_MONGODB_DB_PASSWORD -h
$OPENSHIFT_MONGODB_DB_HOST -port
$OPENSHIFT_MONGODB_DB_PORT
IMPORT DATA INTO MONGODB
git push
DEPLOY APP
rhc create-app localjobs python-2.7 mongodb-2.2
--enable-jenkins -s --from-code
https://github.com/shekhargulati/localjobs-python2.7.git
LOT MORE GOODIES
AutoScaling + Jenkins
QUESTIONS?
DONE!

Más contenido relacionado

La actualidad más candente

Mongo sf spatialmongo
Mongo sf spatialmongoMongo sf spatialmongo
Mongo sf spatialmongoSteven Pousty
 
Monitoramento com ELK - Elasticsearch - Logstash - Kibana
Monitoramento com ELK - Elasticsearch - Logstash - KibanaMonitoramento com ELK - Elasticsearch - Logstash - Kibana
Monitoramento com ELK - Elasticsearch - Logstash - KibanaWaldemar Neto
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Minh Dao
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUPRonald Hsu
 
Functional Programming In JS
Functional Programming In JSFunctional Programming In JS
Functional Programming In JSDamian Łabas
 
Cloud storage: the right way OSS EU 2018
Cloud storage: the right way OSS EU 2018Cloud storage: the right way OSS EU 2018
Cloud storage: the right way OSS EU 2018Orit Wasserman
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012Steven Pousty
 
Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014N Masahiro
 
FluentD for end to end monitoring
FluentD for end to end monitoringFluentD for end to end monitoring
FluentD for end to end monitoringPhil Wilkins
 
Modern Monitoring - SysAdminDay 2017
Modern Monitoring - SysAdminDay 2017Modern Monitoring - SysAdminDay 2017
Modern Monitoring - SysAdminDay 2017Opsta
 
Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUN Masahiro
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually restJakub Riedl
 
Introduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jsIntroduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jschuck h
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLAlex Sharp
 
Fluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker containerFluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker containerTreasure Data, Inc.
 

La actualidad más candente (20)

Fluent Bit
Fluent BitFluent Bit
Fluent Bit
 
Fluent-bit
Fluent-bitFluent-bit
Fluent-bit
 
Mongo sf spatialmongo
Mongo sf spatialmongoMongo sf spatialmongo
Mongo sf spatialmongo
 
Monitoramento com ELK - Elasticsearch - Logstash - Kibana
Monitoramento com ELK - Elasticsearch - Logstash - KibanaMonitoramento com ELK - Elasticsearch - Logstash - Kibana
Monitoramento com ELK - Elasticsearch - Logstash - Kibana
 
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
Cloud Firestore – From JSON Deserialization to Object Document Mapping (ODM)
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP
 
Functional Programming In JS
Functional Programming In JSFunctional Programming In JS
Functional Programming In JS
 
Cloud storage: the right way OSS EU 2018
Cloud storage: the right way OSS EU 2018Cloud storage: the right way OSS EU 2018
Cloud storage: the right way OSS EU 2018
 
Serverless haskell
Serverless haskellServerless haskell
Serverless haskell
 
OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012OpenShift with Eclipse Tooling - EclipseCon 2012
OpenShift with Eclipse Tooling - EclipseCon 2012
 
Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014Fluentd: Unified Logging Layer at CWT2014
Fluentd: Unified Logging Layer at CWT2014
 
FluentD for end to end monitoring
FluentD for end to end monitoringFluentD for end to end monitoring
FluentD for end to end monitoring
 
Modern Monitoring - SysAdminDay 2017
Modern Monitoring - SysAdminDay 2017Modern Monitoring - SysAdminDay 2017
Modern Monitoring - SysAdminDay 2017
 
Spark + i python
Spark + i pythonSpark + i python
Spark + i python
 
Fluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EUFluentd Project Intro at Kubecon 2019 EU
Fluentd Project Intro at Kubecon 2019 EU
 
GraphQL is actually rest
GraphQL is actually restGraphQL is actually rest
GraphQL is actually rest
 
Introduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jsIntroduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.js
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Bldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSLBldr: A Minimalist JSON Templating DSL
Bldr: A Minimalist JSON Templating DSL
 
Fluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker containerFluentd and Docker - running fluentd within a docker container
Fluentd and Docker - running fluentd within a docker container
 

Similar a Bringing spatial love to your python application

Mongo db bangalore
Mongo db bangaloreMongo db bangalore
Mongo db bangaloreMongoDB
 
Building spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBBuilding spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBShekhar Gulati
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
 
Spatial mongo for PHP and Zend
Spatial mongo for PHP and ZendSpatial mongo for PHP and Zend
Spatial mongo for PHP and ZendSteven Pousty
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB
 
Mongodb open data day 2014
Mongodb open data day 2014Mongodb open data day 2014
Mongodb open data day 2014David Green
 
Fandogh Cloud workshop slides
Fandogh Cloud workshop slides Fandogh Cloud workshop slides
Fandogh Cloud workshop slides ssarabadani
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharpSerdar Buyuktemiz
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesAndrás Fehér
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code維佋 唐
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMatt Lord
 
MongoDB & Hadoop, Sittin' in a Tree
MongoDB & Hadoop, Sittin' in a TreeMongoDB & Hadoop, Sittin' in a Tree
MongoDB & Hadoop, Sittin' in a TreeMongoDB
 
Run your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloudRun your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloudwesley chun
 
Webinar: Building Your First App
Webinar: Building Your First AppWebinar: Building Your First App
Webinar: Building Your First AppMongoDB
 
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...Ortus Solutions, Corp
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless worldMatthias Luebken
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3sHaggai Philip Zagury
 
AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...Luciano Mammino
 

Similar a Bringing spatial love to your python application (20)

Mongo db bangalore
Mongo db bangaloreMongo db bangalore
Mongo db bangalore
 
Building spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDBBuilding spatial back ends with Node.js and MongoDB
Building spatial back ends with Node.js and MongoDB
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Spatial mongo for PHP and Zend
Spatial mongo for PHP and ZendSpatial mongo for PHP and Zend
Spatial mongo for PHP and Zend
 
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDBMongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
MongoDB Days Silicon Valley: Winning the Dreamforce Hackathon with MongoDB
 
Mongodb open data day 2014
Mongodb open data day 2014Mongodb open data day 2014
Mongodb open data day 2014
 
Fandogh Cloud workshop slides
Fandogh Cloud workshop slides Fandogh Cloud workshop slides
Fandogh Cloud workshop slides
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Mongo db first steps with csharp
Mongo db first steps with csharpMongo db first steps with csharp
Mongo db first steps with csharp
 
Using MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 MinutesUsing MongoDB For BigData in 20 Minutes
Using MongoDB For BigData in 20 Minutes
 
New paradigms
New paradigmsNew paradigms
New paradigms
 
Parse cloud code
Parse cloud codeParse cloud code
Parse cloud code
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
 
MongoDB & Hadoop, Sittin' in a Tree
MongoDB & Hadoop, Sittin' in a TreeMongoDB & Hadoop, Sittin' in a Tree
MongoDB & Hadoop, Sittin' in a Tree
 
Run your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloudRun your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloud
 
Webinar: Building Your First App
Webinar: Building Your First AppWebinar: Building Your First App
Webinar: Building Your First App
 
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...
 

Más de Shekhar Gulati

Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7Shekhar Gulati
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShiftShekhar Gulati
 
Developing Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaDeveloping Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaShekhar Gulati
 
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSShekhar Gulati
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developersShekhar Gulati
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...Shekhar Gulati
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaShekhar Gulati
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftShekhar Gulati
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftShekhar Gulati
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudShekhar Gulati
 

Más de Shekhar Gulati (11)

Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7
 
Working effectively with OpenShift
Working effectively with OpenShiftWorking effectively with OpenShift
Working effectively with OpenShift
 
Developing Great Apps with Apache Cordova
Developing Great Apps with Apache CordovaDeveloping Great Apps with Apache Cordova
Developing Great Apps with Apache Cordova
 
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJS
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
Open shift for java(ee) developers
Open shift for java(ee) developersOpen shift for java(ee) developers
Open shift for java(ee) developers
 
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...Thinking beyond RDBMS  - Building Polyglot Persistence Java Applications Devf...
Thinking beyond RDBMS - Building Polyglot Persistence Java Applications Devf...
 
Java EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest AustriaJava EE 6 and NoSQL Workshop DevFest Austria
Java EE 6 and NoSQL Workshop DevFest Austria
 
Power up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShiftPower up Magnolia CMS with OpenShift
Power up Magnolia CMS with OpenShift
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShift
 
Indic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloudIndic threads java10-spring-roo-and-the-cloud
Indic threads java10-spring-roo-and-the-cloud
 

Último

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Bringing spatial love to your python application

  • 2. WHO AM I • Shekhar Gulati – Works at Red Hat • Principal OpenShift Developer Evangelist • Java / Python/ JavaScript / NoSQL / Cloud Guy • Twitter Handle : shekhargulati • Github https://github.com/shekhargulati • Slides http://www.slideshare.net/shekhargulati
  • 3. AGENDA ➔ Learn a bit about Flask ➔ Learn some MongoDB basics ➔ Build a location aware Job search application ➔ Go live with a Flask MongoDB powered app in ~ 50 mins
  • 4. Write an application and host it on internet http://localjobsdemo-shekhargulati.rhcloud.com/ GOAL
  • 6. ● You know Python ● You know Git ● You like to write code rather than managing servers. ASSUMPTIONS
  • 7. The Tools Flask , MongoDB , and OpenShift
  • 9. ● Flask is a microframework for web application development in Python ● Microframework refers to simplicity and small size of framework ● It is inspired by Sinatra(Ruby framework to create web apps with minimum fuss) ● Built on Werkzeug , Jinja2 , WSGI ● Good sensible defaults FLASK
  • 10. ● Easy to learn – dead simple ● Simple but extensible ● Excellent documentation spread over 280 pages with lots of examples ● Very active community ● It has minimal footprint ● Does not make choice for you ● Unit testing support WHY FLASK?
  • 11. $ mkdir flask-demo $ cd flask-demo $ virtualenv venv --python=python2.7 $ . venv/bin/activate $ pip install flask $ touch app.py $ python app.py FLASK : GETTING STARTED
  • 12. ● Look under templates for templates (default jinja2) ● Look under static for assets (CSS , JS , etc.) FLASK DEFAULTS
  • 15. 15  Open Source NoSQL document datastore – JSON style documents  Schema-less – Each document is heterogeneous, and may have completely unique structure compared to other documents  Fast and horizontally scalable  Rich query language  Rich documents  Easy to get running  Geospatial indexing WHAT IS MONGODB
  • 16. Database → Database Table → Collection Row → JSON Document Index → Index Join → Embedding STEP 4 : MONGODB TERMINOLOGY
  • 17. 17  What is it for?  Find all the MongoDB jobs near me – Proximity Queries  Find all the MongoDB jobs within Tokyo – Bounded Queries  Find all the MongoDB job at this location – Exact Queries ● Supports only two dimensional indexes.  You can only have one geospatial index per collection.  By default, 2d geospatial indexes assume longitude and latitude have boundaries of -180 inclusive and 180 non- inclusive (i.e. [-180, 180)) GEOSPATIAL INDEXING BASICS
  • 18. 18 1) Put your coordinates into an array { loc : [ 50 , 30 ] } //SUGGESTED OPTION { loc : { x : 50 , y : 30 } } { loc : { foo : 50 , y : 30 } } 1) { loc : { lon : 40.739037, lat: 73.992964 } } 2) Make a 2d index db.jobs.ensureIndex( { loc : "2d" } ) 3) If you use latitude and longitude as your coordinate system, always store longitude first. MongoDB’s 2d spherical index operators only recognize [ longitude, latitude] ordering. HOW TO MAKE IT WORK
  • 19. 19 // Find all the jobs with skill as mongodb db.jobs.find({"skills":"mongodb"}) // Find all the jobs with python as skill and near to given location db.jobs.find({"lngLat":{$near : [139.69 , 35.68]}, "skills":"python"}) // Find all the python or mongodb jobs near to given location db.jobs.find({"lngLat":{$near : [139.69 , 35.68]}, "skills":{$in : ["mongodb","python"]}}) SOME QUERIES
  • 20.
  • 21. Platform as a Service delivers • Application run-time environment in the cloud • Configures & manages both the cloud & stack for your application “The cloud is now useful!”
  • 25. ● Free! No time limit ● 3 gears (like servers) - each 512 Mb RAM, 1 Gb disk ● Auto-scaling ● Simple pricing BUT WAIT – THERE's MORE
  • 26. 1) Create Python 2.7 OpenShift Application 2) Add MongoDB database 3) Pull source code from github 4) Import data into MongoDB 5) Push the changes to Application DEMO
  • 27. rhc app create localjobs python-2.7 CREATE APPLICATION
  • 28. rhc cartridge add mongodb-2.2 --app localjobs ADD CARTRIDGE
  • 29. git remote add upstream -m master https://github.com/shekhargulati/localjobs-python2.7.git git pull -s recursive -X theirs upstream master PULL SOURCECODE
  • 30. ● Step 1 : Application Setup , User Registration , User login – git checkout 005ce14038f489b16249a28be84c035cad99b2b8 ● Step 2 : Create New Job – git checkout e96e5d19f28ae8aaa33c1cce283daef98c4ff124 ● Step 3 : Search with Near – git checkout 06a388f003fbfec51c6cee1763bae3cf96b58185 ● Step 4 : Search with GeoNear – git checkout 653e830dfecf5e7df31016be14e89d5daadb84ee ● Step 5 : OpenShift Application – git checkout master CODE WALKTHROUGH
  • 31. $ rhc show-app $ scp jobs-data.json <ssh url>:app-root/data $ rhc ssh $ cd app-root/data $ mongoimport -d localjobs -c jobs --file jobs-data.json -u $OPENSHIFT_MONGODB_DB_USERNAME -p $OPENSHIFT_MONGODB_DB_PASSWORD -h $OPENSHIFT_MONGODB_DB_HOST -port $OPENSHIFT_MONGODB_DB_PORT IMPORT DATA INTO MONGODB
  • 33. rhc create-app localjobs python-2.7 mongodb-2.2 --enable-jenkins -s --from-code https://github.com/shekhargulati/localjobs-python2.7.git LOT MORE GOODIES AutoScaling + Jenkins
  • 35. DONE!