A library for running Python functions (callables) from git repositories in various states of isolation with integrated caching.
Clone or download
Pull request Compare This branch is 1 commit ahead, 3 commits behind mikicz:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
arca Requiring both Pipfile and Pipfile.lock, unified install Dockerfile Aug 25, 2018
docs Bumped version and updated changelog Aug 25, 2018
tests Requiring both Pipfile and Pipfile.lock, unified install Dockerfile Aug 25, 2018
.coveragerc
.flake8 Removed flake8 ignores, removed some extra imports Apr 11, 2018
.gitignore Dynamically listing versions to build base docker images Feb 25, 2018
.pyup.yml create pyup.io config file Oct 12, 2018
.readthedocs.yml
.travis.yml
LICENSE
MANIFEST.in Bumped version Apr 13, 2018
README.rst
codecov.yml Disabled checks, comments on PRs Apr 11, 2018
mypy.ini
pytest.ini Removed flake8 ignores, removed some extra imports Apr 11, 2018
requirements.txt Python 3.7 and betas compatability Jun 11, 2018
setup.cfg BaseBackend, VenvBackend, Task, Result, setup of testing Sep 24, 2017
setup.py
utils.py Fixed failing build, some mypy issues Feb 25, 2018

README.rst

Arca

https://img.shields.io/github/license/mikicz/arca.svg?style=flat

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/mikicz/arca.git#egg=arca
python -m pip install git+https://github.com/mikicz/arca.git#egg=arca[docker]
python -m pip install git+https://github.com/mikicz/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!

Links

License

This project is licensed under the MIT License - see the LICENSE file for details.