# Path: lib/logger.py
# def get_logger(name):
#     '''
#     Obtain a logger outputing to stderr with specified name. Defaults to INFO
#     log level.
#     '''
#     logger = logging.getLogger(name)
#     if LUIGI_LOG_ARG in sys.argv:
#         index = sys.argv.index(LUIGI_LOG_ARG) + 1
#         if len(sys.argv) > index:
#             logger.setLevel(sys.argv[index])
# 
#     return logger


import os
import re
import inspect
import functools
import asyncpg
from luigi import Target
from sqlalchemy import (Column, Integer, Text, MetaData, Numeric, cast,
                        create_engine, event, ForeignKey, ForeignKeyConstraint,
                        exc, func, UniqueConstraint, Index)
from sqlalchemy.dialects.postgresql import JSON, DATERANGE
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import relationship, sessionmaker, backref
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.types import UserDefinedType
from lib.logger import get_logger
from logging import DEBUG
            AND ct.tag_id = t.id
            AND c.type NOT ILIKE 'geometry%'
            AND c.weight > 0
            AND (c2c.reltype != 'geom_ref' OR c2c.reltype IS NULL)
            AND c.id = ctab.column_id
        ),
        meta AS (
            SELECT numer_id, numer_version FROM observatory.obs_meta_numer
        )
        SELECT id, version, numer_id, numer_version
        FROM columns FULL JOIN meta
        ON id = numer_id AND version = numer_version
        WHERE numer_id IS NULL OR id IS NULL;
        '''
        resp = session.execute(changed_columns)
        if resp.fetchone():
            return False

        # identify tables that have appeared, changed, or disappeared
        changed_tables = '''
        with numer_tables as (
            select distinct tab.id, tab.version
            from observatory.obs_table tab,
                observatory.obs_column_table ctab,
                observatory.obs_column c
                    left join observatory.obs_column_to_column c2c on c.id = c2c.source_id,
                observatory.obs_column_tag ct,
                observatory.obs_tag t
                where c.id = ct.column_id
                    and ct.tag_id = t.id

# Path: lib/logger.py
# def get_logger(name):
#     '''
#     Obtain a logger outputing to stderr with specified name. Defaults to INFO
#     log level.
#     '''
#     logger = logging.getLogger(name)
#     if LUIGI_LOG_ARG in sys.argv:
#         index = sys.argv.index(LUIGI_LOG_ARG) + 1
#         if len(sys.argv) > index:
#             logger.setLevel(sys.argv[index])
# 
#     return logger


# Path: tasks/meta.py
import os
import re
import inspect
import functools
import asyncpg
from luigi import Target
from sqlalchemy import (Column, Integer, Text, MetaData, Numeric, cast,
                        create_engine, event, ForeignKey, ForeignKeyConstraint,
                        exc, func, UniqueConstraint, Index)
from sqlalchemy.dialects.postgresql import JSON, DATERANGE
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import relationship, sessionmaker, backref
from sqlalchemy.orm.collections import attribute_mapped_collection
from sqlalchemy.types import UserDefinedType
from lib.logger import get_logger
from logging import DEBUG

            AND ct.tag_id = t.id
            AND c.type NOT ILIKE 'geometry%'
            AND c.weight > 0
            AND (c2c.reltype != 'geom_ref' OR c2c.reltype IS NULL)
            AND c.id = ctab.column_id
        ),
        meta AS (
            SELECT numer_id, numer_version FROM observatory.obs_meta_numer
        )
        SELECT id, version, numer_id, numer_version
        FROM columns FULL JOIN meta
        ON id = numer_id AND version = numer_version
        WHERE numer_id IS NULL OR id IS NULL;
        '''
        resp = session.execute(changed_columns)
        if resp.fetchone():
            return False

        # identify tables that have appeared, changed, or disappeared
        changed_tables = '''
        with numer_tables as (
            select distinct tab.id, tab.version
            from observatory.obs_table tab,
                observatory.obs_column_table ctab,
                observatory.obs_column c
                    left join observatory.obs_column_to_column c2c on c.id = c2c.source_id,
                observatory.obs_column_tag ct,
                observatory.obs_tag t
                where c.id = ct.column_id
                    and ct.tag_id = t.id

                    and ctab.column_id = c.id