How to use hologram - 10 common examples

To help you get started, we’ve selected a few hologram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fishtown-analytics / dbt / test / unit / View on Github external
def test_invalid(self):
        with self.assertRaises(ValidationError):
                {'git': '', 'version': '0.0.1'}
github fishtown-analytics / dbt-spark / test / unit / View on Github external
def assert_fails_validation(self, dct, cls=None):
        if cls is None:
            cls = self.ContractType

        with self.assertRaises(ValidationError):
github fishtown-analytics / dbt / core / dbt / task / View on Github external

    format_stats will convert the dict into a StatsDict with keys of 'encoded'
    and 'size'.
    stats_collector: StatsDict = {}

    base_keys = {k.split(':')[0] for k in stats}
    for key in base_keys:
        dct: PrimitiveDict = {'id': key}
        for subkey in ('label', 'value', 'description', 'include'):
            dct[subkey] = stats['{}:{}'.format(key, subkey)]

            stats_item = StatsItem.from_dict(dct)
        except ValidationError:
        if stats_item.include:
            stats_collector[key] = stats_item

    # we always have a 'has_stats' field, it's never included
    has_stats = StatsItem(
        label='Has Stats?',
        value=len(stats_collector) > 0,
        description='Indicates whether there are statistics for this table',
    stats_collector['has_stats'] = has_stats
    return stats_collector
github fishtown-analytics / dbt / core / dbt / contracts / View on Github external
class StatsItem(JsonSchemaMixin):
    id: str
    label: str
    value: Primitive
    description: str
    include: bool

StatsDict = Dict[str, StatsItem]

class ColumnMetadata(JsonSchemaMixin):
    type: str
    comment: Optional[str]
    index: int
    name: str

ColumnMap = Dict[str, ColumnMetadata]

class TableMetadata(JsonSchemaMixin):
    type: str
    database: str
    schema: str
    name: str
    comment: Optional[str]
github fishtown-analytics / dbt / core / dbt / contracts / View on Github external
compiled_sql: str
    node: CompileResultNode
    timing: List[TimingInfo]

    def error(self):
        return None

class RemoteExecutionResult(ExecutionResult, RemoteResult):

class ResultTable(JsonSchemaMixin):
    column_names: List[str]
    rows: List[Any]

class RemoteRunOperationResult(RemoteResult):
    success: bool

class RemoteRunResult(RemoteCompileResult):
    table: ResultTable

RPCResult = Union[
github fishtown-analytics / dbt / core / dbt / contracts / graph / View on Github external
from dbt.contracts.util import Replaceable, list_str
from dbt.logger import GLOBAL_LOGGER as logger  # noqa
from dbt.node_types import NodeType

class SnapshotStrategy(StrEnum):
    Timestamp = 'timestamp'
    Check = 'check'

class All(StrEnum):
    All = 'all'

class Hook(JsonSchemaMixin, Replaceable):
    sql: str
    transaction: bool = True
    index: Optional[int] = None

def insensitive_patterns(*patterns: str):
    lowercased = []
    for pattern in patterns:
            ''.join('[{}{}]'.format(s.upper(), s.lower()) for s in pattern)
    return '^({})$'.format('|'.join(lowercased))

Severity = NewType('Severity', str)
register_pattern(Severity, insensitive_patterns('warn', 'error'))
github fishtown-analytics / dbt / core / dbt / contracts / View on Github external
class SourceFreshnessOutput(JsonSchemaMixin):
    max_loaded_at: datetime
    snapshotted_at: datetime
    max_loaded_at_time_ago_in_s: Real
    state: FreshnessStatus
    criteria: FreshnessCriteria

SourceFreshnessRunResult = Union[SourceFreshnessOutput,

class FreshnessRunOutput(JsonSchemaMixin, Writable):
    meta: FreshnessMetadata
    sources: Dict[str, SourceFreshnessRunResult]

Primitive = Union[bool, str, float, None]

CatalogKey = NamedTuple(
    [('database', str), ('schema', str), ('name', str)]

class StatsItem(JsonSchemaMixin):
    id: str
    label: str
github fishtown-analytics / dbt / core / dbt / contracts / View on Github external
from dbt.exceptions import InternalException
from dbt.logger import LogMessage
from dbt.utils import restrict_to

TaskTags = Optional[Dict[str, Any]]
TaskID = uuid.UUID

# Inputs

class RPCParameters(JsonSchemaMixin):
    timeout: Optional[Real]
    task_tags: TaskTags

class RPCExecParameters(RPCParameters):
    name: str
    sql: str
    macros: Optional[str]

class RPCCompileParameters(RPCParameters):
    threads: Optional[int] = None
    models: Union[None, str, List[str]] = None
    exclude: Union[None, str, List[str]] = None
github fishtown-analytics / dbt / core / dbt / contracts / graph / View on Github external
'Seeds should always have a seed_file_path'

    def empty(self):
        """ Seeds are never empty"""
        return False

class TestConfig(NodeConfig):
    severity: Severity = Severity('error')

class TestMetadata(JsonSchemaMixin):
    namespace: Optional[str]
    name: str
    kwargs: Dict[str, Any]

class ParsedTestNode(ParsedNode):
    resource_type: NodeType = field(metadata={'restrict': [NodeType.Test]})
    column_name: Optional[str] = None
    config: TestConfig = field(default_factory=TestConfig)
    test_metadata: Optional[TestMetadata] = None

class _SnapshotConfig(NodeConfig):
    unique_key: str = field(init=False, metadata=dict(init_required=True))
github fishtown-analytics / dbt / core / dbt / View on Github external
from hologram import JsonSchemaMixin
from hologram.helpers import StrEnum
from typing import Optional

class Matchers(StrEnum):
    GREATER_THAN = '>'
    LESS_THAN = '<'
    EXACT = '='

class VersionSpecification(JsonSchemaMixin):
    major: Optional[str]
    minor: Optional[str]
    patch: Optional[str]
    prerelease: Optional[str]
    build: Optional[str]
    matcher: Matchers = Matchers.EXACT

_MATCHERS = r"(?P\>=|\>|\<|\<=|=)?"
_NUM_NO_LEADING_ZEROS = r"(0|[1-9][0-9]*)"
_ALPHA = r"[0-9A-Za-z-]*"
_ALPHA_NO_LEADING_ZEROS = r"(0|[1-9A-Za-z-][0-9A-Za-z-]*)"