Skip to content

Commit

Permalink
Restructured into metadata and query module
Browse files Browse the repository at this point in the history
  • Loading branch information
Stiivi committed Jul 4, 2016
1 parent fdb944e commit 2ecbf0c
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 55 deletions.
4 changes: 1 addition & 3 deletions cubes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
__version__ = "1.1"

from .common import *
from .browser import *
from .cells import *
from .query import *
from .metadata import *
from .workspace import *
from .errors import *
from .formatters import *
from .computation import *
from .mapper import *
from .calendar import *
from .auth import *
Expand Down
2 changes: 1 addition & 1 deletion cubes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os.path
from collections import defaultdict
from .cells import Cell, cut_from_string, cut_from_dict, PointCut
from .query import Cell, cut_from_string, cut_from_dict, PointCut
from .metadata import string_to_dimension_level
from .errors import UserError, ConfigurationError, NoSuchDimensionError
from .common import read_json_file, sorted_dependencies
Expand Down
2 changes: 1 addition & 1 deletion cubes/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from . import compat
from . import ext

from .browser import SPLIT_DIMENSION_NAME
from .query import SPLIT_DIMENSION_NAME


__all__ = [
Expand Down
3 changes: 2 additions & 1 deletion cubes/metadata/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from collections import OrderedDict, defaultdict

from ..common import assert_all_instances, get_localizable_attributes
from ..statutils import aggregate_calculator_labels
# TODO: This should belong here
from ..query.statutils import aggregate_calculator_labels
from ..errors import ModelError, ArgumentError, NoSuchAttributeError
from ..errors import NoSuchDimensionError
from .base import ModelObject, object_dict
Expand Down
4 changes: 4 additions & 0 deletions cubes/query/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .browser import *
from .cells import *
from .computation import *
from .statutils import *
13 changes: 7 additions & 6 deletions cubes/browser.py → cubes/query/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

from collections import namedtuple

from ..calendar import CalendarMemberConverter
from ..logging import get_logger
from ..common import IgnoringDictionary
from ..errors import ArgumentError, NoSuchAttributeError, HierarchyError
from ..metadata import string_to_dimension_level

from .statutils import calculators_for_aggregates, available_calculators
from .calendar import CalendarMemberConverter
from .logging import get_logger
from .common import IgnoringDictionary
from .errors import ArgumentError, NoSuchAttributeError, HierarchyError
from .cells import Cell, PointCut, RangeCut, SetCut, cuts_from_string
from .metadata import string_to_dimension_level

from . import compat
from .. import compat


__all__ = [
Expand Down
8 changes: 4 additions & 4 deletions cubes/cells.py → cubes/query/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from collections import OrderedDict

from .errors import ArgumentError, CubesError
from .metadata import Dimension, Cube
from .logging import get_logger
from . import compat
from ..errors import ArgumentError, CubesError
from ..metadata import Dimension, Cube
from ..logging import get_logger
from .. import compat


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion cubes/computation.py → cubes/query/computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import itertools

from .errors import ArgumentError
from ..errors import ArgumentError

__all__ = [
"combined_cuboids",
Expand Down
4 changes: 2 additions & 2 deletions cubes/statutils.py → cubes/query/statutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from functools import partial
from math import sqrt

from .errors import ArgumentError, InternalError, ModelError
from . import compat
from ..errors import ArgumentError, InternalError, ModelError
from .. import compat

__all__ = [
"CALCULATED_AGGREGATIONS",
Expand Down
15 changes: 7 additions & 8 deletions cubes/server/blueprint.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
from flask import Blueprint, Response, request, g, current_app, url_for, safe_join, make_response
from flask import render_template, redirect
from jinja2 import Template
import json, re
from functools import wraps
import json
import sys
import traceback
from collections import OrderedDict

from flask import Blueprint, Response, request, g, current_app, safe_join, make_response
from flask import render_template, redirect

from ..workspace import Workspace, SLICER_INFO_KEYS
from ..cells import Cell, cut_from_dict
from ..browser import SPLIT_DIMENSION_NAME
from ..query import Cell, cut_from_dict
from ..query import SPLIT_DIMENSION_NAME
from ..errors import *
from ..formatters import JSONLinesGenerator, csv_generator
from .. import ext
Expand All @@ -21,7 +21,6 @@
from .local import *
from .auth import NotAuthenticated

from collections import OrderedDict

from cubes import __version__

Expand Down
2 changes: 1 addition & 1 deletion cubes/server/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import logging
from ..logging import get_logger
from ..browser import *
from ..query import *

class SlicerBrowser(AggregationBrowser):
"""Aggregation browser for Cubes Slicer OLAP server."""
Expand Down
6 changes: 3 additions & 3 deletions cubes/server/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from ..workspace import Workspace
from ..auth import NotAuthorized
from ..cells import Cell, cut_from_dict
from ..browser import SPLIT_DIMENSION_NAME
from ..cells import cuts_from_string
from ..query import Cell, cut_from_dict
from ..query import SPLIT_DIMENSION_NAME
from ..query import cuts_from_string
from ..errors import *
from .utils import *
from .errors import *
Expand Down
2 changes: 1 addition & 1 deletion cubes/server/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .. import compat
from ..logging import get_logger
from ..errors import *
from ..browser import Drilldown
from ..query import Drilldown

__all__ = [
"create_request_log_handler",
Expand Down
2 changes: 1 addition & 1 deletion cubes/server/store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding=utf -*-
from ..metadata import *
from ..browser import *
from ..query import *
from ..stores import Store
from ..errors import *
from ..logging import get_logger
Expand Down
4 changes: 2 additions & 2 deletions cubes/slicer/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

from .. import ext

from ..cells import cuts_from_string, Cell
from ..browser import string_to_dimension_level
from ..query import cuts_from_string, Cell
from ..metadata import string_to_dimension_level


DEFAULT_CONFIG = "slicer.ini"
Expand Down
6 changes: 3 additions & 3 deletions cubes/sql/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from ...common import MissingPackage
sqlalchemy = sql = MissingPackage("sqlalchemy", "SQL aggregation browser")

from ..statutils import available_calculators
from ..browser import AggregationBrowser, AggregationResult, Drilldown
from ..query import available_calculators
from ..query import AggregationBrowser, AggregationResult, Drilldown
from ..query import Cell, PointCut
from ..logging import get_logger
from ..errors import ArgumentError, InternalError
from ..stores import Store
from ..cells import Cell, PointCut
from ..metadata import collect_attributes
from .. import compat

Expand Down
4 changes: 2 additions & 2 deletions cubes/sql/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from ..metadata import object_dict
from ..errors import InternalError, ModelError, ArgumentError, HierarchyError
from .. import compat
from ..browser import SPLIT_DIMENSION_NAME
from ..cells import PointCut, SetCut, RangeCut
from ..query import SPLIT_DIMENSION_NAME
from ..query import PointCut, SetCut, RangeCut

from .expressions import compile_attributes

Expand Down
3 changes: 1 addition & 2 deletions cubes/sql/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from ..common import coalesce_options
from ..stores import Store
from ..errors import ArgumentError, StoreError, ConfigurationError
from ..browser import Drilldown
from ..cells import Cell
from ..query import Drilldown, Cell
from .utils import CreateTableAsSelect, CreateOrReplaceView
from ..metadata import string_to_dimension_level

Expand Down
2 changes: 1 addition & 1 deletion cubes/sql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from collections import OrderedDict

from ..browser import SPLIT_DIMENSION_NAME
from ..query import SPLIT_DIMENSION_NAME

__all__ = [
"CreateTableAsSelect",
Expand Down
12 changes: 3 additions & 9 deletions tests/sql/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
from __future__ import absolute_import

from unittest import TestCase, skip
import os
import json
import re
import sqlalchemy as sa
import datetime

from .common import create_table, SQLTestCase

from cubes.errors import HierarchyError
from cubes.cells import PointCut, SetCut, RangeCut, Cell
from cubes.sql import SQLBrowser, SQLStore
from cubes.sql import SQLStore
from cubes.sql.query import StarSchema, FACT_KEY_LABEL, to_join
from cubes.sql.query import QueryContext
from cubes.sql.mapper import map_base_attributes, StarSchemaMapper
from cubes.sql.mapper import distill_naming

from .dw.demo import create_demo_dw, TinyDemoModelProvider
from .common import SQLTestCase

#
# TODO: this should be workspace-free test
#
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cells.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest

from cubes.cells import Cell, PointCut, SetCut, RangeCut
from cubes.cells import string_from_path, cut_from_string, path_from_string
from cubes.cells import cut_from_dict
from cubes.query import Cell, PointCut, SetCut, RangeCut
from cubes.query import string_from_path, cut_from_string, path_from_string
from cubes.query import cut_from_dict
from cubes.errors import CubesError, ArgumentError
from cubes.errors import HierarchyError, NoSuchDimensionError

Expand Down

0 comments on commit 2ecbf0c

Please sign in to comment.