Skip to main content

Genie Python Client.

Project description

=================== Genie Python Client

This package provides a robust client for interacting with an existing Genie service. Included are modules for the resource models (Application, Command, Cluster, Job, etc), exceptions and retry logic wrappers for API calls.

For more documentation on Genie and its available API's see the Genie GitHub <http://netflix.github.io/genie/>_ page.

Examples

Configuration Service Example


This example shows how to register a new application with a running Genie instance. Similar processes can be followed
for registering clusters and commands as well as relating all three to each other.

::

    import genie2.client.wrapper
    import genie2.model.Application

    # Create a Genie client which proxies API calls through wrapper which retries failures based on various return codes
    genie = genie2.client.wrapper.Genie2("http://localhost:7001/genie", genie2.client.wrapper.RetryPolicy(tries=8, none_on_404=True, no_retry_http_codes=range(400, 500)))

    # Create a new application instance and set required fields
    app = genie2.model.Application.Application()
    app.name = "exampleAppName"
    app.user = "exampleUser"
    app.version = "0.0.1"
    app.status = "ACTIVE"

    # Save the application to the service
    created_app = genie.createApplication(app)
    print created_app.id

    # Retrieve the application by ID
    got_app = genie.getApplication(created_app.id)
    print got_app.name

    # Delete the application by ID
    deleted_app = genie.deleteApplication(got_app.id)
    print deleted_app.id


Execution Service Example
~~~~~~~~~~~~~~~~~~~~~~~~~

This example shows how to execute a job on Genie. In this case it's running a `Presto <http://prestodb.io/>`_ query.
This assumes the Presto cluster has already been configured with Genie and the command registered.

::

    import genie2.client.wrapper
    import genie2.model.Job
    import genie2.model.ClusterCriteria

    # Create a Genie client which proxies API calls through wrapper which retries failures based on various return codes
    genie = genie2.client.wrapper.Genie2("http://localhost:7001/genie", genie2.client.wrapper.RetryPolicy(tries=8, none_on_404=True, no_retry_http_codes=range(400, 500)))

    # Create a job instance and fill in the required parameters
    job = genie2.model.Job.Job()
    job.name = "GeniePythonClientExampleJob"
    job.user = "tgianos"
    job.version = "0.0.1"

    # Create a list of cluster criterias which determine the cluster to run the job on
    cluster_criterias = list()
    cluster_criteria = genie2.model.ClusterCriteria.ClusterCriteria()
    criteria = set()
    criteria.add("presto")
    criteria.add("prod")
    cluster_criteria.tags = criteria
    cluster_criterias.append(cluster_criteria)
    job.clusterCriterias = cluster_criterias

    # Create the set of command criteria which will determine what command Genie executes for the job
    command_criteria = set()
    command_criteria.add("presto")
    job.commandCriteria = command_criteria

    # Any command line arguments to run along with the command. In this case it holds the actual query but this
    # could also be done via an attachment or file dependency.
    job.commandArgs = "--execute \"show tables;\""

    # Submit the job to Genie
    running_job = genie.submitJob(job)

    # Check on the status of the job
    job_status = genie.getJobStatus(running_job.id)
    print job_status




Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nflx-genie-client-3.6.8.tar.gz (44.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

nflx_genie_client-3.6.8-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

nflx_genie_client-3.6.8-py2-none-any.whl (56.0 kB view details)

Uploaded Python 2

File details

Details for the file nflx-genie-client-3.6.8.tar.gz.

File metadata

  • Download URL: nflx-genie-client-3.6.8.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

File hashes

Hashes for nflx-genie-client-3.6.8.tar.gz
Algorithm Hash digest
SHA256 e44a40ea32d0705cd19a39fd32eb36760e8c8eaf9a8fb21602f34a147f53e262
MD5 f6f2d02cb707854ef5277c6be4ba9795
BLAKE2b-256 48cf13cbc119b9918c6d4dff990d2a1e806b5b141a4bd3854ee54e1f4f5c6ea8

See more details on using hashes here.

File details

Details for the file nflx_genie_client-3.6.8-py3-none-any.whl.

File metadata

  • Download URL: nflx_genie_client-3.6.8-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.3

File hashes

Hashes for nflx_genie_client-3.6.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7dcb1efbc7cce2c537e039f30ed686454843b236c135dc14d25080b2e754bdd5
MD5 d47e8ea7cdc5f4ff7e9b66e87106956d
BLAKE2b-256 bd8fca069763367cd48d41ba871f3c7e8eb2eb8c87d532e52da4eefeacdb0dca

See more details on using hashes here.

File details

Details for the file nflx_genie_client-3.6.8-py2-none-any.whl.

File metadata

  • Download URL: nflx_genie_client-3.6.8-py2-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.14

File hashes

Hashes for nflx_genie_client-3.6.8-py2-none-any.whl
Algorithm Hash digest
SHA256 cdd61d95d717829a72c55f1f0eb5cc6b9ab7b55c2c68114315ea932dc4d52aa3
MD5 60ae64594ad26d5e957940c242cf628b
BLAKE2b-256 4476e44a5304c0c63d0f63279c8bb6d5dbd0a2606f5faaae94804c0140a65bc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page