GithubHelp home page GithubHelp logo

chengat1314 / qds-sdk-py Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qubole/qds-sdk-py

1.0 1.0 0.0 735 KB

Python SDK for accessing Qubole Data Service

Home Page: https://qubole.com

License: Apache License 2.0

Python 100.00%

qds-sdk-py's Introduction

Qubole Data Service Python SDK

Build Status

A Python module that provides the tools you need to authenticate with, and use the Qubole Data Service API.

Installation

From PyPI

The SDK is available on PyPI.

$ pip install qds-sdk

From source

  • Download the source code:
  • Run the following command (may need to do this as root):

    $ python setup.py install
  • Alternatively, if you use virtualenv, you can do this:

    $ cd qds-sdk-py
    $ virtualenv venv
    $ source venv/bin/activate
    $ python setup.py install

This should place a command line utility qds.py somewhere in your path

$ which qds.py
/usr/bin/qds.py

CLI

qds.py allows running Hive, Hadoop, Pig, Presto and Shell commands against QDS. Users can run commands synchronously - or submit a command and check its status.

$ qds.py -h  # will print detailed usage

Examples:

  1. run a hive query and print the results

    $ qds.py --token 'xxyyzz' hivecmd run --query "show tables"
    $ qds.py --token 'xxyyzz' hivecmd run --script_location /tmp/myquery
    $ qds.py --token 'xxyyzz' hivecmd run --script_location s3://my-qubole-location/myquery
  2. pass in api token from bash environment variable

    $ export QDS_API_TOKEN=xxyyzz
  3. run the example hadoop command

    $ qds.py hadoopcmd run streaming -files 's3n://paid-qubole/HadoopAPIExamples/WordCountPython/mapper.py,s3n://paid-qubole/HadoopAPIExamples/WordCountPython/reducer.py' -mapper mapper.py -reducer reducer.py -numReduceTasks 1 -input 's3n://paid-qubole/default-datasets/gutenberg' -output 's3n://example.bucket.com/wcout'
  4. check the status of command # 12345678

    $ qds.py hivecmd check 12345678
    {"status": "done", ... }
  5. If you are hitting api_url other than api.qubole.com, then you can pass it in command line as --url or set in as env variable

    $ qds.py --token 'xxyyzz' --url https://<env>.qubole.com/api hivecmd ...
    
    or
    
    $ export QDS_API_URL=https://<env>.qubole.com/api

SDK API

An example Python application needs to do the following:

  1. Set the api_token and api_url (if api_url other than api.qubole.com):

    from qds_sdk.qubole import Qubole
    
    Qubole.configure(api_token='ksbdvcwdkjn123423')
    
    # or
    
    Qubole.configure(api_token='ksbdvcwdkjn123423', api_url='https://<env>.qubole.com/api')
  2. Use the Command classes defined in commands.py to execute commands. To run Hive Command:

    from qds_sdk.commands import *
    
    hc=HiveCommand.create(query='show tables')
    print "Id: %s, Status: %s" % (str(hc.id), hc.status)

example/mr_1.py contains a Hadoop Streaming example

Reporting Bugs and Contributing Code

  • Want to report a bug or request a feature? Please open an issue.
  • Want to contribute? Fork the project and create a pull request with your changes against unreleased branch.

qds-sdk-py's People

Contributors

rohitagarwal003 avatar shahharsh87 avatar adityaka avatar msumit avatar tanishgupta1 avatar rjainqb avatar prakharjain09 avatar vrajat avatar guptavishal avatar yogeshg-qubole avatar randgalt avatar chattarajoy avatar abshkmodi avatar sriram137 avatar rohitpruthi95 avatar rahul26goyal avatar nitinik avatar mrwalker avatar harshashah16 avatar anumahadevan avatar ashubhumca avatar ionrock avatar karandeep-johar avatar namratasqubole avatar praveenseluka avatar rishi-nextdoor avatar vaibhavsagar avatar akaranjkar-qu avatar ksr-qubole avatar nitin12388 avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.