Skip to main content

Gen3 Data Model Utils

Project description

datamodelutils

Docker Repository on Quay

Wrapper utils to allow gen3datamodel.models to be loaded after initialization.

For example

from datamodelutils import models
from dictionaryutils import DataDictionary, dictionary

d = DataDictionary(url="https://s3.amazonaws.com/dictionary-artifacts/bhcdictionary/feat/s3/schema.json")

dictionary.init(d)
# Always import gen3datamodel after dictionary has been initialized.
# Creates a singleton for life of python session.
# Required for backward compatibility. 
from gen3datamodel import models as md
models.init(md)

print(models)

will produce output of

<module 'gen3datamodel.models' from '/Users/phillis/Documents/work/datamodelutils/venv/lib/python3.9/site-packages/gen3datamodel/gen3datamodel/models/__init__.py'>

CLI Utilities

The datamodelutils has a docker image that exposes admin commands to manage or interact with datamodel

datamodel_postgres_admin

Script to do database creation and migration

# setup all tables, this should be run when you initialize the database
> export PG_HOST=localhost
> export PG_USER=test
> export PG_PASS=test
> export PG_NAME=test_graph
> export DICTIONARY_URL="https://s3.amazonaws.com/dictionary-artifacts/<dictionary_repl>/<branch>/schema.json"
> datamodel_postgres_admin create-all

# setup/create new graph tables, this should be run for dictionary migrations that needs to setup new tables
datamodel_postgres_admin graph-create

datamodel_repl

repl to interact with datamodel

> export PG_HOST=localhost
> export PG_USER=test
> export PG_PASS=test
> export PG_NAME=test_graph
> export DICTIONARY_URL="https://s3.amazonaws.com/dictionary-artifacts/<dictionary_repl>/<branch>/schema.json"
> datamodel_repl
Python 2.7.10 (default, Feb  7 2017, 00:08:15)
Type "copyright", "credits" or "license" for more information.

IPython 5.4.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: g.nodes(md.Project).first()
Out[1]: <Project(a77f549b-c74b-563e-80bb-570b5a4dde88)>

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

datamodelutils-1.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

datamodelutils-1.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file datamodelutils-1.1.0.tar.gz.

File metadata

  • Download URL: datamodelutils-1.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1014-azure

File hashes

Hashes for datamodelutils-1.1.0.tar.gz
Algorithm Hash digest
SHA256 81f1c0b9ce69c94420e5af12f07f36a1b15bc3ff8e02abde72e804b3e9988f2e
MD5 8c70a008881430064554933724702e8c
BLAKE2b-256 96be291841c4652d5bbf50990283d9d4c1c8449013941486cb43aba5f5dbe7c8

See more details on using hashes here.

File details

Details for the file datamodelutils-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: datamodelutils-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1014-azure

File hashes

Hashes for datamodelutils-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d17958773f6dc299e2ddaa3b56b3c86a0c4c52e1694da60ce1e97dc83b299fc
MD5 8956afee05e6cd18214b657eb3201f65
BLAKE2b-256 1ba9c3309c5eccb9c8e351eb69046d7c618d0586c482dc996cb4f800fab9dd39

See more details on using hashes here.

Supported by

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