Skip to content

hz-b/lat2db

Repository files navigation

Lat2DB Project

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.

Features

  • 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.

Getting Started

Prerequisites

  • Python 3.x
  • MongoDB installed and running

Installation

  1. Clone the repository: git clone <https://github.com/hz-b/lat2db>
  2. Install dependencies: pip install -r requirements.txt
  3. Build UI-> make sure you have Node.js installed and then go to UI directory and run: npm run build

Usage

Running the REST API

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

Using the application for calculations

Go to examples folder and try: create_ring.py or the jupyter file. The examples are self-explanatory

File Conversion and Insertion

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.

API Endpoints

  • 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.

Acknowledgments

Thanks to Andreas Felix for the Lark grammar used in this project. Link to Andreas' GitHub Project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •