Example #1
0
"""Example of using the 'ReifySub' transformation.
"""
import os
from deriva.core import DerivaServer
from deriva.chisel import Model

__dry_run__ = os.getenv('CHISEL_EXAMPLE_DRY_RUN', True)
__host__ = os.getenv('CHISEL_EXAMPLES_HOSTNAME', 'localhost')
__catalog_id__ = os.getenv('CHISEL_EXAMPLES_CATALOG', '1')

server = DerivaServer('https', __host__)
catalog = server.connect_ermrest(__catalog_id__)
model = Model.from_catalog(catalog)

# Create a new (child) relation computed from a subset of column(s) of the source relation
with model.begin(dry_run=__dry_run__) as session:
    dataset = model.schemas['isa'].tables['dataset']
    session.create_table_as('isa', 'dataset_study_designs',
                            dataset.reify_sub(dataset.columns['study_design']))
Example #2
0
"""Minimal example of a possible rendering of the ETAS starter model.
Developer: Robert Schuler
Modifications: Philip Maechling
"""
"""Minimal example of a possible rendering of the ETAS starter model.
"""
from deriva.core import DerivaServer, get_credential
from deriva.chisel import Model, Schema, Table, Column, Key, ForeignKey, builtin_types, tag

# Connect to server and catalog ------------------------------------------------------------------#

hostname = 'forecast.derivacloud.org'   # this is a dev server for throw-away work (change to 'forecast.derivacloud.org)
catalog_id = '5'            # this was a throw-away catalog used to test this script (change to TBD)

model = Model.from_catalog(
    DerivaServer('https', hostname, credentials=get_credential(hostname)).connect_ermrest(catalog_id)
)


# Cleanup ----------------------------------------------------------------------------------------#

if 'ETAS' in model.schemas:
    # Purge anything so we can "do over" repeatedly at this point
    model.schemas['ETAS'].drop(cascade=True)


# ETAS schema ------------------------------------------------------------------------------------#

# Create the "schema" to organize tables in the catalog "model"
model.create_schema(Schema.define('ETAS'))
Example #3
0
 def connect(self):
     # connect to catalog
     assert isinstance(self._ermrest_catalog, ErmrestCatalog)
     return Model.from_catalog(self._ermrest_catalog)