/qctrl-api

Solution for Q-CTRL Back-end Engineering Challenge.

Primary LanguagePythonApache License 2.0Apache-2.0

Simple BLACK OPAL API

Implementation of Q-CTRL back-end engineering challenge in Django.

Development Set-up

Make sure you have Poetry installed. And create a fresh database in postgreSQL.

$ ln -sv .envs/.env.dev qctrl/.env
$ poetry install

Modify project settings as you require in qctrl/.env, or override them using environment variables when calling manage.py.

You can then run a development server with

$ poetry run ./manage.py makemigrations api
$ poetry run ./manage.py migrate
$ poetry run ./manage.py runserver

Usage

The API root is available at api/. HTTP request bodies should be in JSON, unless otherwise specified.

Controls

The API allows for

  1. Create a new control
  2. List all controls (five per page)
  3. Get a specific control
  4. Update a specific control
  5. Delete a specific control
  6. Bulk upload controls in CSV format
  7. Download controls in CSV format

Create a new control

POST /controls/
Input
Name Type Description
name string Required Name of the control
type string Required One of: Primitive, CORPSE, Gaussian, CinBB, CinSK
maximum_rabi_rate float Required The maximum achievable angular frequency of the Rabi cycle for a driven quantum transition. This is a number between 0 and 100.
polar_angle float Required An angle measured from the z-axis on the Bloch sphere. This is a number between 0 and 1 (units of pi).

List all controls

GET /controls/

List one control

GET /controls/:id

Update one specific control

PUT /controls/:id
Input
Name Type Description
name string Required Name of the control
type string Required One of: Primitive, CORPSE, Gaussian, CinBB, CinSK
maximum_rabi_rate float Required The maximum achievable angular frequency of the Rabi cycle for a driven quantum transition. This is a number between 0 and 100.
polar_angle float Required An angle measured from the z-axis on the Bloch sphere. This is a number between 0 and 1 (units of pi).

Delete one control

DELETE /controls/:id

Bulk upload controls in CSV

POST /controls/upload
Input
Name Type Description
data binary CSV file in binary format

For example,

curl -X POST -i
--data-binary @dir/to/foo.csv
-H 'Content-Type: text/csv'
-H 'Accept: text/csv' http://domain.name/api/controls/upload/

Download controls in CSV

GET /controls/download

Testing

You can easily invoke tests with

$ poetry run ./manage.py test

Future Improvements

  1. CI/CD (with GitHub actions)
  2. Authentication to limit scope of API
  3. API versioning
  4. Rate limiting
  5. User-Agent detection