/lat2db

Primary LanguagePython

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 lattice files.

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

Usage

Running the REST API

To start the FastAPI server, run:

python scripts/main.py

File Conversion and Insertion

To convert a lattice file to JSON and insert it into MongoDB, you can use the provided script:

python 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