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.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad3cae73468fc95a3208b7743818be7ec2551f80ee6678d22b8e2fc91ef542bd |
|
MD5 | f5e6d3d3d5bdc2b4805703d80692e67d |
|
BLAKE2b-256 | c3afeeb7df5f24fb4409172c122d798ab29bd34474d4fd1271bbd472f5bb5269 |