A GraphQL API for Nextline
Project description
nextline-graphql
A GraphQL API for Nextline
Nextline allows line-by-line execution of concurrent Python scripts by multiple users simultaneously from web browsers. Nextline is being developed as a DAQ sequencer of the Observatory Control System (OCS).
Packages
- nextline: (Python) the core functionality. imported in nextline-graphql.
- nextline-graphql: (Python) this package. the GraphQL API
- nextline-web: (JavaScript) the client website
How to run the Nextline GraphQL API
The section shows how to run the Nextline GraphQL API server. How to run the client website will be described elsewhere.
As a Docker container
Docker images of the Nextline GraphQL API server are created as ghcr.io/simonsobs/nextline-graphql. These images are created by the Dockerfile.
Use, for example, the following command to run as a Docker container.
docker run -p 8080:8000 ghcr.io/simonsobs/nextline-graphql
If you access to the API server with a web browser, you will see the GraphQL IDE: http://localhost:8080/.
With a persistent DB
Nextline-graphql stores the execution history and other information in the DB. It uses SQLAlchemy, with, by default, a SQLite in-memory database.
An environment variable in the container
The container has one environment variable, which is to change the DB URL of SQLAlchemy.
Environment variable | Default value | Description |
---|---|---|
NEXTLINE_DB__URL |
sqlite:///:memory:?check_same_thread=false |
The DB URL of SQLAlchemy |
For example, the following command uses a file on the host machine
db/db.sqlite3
as the persistent DB. The directory db/
and the file
db.sqlite3
will be created if they don't exist.
docker run -p 8080:8000 --env NEXTLINE_DB__URL='sqlite:////db/db.sqlite3' -v "$(pwd)/db:/db" ghcr.io/simonsobs/nextline-graphql
from PyPI
It is also possible to install with pip and run.
pip install nextline-graphql
uvicorn --lifespan on --factory --port 8080 nextlinegraphql:create_app
The environment variable NEXTLINE_DB__URL
mentioned above can be used to
specify the SQLAlchemy DB URL.
Check with a web browser at http://localhost:8080/.
Check out code for development
This section shows an example way to check out code from GitHub for development.
python -m venv venv
source venv/bin/activate
git clone git@github.com:simonsobs/nextline.git
git clone git@github.com:simonsobs/nextline-graphql.git
pip install -e ./nextline/"[tests,dev]"
pip install -e ./nextline-graphql/"[tests,dev]"
To run
uvicorn --port 8080 --lifespan on --factory --reload --reload-dir nextline-graphql --reload-dir nextline nextlinegraphql:create_app
License
- Nextline is licensed under the MIT license.
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nextline_graphql-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cdc7282833de25a2bfa9d7115efa2add5ab81d74c45ee2ca84ea2a496f30531 |
|
MD5 | 76068088b49c2a116b7f80a98b3a232e |
|
BLAKE2b-256 | 9e5a7c948935ed7f86974a15b4a8016a09a27b76941a1c58765b622386fdd45e |