Peter Rudenko avatar Peter Rudenko committed b8ac4ab

Temleton pig API

Comments (0)

Files changed (15)

templeton/Makefile

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-ifeq ($(ROOT),)
-  $(error "Error: Expect the environment variable $$ROOT to point to the Desktop installation")
-endif
-
-include $(ROOT)/Makefile.sdk

templeton/setup.py

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-from setuptools import setup, find_packages
-import os
-
-def expand_package_data(src_dirs, strip=""):
-  ret = []
-  for src_dir in src_dirs:
-    for path, dnames, fnames in os.walk(src_dir):
-      for fname in fnames:
-        ret.append(os.path.join(path, fname).replace(strip, ""))
-  return ret
-
-os.chdir(os.path.dirname(os.path.abspath(__file__)))
-setup(
-  name = "templeton",
-  version = "0.1",
-  url = 'TODO',
-  description = 'TODO',
-  author = 'TODO',
-  packages = find_packages('src'),
-  package_dir = {'': 'src'},
-  install_requires = ['setuptools', 'desktop'],
-  entry_points = { 'desktop.sdk.application': 'templeton=templeton' },
-  zip_safe = False,
-  package_data = {
-    # Include static resources.  Package_data doesn't
-    # deal well with directory globs, so we enumerate
-    # the files manually.
-    'templeton': expand_package_data(
-      ["src/templeton/templates", "src/templeton/static"],
-      "src/templeton/")
-  }
-)

templeton/src/templeton/__init__.py

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.

templeton/src/templeton/api.py

-# -*- coding: utf-8 -*-
-import urllib
-import urllib2
-import simplejson as json
-
-
-TEMPLETON_URL = "http://ec2-75-101-199-141.compute-1.amazonaws.com:50111/templeton/v1/"
-
-
-class Templeton(object):
-
-    def __init__(self, user="hdfs"):
-        self.user = user
-
-    def get(self, url, data=None):
-        """
-        Make GET query to templeton url.
-        """
-        if data is not None:
-            data['user.name'] = self.user
-        else:
-            data = {"user.name": self.user}
-        data = urllib.urlencode(data)
-        response = urllib2.urlopen(TEMPLETON_URL + url + "?" + data)
-        return json.loads(response.read())
-
-    def post(self, url, data=None):
-        """
-        Make POST query to templeton url.
-        """
-        if data is not None:
-            data['user.name'] = self.user
-        else:
-            data = {"user.name": self.user}
-        data = urllib.urlencode(data)
-        req = urllib2.Request(TEMPLETON_URL + url, data)
-        response = urllib2.urlopen(req)
-        return json.loads(response.read())
-
-
-    def pig_query(self, execute=None, pig_file=None, statusdir=None, callback=None):
-        """
-        Create and queue a Pig job.
-
-        Keyword arguments:
-        user -- Hue/Hadoop user
-        execute -- String containing an entire, short pig program to run. (e.g. pwd)
-        file -- HDFS file name of a pig program to run. (One of either "execcute" or "file" is required )
-        statusdir -- A directory where Templeton will write the status of the Pig job. If
-                     provided, it is the caller's responsibility to remove this directory when done.
-        callback -- Define a URL to Optional be called upon job completion. You may embed a specific job
-                    ID into this URL using $jobId. This tag will be replaced in the callback URL with this job's job
-                    ID.
-
-        Returns dict:
-        id -- A string containing the job ID similar to "job_201110132141_0001".
-        info -- A JSON object containing the information returned when the job was queued.
-        """
-        if not any([execute, pig_file]):
-            raise Exception("""One of either "execcute" or "file" is required""")
-        data = {}
-        if execute:
-            data['execute'] = execute
-        if pig_file:
-            data['file'] = pig_file
-        if statusdir:
-            data['statusdir'] = statusdir
-        if callback:
-            data['callback'] = callback
-        return self.post("pig", data)
-
-    def check_job(self, job_id):
-        """
-        Check the status of a job and get related job information given its job ID.
-        """
-        return self.get("queue/%s" % job_id)
-
-    def show_hcat_tables(self, db="default"):
-        """
-        List the tables in an HCatalog database.
-        """
-        return self.get("ddl/database/%s/table" % db)['tables']
-
-
-
-if __name__ == "__main__":
-    t = Templeton()
-    #pig_query = t.pig_query(user="hdfs", execute="pwd")
-    #job = t.check_job(pig_query['id'])
-    #print job
-    print t.show_hcat_tables()

templeton/src/templeton/forms.py

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.

templeton/src/templeton/models.py

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.

templeton/src/templeton/settings.py

-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-DJANGO_APPS = [ "templeton" ]
-REQUIRES_HADOOP = False
-MENU_INDEX = 100
-ICON = "/templeton/static/art/templeton.png"
Add a comment to this file

templeton/src/templeton/static/art/templeton.png

Removed
Old image

templeton/src/templeton/static/css/templeton.css

-/* 
-	templeton styles
-	important: these should be namespaced
-	example:
-		let's say you are creating an app called "calculator"; you should prefix all your styles with your application's name like so
-		
-		.calculator img {
-			border: 1px solid #000;
-		}
-		.calculator p {
-			margin: 10px 0px;
-		}
-		etc...
-
-	other notes:
-	* don't use ids - there may be more than one of your apps open; use classes!
-	* the toolbar element is absolutely positioned and 100% wide (and therefor 0px high);
-	  any elements inside it should also be absolutely positioned
-*/
-
-.templeton img.templeton_icon {
-	width: 55px;
-	height: 55px;
-	position: absolute;
-	top: 27px;
-	left: 3px;
-}

templeton/src/templeton/static/help/index.md

-Help for your app, written in [MarkDown](http://daringfireball.net/projects/markdown/syntax) syntax.
Add a comment to this file

templeton/src/templeton/static/js/templeton.js

Empty file removed.

templeton/src/templeton/templates/index.mako

-<%!from desktop.views import commonheader, commonfooter %>
-<%namespace name="shared" file="shared_components.mako" />
-
-${commonheader("Templeton", "templeton", "100px")}
-${shared.menubar(section='mytab')}
-
-## Use double hashes for a mako template comment
-## Main body
-
-<div class="container-fluid">
-  <h2>Templeton app is successfully setup!</h2>
-  <p>It's now ${date}.</p>
-</div>
-${commonfooter()}

templeton/src/templeton/templates/shared_components.mako

-
-<%!
-def is_selected(section, matcher):
-  if section == matcher:
-    return "active"
-  else:
-    return ""
-%>
-
-<%def name="menubar(section='')">
-  <div class="subnav subnav-fixed">
-    <div class="container-fluid">
-      <ul class="nav nav-pills">
-        <li class="${is_selected(section, 'mytab')}"><a href="#">Tab 1</a></li>
-        <li class="${is_selected(section, 'mytab2')}"><a href="#">Tab 2</a></li>
-      </ul>
-    </div>
-  </div>
-</%def>

templeton/src/templeton/urls.py

-#!/usr/bin/env python
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from django.conf.urls.defaults import patterns, url
-
-urlpatterns = patterns('templeton',
-  url(r'^$', 'views.index'),
-)

templeton/src/templeton/views.py

-#!/usr/bin/env python
-# Licensed to Cloudera, Inc. under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  Cloudera, Inc. licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from desktop.lib.django_util import render
-import datetime
-
-def index(request):
-  return render('index.mako', request, dict(date=datetime.datetime.now()))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.