示例#1
0
from utils.db import dal, DataAccessLayer
from utils import util
import networkx as nx

from model.query_builder import QueryBuilder

import settings


if __name__ == "__main__":
    db = settings.DATABASES[settings.DATABASE]
    dal.db_init(DataAccessLayer.str_connection(db),
                schema_output=settings.SCHEMA_OUTPUT)

    op_description = util.load_json(settings.OPS_DESCRIPTION_FILE)
    G = nx.read_adjlist(settings.OPS_SEQUENCE_FILE, create_using=nx.DiGraph())

    builder = QueryBuilder(op_description, G)
    operations = builder.get_operations()

    for k, v in operations.items():
        print(k)
        print(str(v))
        # print(v.access_data_table())
        print(v.columns_name())
        print(v.number_of_rows())
示例#2
0
class test_operations(unittest.TestCase):
    str_con = "oracle://*****:*****@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=leovip148.ncsa.uiuc.edu)(PORT=1521)))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=dessci)))"
    dal.db_init(str_con, schema_output='BRPORTAL')

    def setUp(self):
        ops_path = "test/ops_y1a1_oracle.json"
        self.ops_desc = util.load_json(ops_path)
        self.tree_desc = {
            "galaxy_properties": ["photoz"],
            "photoz": ["sg_separation"],
            "sg_separation": ["object_selection"],
            "object_selection": ["bitmask"],
            "bitmask": ["cuts"],
            "cuts": ["reduction", "zero_point"],
            "reduction": ["footprint"],
            "footprint": ["exposure_time", "mangle_map", "bad_regions"],
            "exposure_time":
            ["exposure_time_i", "exposure_time_r", "exposure_time_z"],
            "mangle_map": ["mangle_maps_i", "mangle_maps_r"]
        }
        self.operations = None

    def test_op_great_equal(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('exposure_time_i')
        self.operations = QueryBuilder(tree)

    def test_op_combined_maps(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('exposure_time')
        self.operations = QueryBuilder(tree)

    def test_op_zero_point(self):
        tree_desc = {'zero_point': []}
        tree = t.Tree(tree_desc, self.ops_desc).tree_builder('zero_point')
        self.operations = QueryBuilder(tree)

    def test_op_footprint_inner_left(self):
        tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('footprint')
        self.operations = QueryBuilder(tree)

    def test_op_object_selection(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('object_selection')
        self.operations = QueryBuilder(tree)

    def test_op_sg_separation(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('sg_separation')
        self.operations = QueryBuilder(tree)

    def test_op_photoz(self):
        tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('photoz')
        self.operations = QueryBuilder(tree)

    def test_op_galaxy_properties(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('galaxy_properties')
        self.operations = QueryBuilder(tree)

    def tearDown(self):
        ops = self.operations.get_operations()
        self.operations.drop_all_tables()
 def query_builder_factory(self, operation):
     return QueryBuilder(self.ops_desc, self.workflow, root_node=operation)
示例#4
0
 def test_op_photoz(self):
     tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('photoz')
     self.operations = QueryBuilder(tree)
示例#5
0
 def test_op_galaxy_properties(self):
     tree = t.Tree(self.tree_desc,
                   self.ops_desc).tree_builder('galaxy_properties')
     self.operations = QueryBuilder(tree)
示例#6
0
 def test_op_object_selection(self):
     tree = t.Tree(self.tree_desc,
                   self.ops_desc).tree_builder('object_selection')
     self.operations = QueryBuilder(tree)
示例#7
0
 def test_op_sg_separation(self):
     tree = t.Tree(self.tree_desc,
                   self.ops_desc).tree_builder('sg_separation')
     self.operations = QueryBuilder(tree)
示例#8
0
 def test_op_footprint_inner_left(self):
     tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('footprint')
     self.operations = QueryBuilder(tree)
示例#9
0
 def test_op_zero_point(self):
     tree_desc = {'zero_point': []}
     tree = t.Tree(tree_desc, self.ops_desc).tree_builder('zero_point')
     self.operations = QueryBuilder(tree)
示例#10
0
 def test_op_combined_maps(self):
     tree = t.Tree(self.tree_desc,
                   self.ops_desc).tree_builder('exposure_time')
     self.operations = QueryBuilder(tree)
示例#11
0
 def test_op_great_equal(self):
     tree = t.Tree(self.tree_desc,
                   self.ops_desc).tree_builder('exposure_time_i')
     self.operations = QueryBuilder(tree)
示例#12
0
class test_operations(unittest.TestCase):
    db = {
        'dialect': 'postgresql',
        'driver': 'psycopg2',
        'username': '******',
        'password': '******',
        'host': 'localhost',
        'port': '5432',
        'database': 'query_builder'
    }
    dal.db_init(DataAccessLayer.str_connection(db),
                schema_output='tst_oracle_output')

    def setUp(self):
        ops_path = "test/ops_subset_y1a1_local_db.json"
        self.ops_desc = util.load_json(ops_path)
        self.tree_desc = {
            "galaxy_properties": ["photoz"],
            "photoz": ["sg_separation"],
            "sg_separation": ["object_selection"],
            "object_selection": ["bitmask"],
            "bitmask": ["cuts"],
            "cuts": ["reduction"],
            "reduction": ["footprint"],
            "footprint": ["exposure_time", "mangle_map", "bad_regions"],
            "exposure_time":
            ["exposure_time_i", "exposure_time_r", "exposure_time_z"],
            "mangle_map": ["mangle_maps_i", "mangle_maps_r"]
        }
        self.operations = None

    def test_op_great_equal(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('exposure_time_i')
        self.operations = QueryBuilder(tree)

    def test_op_footprint_inner_left(self):
        tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('footprint')
        self.operations = QueryBuilder(tree)

    def test_op_combined_maps(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('exposure_time')
        self.operations = QueryBuilder(tree)

    def test_op_object_selection(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('object_selection')
        self.operations = QueryBuilder(tree)

    def test_op_sg_separation(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('sg_separation')
        self.operations = QueryBuilder(tree)

    def test_op_photoz(self):
        tree = t.Tree(self.tree_desc, self.ops_desc).tree_builder('photoz')
        self.operations = QueryBuilder(tree)

    def test_op_galaxy_properties(self):
        tree = t.Tree(self.tree_desc,
                      self.ops_desc).tree_builder('galaxy_properties')
        self.operations = QueryBuilder(tree)

    def tearDown(self):
        self.operations.drop_all_tables()