Webservice#

QC-Tests

Testbed-WebAPI: https://shepherd.cfaed.tu-dresden.de:8000

Main Documentation: https://orgua.github.io/shepherd

Source Code: https://github.com/orgua/shepherd-webservice

Main Project: https://github.com/orgua/shepherd


The Webservice links the user to the testbed. It’s written in Python and uses FastAPI to expose an interface to the internet. You can write your own tools or just use the testbed-client integrated in the Core-Datalib.

Internally the webservices utilizes the herd-lib to access the shepherd observers. Handling of data is done with Pydantic-Models that store the actual data in a database.

FastApi Webservice (current prototype)#

  • DNS approved for the server: shepherd.cfaed.tu-dresden.de

  • Port 8000 requested for firewall passing

    • SSL-Certificate per LetsEncrypt -> alternative is <www.sectigo.com>

    • bring demo-application online

    • add https to FastAPI

  • TODO: allow service to start with reduced rights -> get nfs in order (access needs elevation)

API-Website ReDoc OpenApiDoc


Cornerstones#

Data-Containers#

Pydantic

  • data validation for python dataclasses, its fast, elegantly designed and comes with batteries included

  • already trusted base for shepherd-datalib

WebFrontend#

FastUI

  • restful web-framework based on pydantic2 & fastapi

  • still alpha, but usable, rapid updates

  • plan B: tbd

Streamlit

  • stable and lots to offer, but maybe limited for more

  • and there is a freemium service

WebApi#

FastApi

  • high performance web framework for APIs based on pydantic

  • offers features like OAuth, SSL-Encryption (by uvicorn), user-sessions

  • choice for now

Flask

  • low level but stable framework

Database#

Beanie

  • async & pydantic-based ODM or MongoDB

  • stable, but also actively developed

  • choice for now

SQLModel

  • async & pydantic-based ODM for SQLAlchemy

  • still alpha, very slow in development

  • has trouble with complex pydantic-models

ORMDantic

  • async & pydantic-based ODM for SQLAlchemy

  • currently limited to pydantic <v2 -> dealbreaker

Misc#

  • Secrets-Management

    • https://pypi.org/project/python-secrets/

  • Server-Monitoring, remote alerting

    • sentry-sdk,

install#

  • set up a local MongoDB instance

  • install package

  • config .env, by either bringing in a backup or starting fresh

    • backup: repopulate database by using ´shepherd_wsrv init file´

    • fresh start: generate fresh salt and initialize database with shepherd_wsrv init

run server#

shepherd_wsrv run

or to switch to the offline-mode activate the redirect to the docs

shepherd_wsrv redirect

save state#

shepherd_wsrv backup file_name