Welcome to Wespe’s documentation!

Wespe - Batching ad tech providers’ operations for humans

BuildStatus CoverageStatus Codacy Docs PyPi License

Abstract

What is Wespe?

Wespe is a Python API for batching requests when interfacing AdTech providers (e.g. adwords, facebook business). The motivation behind Wespe is to provide a simple and consistent interface for batching requests. Currently it only supports Facebook Business. Other providers will be added in the future.

Read the docs: http://wespe.readthedocs.io/en/latest/

Installation

Wespe supports python 3.6+. It may also work on pypy, cython, and jython, but is not being tested for these versions.

To install Wespe run the following command:

pip install wespe

Usage - Facebook Business

All steps from now on will assume you’ve already set the default api connection using facebook_busines. It’s also possible to set one on the fly by providing the api kwarg in FacebookBatchUploader’s constructor.

from wespe.batch_uploaders import FacebookBatchUploader

# There is no request limit. If necessary Wespe will coordinate the execution of multiple FacebookAdsApiBatch
# instances.
batch_uploader = FacebookBatchUploader(requests)

try:
    batch_uploader.execute()
except BatchExecutionError:
    for error in batch_uploader.errors:
        # See FacebookBatchRequestError for more info on what you can do
        pass

for response in batch_uploader.responses:
    # See FacebookBatchResponse for more info on what you can do
    pass

License

Copyright 2016 KAYAK Germany, GmbH

Licensed 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

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.

Crafted with ♥ in Berlin.

Installation

Stable release

To install Wespe, run this command in your terminal:

$ pip install wespe

This is the preferred method to install Wespe, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for Wespe can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/x8lucas8x/wespe

Or download the tarball:

$ curl  -OL https://github.com/kayak/wespe/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage - Facebook Business

All steps from now on will assume you’ve already set the default api connection using facebook_busines. It’s also possible to set one on the fly by providing the api kwarg in FacebookBatchUploader’s constructor.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 from wespe.batch_uploaders import FacebookBatchUploader

 # There is no request limit. If necessary Wespe will coordinate the execution of multiple FacebookAdsApiBatch
 # instances.
 batch_uploader = FacebookBatchUploader(requests)

 try:
     batch_uploader.execute()
 except BatchExecutionError:
     for error in batch_uploader.errors:
         # See FacebookBatchRequestError for more info on what you can do
         pass

 for response in batch_uploader.responses:
     # See FacebookBatchResponse for more info on what you can do
     pass

wespe

wespe package

Subpackages

wespe.batch_uploaders package
Submodules
wespe.batch_uploaders.facebook module
wespe.batch_uploaders.requests module
class wespe.batch_uploaders.requests.BaseRequestError(description: str, is_transient: bool, data: dict)[source]

Bases: object

data

Returns the entire error payload response.

Returns:a dictionary.
description

Returns an error description.

Returns:a string.
is_transient

Returns True when the error is likely to be caused by a temporary issue (e.g. network issue). This should be used as a way to identify which requests can be retried without further modifications.

Returns:a boolean.
class wespe.batch_uploaders.requests.BaseResponse(data: dict)[source]

Bases: object

data

Returns the entire payload response.

Returns:a dictionary.
wespe.batch_uploaders.retries module
Module contents

Submodules

wespe.exceptions module

exception wespe.exceptions.BaseException[source]

Bases: Exception

All errors specific to to this library will be subclassed from BaseException.

exception wespe.exceptions.BatchExecutionError[source]

Bases: OSError, wespe.exceptions.BaseException

exception wespe.exceptions.InvalidValueError[source]

Bases: ValueError, wespe.exceptions.BaseException

exception wespe.exceptions.NoFacebookRequestProvidedError[source]

Bases: wespe.exceptions.InvalidValueError

exception wespe.exceptions.TooManyRequestsPerBatchError[source]

Bases: wespe.exceptions.InvalidValueError

Module contents

Top-level package for Wespe.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/kayak/wespe/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

Wespe could always use more documentation, whether as part of the official Wespe docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/kayak/wespe/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up wespe for local development.

  1. Fork the wespe repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/wespe.git
    

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

$ mkvirtualenv wespe
$ cd wespe/
$ python setup.py develop
  1. Install the commit hooks, which includes an auto formatter:

    $ pre-commit install
    
  2. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

6. When you’re done making changes, check that your changes pass for all python versions that we support, including flake8 rules, by running tox:

$ tox
  1. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  2. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 3.4, 3.5 and 3.6. Check https://travis-ci.org/x8lucas8x/wespe/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ py.test tests.test_wespe

Deploying

A reminder for the maintainers on how to deploy. Make sure all your changes are committed. Then run:

$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.

Indices and tables