Lat2DB is a project designed to convert lattice files into JSON format and store them in MongoDB. It utilizes a Lark grammar created by Andreas Felix to parse thor_scsi lattice files.
For other lattice formats (e.g. AT) we have separate parsers.
- Lattice File Conversion: Lat2DB can read a lattice file and export it to JSON format.
- MongoDB Integration: The exported JSON data is inserted into MongoDB for efficient storage and retrieval.
- REST API: Lat2DB is a REST API-based project, built using FastAPI, providing endpoints for interacting with the data.
- Python 3.x
- MongoDB installed and running
- Clone the repository:
git clone <https://github.com/hz-b/lat2db>
- Install dependencies:
pip install -r requirements.txt
- Build UI-> make sure you have Node.js installed and then go to UI directory and run:
npm run build
To start the FastAPI server, run:
python3 scripts/main.py
The provided API will give you an interface to navigate through different elements of the lattice and even edit them
In order to download the lattice in json format from the api (browser) you can go to the link:
api link followed by /machine/machine/_id of the machine e.g. http://datascc.trs.bessy.de:8000/machine/machine/662f83c50019a6f1a5ce7ea2
The json which is loaded can be saved
Go to examples folder and try: create_ring.py or the jupyter file. The examples are self-explanatory
To convert a lattice file to JSON and insert it into MongoDB, you can use the provided script:
python3 scripts/export_lattice_to_db.py
This script will convert the specified lattice file to JSON format and store it in the MongoDB database.
- GET
/machine/machine
: Retrieve a list of existing machines (lattices) from the MongoDB repository. - GET
/machine/machine/<uid>
: Retrieve a specific machine by its unique identifier (UID) from the MongoDB repository. - POST
/machine/machine
: Create a new machine by posting JSON data.
Thanks to Andreas Felix for the Lark grammar used in this project. Link to Andreas' GitHub Project