Skip to content

About

AiiDA Web API for data queries and workflow management.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Repository files navigation

Build Status Coverage Status Docs status PyPI version

aiida-restapi

AiiDA REST API for data queries and workflow management.

Uses pydantic for models/validation and fastapi for the ASGI application. Serve e.g. using uvicorn.

Features

  • /users (GET/POST) and /users/<id> (GET) endpoints
  • User pydantic model for validation
  • Automatic documentation at http://127.0.0.1:8000/docs
  • Full specification at http://127.0.0.1:8000/openapi.json

Installation

pip install aiida-restapi

Usage

To start the REST API, run:

aiida_restapi start [OPTIONS]

Options

  • --root-path Root path for the API (default: /)
  • --host Host to listen on (default: 127.0.0.1)
  • --port Port to listen on (default: 8000)
  • --read-only Start the API in read-only mode (default: False)
  • --watch Watch for changes and reload (default: False)

CORS policy

By default, the API allows requests from localhost. You can configure the CORS policy by modifying CORS_ALLOW_ORIGIN_REGEX and/or CORS_ORIGIN_URLS in aiida_restapi/config.py. For more details, see FastAPI CORS documentation.

Examples

See the examples directory.

Development

git clone https://github.com/aiidateam/aiida-restapi .
cd aiida-restapi

To reload the API on changes, run:

aiida_restapi start --watch

Setting up pre-commit

We use pre-commit to take care for the formatting, type checking and linting.

pip install -e .[pre-commit]  # install extra dependencies
pre-commit run # running pre-commit on changes
pre-commit run --all-files # running pre-commit on every file
pre-commit run pylint --all-files # run only the linter on every file

One can also set up pre-commit to be run on every commit

pre-commit install
# pre-commit uninstall # to disable it again

Running tests

With tox the tests can be run

pip install tox
tox -e py311 # run all tests for Python 3.11
tox -av # see all supported environments

tox will create a custom environment to run the tests in. If you want to run the tests inside your current environment

pip install -e .[testing]  # install extra dependencies
pytest -v

See the developer guide for more information.

License

MIT

Contact

leopold.talirz@gmail.com chrisj_sewell@hotmail.com

About

AiiDA Web API for data queries and workflow management.

Topics

Resources

Stars

11 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages