Skip to main content

A library for running Python functions (callables) from git repositories in various states of isolation with integrating caching.

Project description

Arca

https://img.shields.io/travis/pyvec/arca.svg https://img.shields.io/codecov/c/github/pyvec/arca.svg https://img.shields.io/pypi/v/arca.svg https://img.shields.io/github/license/pyvec/arca.svg?style=flat https://img.shields.io/readthedocs/arca.svg

Arca is a library for running Python functions (callables) from git repositories in various states of isolation. Arca can also cache the results of these callables using dogpile.cache.

Getting started

Glossary

  • Arca - name of the library. When written as Arca, the main interface class is being referenced.

  • Task - definition of the function (callable), consists of a reference to the object and arguments.

  • Backend - a way of running tasks.

Installation

Requirements
  • Python >= 3.6

Requirements for certain backends:

Installation

To install the last stable version:

python -m pip install arca

If you want to use the Docker backend:

python -m  pip install arca[docker]

Or if you want to use the Vagrant backend:

python -m pip install arca[vagrant]

Or if you wish to install the upstream version:

python -m pip install git+https://github.com/pyvec/arca.git#egg=arca
python -m pip install git+https://github.com/pyvec/arca.git#egg=arca[docker]
python -m pip install git+https://github.com/pyvec/arca.git#egg=arca[vagrant]

Example

To run a Hello World example you’ll only need the arca.Arca and arca.Task classes. Task is used for defining the task that’s supposed to be run in the repositories. Arca takes care of all the settings and provides the basic API for running the tasks.

Let’s say we have the following file, called hello_world.py, in a repository https://example.com/hello_word.git, on branch master.

def say_hello():
   return "Hello World!"

To call the function using Arca, the following example would do so:

from arca import Arca, Task

task = Task("hello_world:say_hello")
arca = Arca()

result = arca.run("https://example.com/hello_word.git", "master", task)
print(result.output)

The code would print Hello World!. result would be a arca.Result instance. arca.Result has three attributes, output with the return value of the function call, stdout and stderr contain things printed to the standard outputs (see the section about Result for more info about the capture of the standard outputs). If the task fails, arca.exceptions.BuildError would be raised.

By default, the Current Environment Backend is used to run tasks, which uses the current Python, launching the code in a subprocess. You can learn about backends here.

Further reading

You can read the full documentation on Read The Docs.

Running tests

To run tests you’ll need the optional requirements, Docker and Vagrant. Once you have them and they can be used by the current user you just need to run:

python setup.py test

This will launch the tests and a PEP8 check. The tests will take some time since building the custom docker images is also tested and vagrant, in general, takes a long time to set up.

Contributing

Contributions are welcomed! Feel free to open a issue or submit a pull request on GitHub!

Changes

0.3.2 (2019-11-23)

Changes:
  • Moved the project under organisation Pyvec.

  • Changed the Docker registry for the base images to arcaoss/arca.

  • Fixed unicode paths to repositories (#60)

0.3.1 (2018-11-16)

Raising a Arca exception when building of a Docker image fails. (#56, #57)

0.3.0 (2018-08-25)

Changes:
  • Removed CurrentEnvironmentBackend’s capability to process requirements - all requirements are ignored. (BACKWARDS INCOMPATIBLE)

  • Added support for installing requirements using Pipenv. The directory containing Pipfile and Pipfile.lock is set by the backend option pipfile_location, by default the root of the repository is selected. The Pipenv files take precedence over regular requirement files.

  • The Result class now has two more attributes, stdout and stderr with the outputs of launched tasks to standard output and error. Priting is therefore now allowed in the endpoints.

  • Using UTF-8 locale in Docker images used in DockerBackend.

  • Supporting Python 3.7.

0.2.1 (2018-06-11)

Updated dogpile.cache to 0.6.5, enabling compatability with Python 3.7. Updated the Docker backend to be able to run on Python betas.

0.2.0 (2018-05-09)

This release has multiple backwards incompatible changes against the previous release.

Changes:
  • Using extras to install Docker and Vagrant dependencies

    • pip install arca[docker] or pip install arca[vagrant] has to be used

  • Automatically using cloned repositories as reference for newly cloned branches

  • Using Debian as the default base image in the Docker backend:

    • apk_dependencies changed to apt_dependencies, now installing using apt-get

  • Vagrant backend only creates one VM, instead of multiple – see its documentation

  • Added timeout to tasks, 5 seconds by default. Can be set using the argument timeout for Task.

  • Added timeout to installing requirements, 300 seconds by default. Can be set using the requirements_timeout configuration option for backends.

0.1.1 (2018-04-23)

Updated gitpython to 2.1.9

0.1.0 (2018-04-18)

Initial release

Changes:
  • Updated PyPI description and metadata

0.1.0a0 (2018-04-13)

Initial alfa release

Project details


Download files

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

Source Distribution

arca-0.3.2.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

arca-0.3.2-py3-none-any.whl (34.2 kB view details)

Uploaded Python 3

File details

Details for the file arca-0.3.2.tar.gz.

File metadata

  • Download URL: arca-0.3.2.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for arca-0.3.2.tar.gz
Algorithm Hash digest
SHA256 73cb2b344e9a327c151b22979e34300f84978dac5e8efa7730f13bf76257fbdd
MD5 2197673cd88c3d34e2329cf3817519b1
BLAKE2b-256 97ece7a57147a51ff0db761b4723927a47ec0ae9f606bcb7d4adf1bd7d37a595

See more details on using hashes here.

File details

Details for the file arca-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: arca-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.39.0 CPython/3.7.5

File hashes

Hashes for arca-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fdd40224ad1398f455a35aa38355c811928eedb0048a814d2a86424a44c57602
MD5 805f512301b0f8f33eaed94e8c6cd251
BLAKE2b-256 90bd695067756041d75e54cfd75056800d7919d42ba3e3b9723388cbb80f702d

See more details on using hashes here.

Supported by

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