Skip to content

Commit

Permalink
Add script to generate sdss5db graphs and update them
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed May 4, 2020
1 parent 9116ea8 commit b36cc02
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
Binary file modified schema/sdss5db/catalogdb/sdss5db.catalogdb.pdf
Binary file not shown.
Binary file modified schema/sdss5db/catalogdb/sdss5db.catalogdb_lite.pdf
Binary file not shown.
Binary file modified schema/sdss5db/targetdb/sdss5db.targetdb.pdf
Binary file not shown.
57 changes: 57 additions & 0 deletions schema/sdss5db/update_graphs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @Author: José Sánchez-Gallego (gallegoj@uw.edu)
# @Date: 2020-05-04
# @Filename: update_graphs.py
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause)

# This script generates the schema graphs for catalogdb (full and lite)
# and targetdb. It requires graphviz to be installed with support for PDF.
# Accepts a single, optional argument, the name of the profile to use to
# connect to the database.

import os
import sys

from sdssdb.peewee.sdss5db import database
from sdssdb.utils.schemadisplay import create_schema_graph


def create_graphs():

cwd = os.path.dirname(os.path.realpath(__file__))

cdb_graph = create_schema_graph(base=catalogdb.CatalogdbModel,
show_columns=True,
skip_tables=['galactic_genesis_big',
'galactic_genesis'],
graph_options={'rankdir': 'TB'})
cdb_graph.write_pdf(f'{cwd}/catalogdb/sdss5db.catalogdb.pdf')

cdb_lite_graph = create_schema_graph(base=catalogdb.CatalogdbModel,
show_columns=False,
skip_tables=['galactic_genesis_big',
'galactic_genesis'],
graph_options={'rankdir': 'TB',
'ratio': 'compress',
'size': '30!,20!'})
cdb_lite_graph.write_pdf(f'{cwd}/catalogdb/sdss5db.catalogdb_lite.pdf')

tdb_graph = create_schema_graph(base=targetdb.TargetdbBase,
show_columns=True,
graph_options={'rankdir': 'TB'})
tdb_graph.write_pdf(f'{cwd}/targetdb/sdss5db.targetdb.pdf')


if __name__ == '__main__':

if len(sys.argv) == 2:
database.set_profile(sys.argv[1])

assert database.connected, 'database is not connected'

# Import modules here to make sure all the relational tables are loaded.
from sdssdb.peewee.sdss5db import catalogdb, targetdb

create_graphs()

0 comments on commit b36cc02

Please sign in to comment.