Skip to main content

seamm_datastore

Project description

seamm_datastore

GitHub Actions Build Status codecov

This repository contains the SQLAlchemy models for the SEAMM datastore as well as some associated utilities such as dumping to JSON and checking permissions. These database models and permissions system were developed to be used inside a flask application context in the SEAMM Dashboard. However, you may use this package as a stand-alone (outside of flask) with limited permissions capabilities.

Quickstart

This package contains SQLAlchemy models for the SEAMM datastore. The following gives an example of how to connect to a database in memory. You can switch the database by providing a different database URI.

import seamm_datastore

# Create a database session
connection = seamm_datastore.SEAMMDatastore("sqlite:///:memory:", initialize=True, username="your_username", password="your_password")

The SEAMMDatastore class has associated functions which can be used to add to the database using the same permission system that the seamm dashboard uses. Use the .add_job method to add a job and get_jobs to get all of the jobs the user is authorized to view.

To retrieve all the users and dump the info to JSON:

from seamm_datastore.database.schema import JobSchema

# Create user schema
users = JobSchema(many=True)

# To retrieve all users in db
all_jobs = connection.get_jobs()

users_json = users.dump(all_jobs)

Permissions

The SEAMM datastore has a permissions system built in using flask-authorize for authorization. This provides a "permissions" entry on each resource table (Jobs, Flowcharts, and Projects) where permissions for "owner", "group" and "world". The SEAMM datastore also has capabilities to set "special permissions" for users or groups on specific projects.

Permissions are not automatically enforced when working directly with database models. In the SEAMM Dashboard, permissions are enforced with authentication (verifying the user is who they say they are) using [flask-jwt-extended] and authorization using flask-authorize.

To use the permissions checking mechanisms of flask authorize outside of a flask app, use the helper function here seamm_datastore.SEAMMDatastore.

Copyright

Copyright (c) 2021, Jessica A. Nash (The Molecular Sciences Software Institute)

Acknowledgements

Project based on the Computational Molecular Science Python Cookiecutter version 1.5.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seamm_datastore-2022.1.10.tar.gz (91.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seamm_datastore-2022.1.10-py2.py3-none-any.whl (85.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file seamm_datastore-2022.1.10.tar.gz.

File metadata

  • Download URL: seamm_datastore-2022.1.10.tar.gz
  • Upload date:
  • Size: 91.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for seamm_datastore-2022.1.10.tar.gz
Algorithm Hash digest
SHA256 ce553d7c66ec14102ce4f9ec14bdee3594f1f0878ad93a14bedfeb596a689071
MD5 ab20eebdfc0e34ead846796c2f149d12
BLAKE2b-256 8463acf431e81cf9ca798d7c094d000987c5d7c4b8df6aeb446d7f504afff31c

See more details on using hashes here.

File details

Details for the file seamm_datastore-2022.1.10-py2.py3-none-any.whl.

File metadata

  • Download URL: seamm_datastore-2022.1.10-py2.py3-none-any.whl
  • Upload date:
  • Size: 85.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for seamm_datastore-2022.1.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ead07397aad08f98151d9f03713adc0deafcc38072f5d3eee3fa957448d9a2f
MD5 3de4b1788c10b70106933c0f12493983
BLAKE2b-256 61006a4780ed99ac52d8d1743d2b6f9d93d48b4f46ea26c27607f91cb3618198

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page