This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A client application for Ambry libraries. The client presents a simple interface that returns acessors objects, providing a thin attrubute interface on the dictionaries you normally get by directly converting the JSON objects the library returns.

Installation

$ pip install ambry-client

Command Line Client

The ambry-client package also installs a command line program ambrydl. Run ambrydl -h for the help message. If you want download all of the public files from a library:

$ ambrydl http://example.com

If the files in the library are not public, you will need to set a username and secret. ( Note that the secret is used for the API, and is different from the password, which is used in the web UI )

$ ambrydl -u eric -s ABwq9ZAch3Jiy4CPce8r http://example.com

If you want to download a subset of the files, you can specify a subset of datasets or files using their vid or vnames. These are viewable in the web interface, or using the ambrydl -l command. These values look like:

  • File vid: p03r003003
  • File name: oshpd.ca.gov-pqi-pqi-county-0.0.3
  • Dataset vid: d03r003
  • Dataset vname: oshpd.ca.gov-pqi-0.0.3

Using one or more of these names, you can download specific files, or all of the files in a dataset:

$ ambrydl http://example.com d03r003 cdph.ca.gov-hci-abuse_neglect-california

By default, the files will be written with the cache key, which is the standard path name for ambry files. You can also use the -v option to write the file names using the vid, or -n to write the files using the vname.

Authentication

To authenticate with the command line client, use the -u option to specify a username, and the -s option to specify a secret. These values can be set on the server site using the ambry ui user add command.

API

The Client object has these methods:

  • list() Return a list of Dataset objects, one for each dataset in the library. The Dataset objects have a limited number of fields, fewer than those returned by dataset()
  • dataset(ref) Return a dataset, with all of the fields. Most significantly is the partitions property, which holds records for all of the files in the dataset.
  • partition(ref) Return a partition, with all of its fields.

If you use list() to get datasets, they will have a subset of the available fields, to make the reuqest faster. To get the complete list use the Dataset.detailed property to re-request all of the fields.

Locating Properties

There are a lot of properties for each object, dynamically generated from the response from the Library server. To get a sense of what properties are available, you can either iterate over the Dataset or Partition object as a dictionary, using keys(), values() or items(), or view the JSON output on the Library website, available from the blue ‘{json}’ buttons in the footer.

Writing Files

The Partition object have several methods for acessing row information and writing CSV files:

  • rows returns an iterator, over the rows in the file. The first row is the header
  • csvlines returns an iterator, iterating over CSV formatted lines.
  • write_csv(path) writes the data in the partition to a CSV file.

Example

Here is a simple example of iterating over all of the partitions in a library, printing out the dataset and partition titles, and writing CSV files:

from ambry_client import Client
import os

base_url = 'http://localhost:8080'

client = Client(base_url, username, secret)

for ds in client.list():

    print ds.vid, ds.title

    for p in ds.partitions:
        print '  ', p.vid, p.description

        fn = '{}.csv'.format(p.vid)

        if not os.path.exists(fn):
            p.write_csv(fn)
Release History

Release History

0.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ambry-client-0.0.2.tar.gz (9.7 kB) Copy SHA256 Checksum SHA256 Source Jan 15, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting