Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#646 remove init #741

Merged
merged 8 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions src/csvcubed/cli/error_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,15 @@
from os import linesep
from typing import Type, Union

from csvcubed.models.cube.qb import (
BothMeasureTypesDefinedError,
BothUnitTypesDefinedError,
CsvColumnUriTemplateMissingError,
EmptyQbMultiMeasureDimensionError,
MoreThanOneMeasureColumnError,
MoreThanOneUnitsColumnError,
NoDimensionsDefinedError,
NoMeasuresDefinedError,
NoObservedValuesColumnDefinedError,
NoUnitsDefinedError,
QbAttribute,
QbCodeList,
QbDimension,
QbMultiMeasureDimension,
QbMultiUnits,
QbObservationValue,
from csvcubed.models.cube.qb.components.attribute import QbAttribute
from csvcubed.models.cube.qb.components.codelist import QbCodeList
from csvcubed.models.cube.qb.components.datastructuredefinition import (
QbStructuralDefinition,
)
from csvcubed.models.cube.qb.components.dimension import QbDimension
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits
from csvcubed.models.cube.qb.components.validationerrors import (
ConflictingUriSafeValuesError,
EmptyQbMultiUnitsError,
Expand All @@ -32,10 +22,20 @@
)
from csvcubed.models.cube.qb.validationerrors import (
AttributeNotLinkedError,
BothMeasureTypesDefinedError,
BothUnitTypesDefinedError,
CsvColumnUriTemplateMissingError,
DuplicateMeasureError,
EmptyQbMultiMeasureDimensionError,
HybridShapeError,
LinkedObsColumnDoesntExistError,
LinkedToNonObsColumnError,
MoreThanOneMeasureColumnError,
MoreThanOneUnitsColumnError,
NoDimensionsDefinedError,
NoMeasuresDefinedError,
NoObservedValuesColumnDefinedError,
NoUnitsDefinedError,
PivotedObsValColWithoutMeasureError,
PivotedShapeMeasureColumnsExistError,
)
Expand Down
3 changes: 1 addition & 2 deletions src/csvcubed/models/codelistconfig/code_list_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from csvcubedmodels.dataclassbase import DataClassBase

from csvcubed.models.cube.qb.catalog import CatalogMetadata
from csvcubed.models.cube.qb.components import NewQbConcept
from csvcubed.models.cube.qb.components.concept import DuplicatedQbConcept
from csvcubed.models.cube.qb.components.concept import DuplicatedQbConcept, NewQbConcept
from csvcubed.readers.catalogmetadata.v1.catalog_metadata_reader import (
metadata_from_dict,
)
Expand Down
4 changes: 0 additions & 4 deletions src/csvcubed/models/cube/qb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .catalog import CatalogMetadata
from .columns import QbColumn
from .components import *
from .validationerrors import *
28 changes: 0 additions & 28 deletions src/csvcubed/models/cube/qb/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +0,0 @@
from .arbitraryrdf import RdfSerialisationHint
from .attribute import (
ExistingQbAttribute,
ExistingQbAttributeLiteral,
NewQbAttribute,
NewQbAttributeLiteral,
QbAttribute,
QbAttributeLiteral,
)
from .attributevalue import NewQbAttributeValue
from .codelist import (
CompositeQbCodeList,
ExistingQbCodeList,
NewQbCodeList,
NewQbCodeListInCsvW,
QbCodeList,
)
from .concept import DuplicatedQbConcept, ExistingQbConcept, NewQbConcept
from .datastructuredefinition import (
QbColumnStructuralDefinition,
QbStructuralDefinition,
)
from .dimension import ExistingQbDimension, NewQbDimension, QbDimension
from .measure import ExistingQbMeasure, NewQbMeasure, QbMeasure
from .measuresdimension import QbMultiMeasureDimension
from .observedvalue import QbObservationValue
from .unit import ExistingQbUnit, NewQbUnit, QbUnit
from .unitscolumn import QbMultiUnits
13 changes: 6 additions & 7 deletions src/csvcubed/models/cube/qb/validationerrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
from dataclasses import dataclass, field
from typing import List, Optional, Type, Union

from csvcubed.models.validationerror import SpecificValidationError

from ..qb import (
QbDimension,
QbMultiMeasureDimension,
QbMultiUnits,
QbObservationValue,
from csvcubed.models.cube.qb.components.datastructuredefinition import (
QbStructuralDefinition,
)
from csvcubed.models.cube.qb.components.dimension import QbDimension
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits
from csvcubed.models.validationerror import SpecificValidationError

ComponentTypeDescription = Union[str, Type[QbStructuralDefinition]]

Expand Down
28 changes: 15 additions & 13 deletions src/csvcubed/readers/cubeconfig/v1/columnschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,30 @@
from csvcubed.inputs import PandasDataTypes, pandas_input_to_columnar_optional_str
from csvcubed.models.codelistconfig.code_list_config import CodeListConfig
from csvcubed.models.cube.cube import CatalogMetadata
from csvcubed.models.cube.qb.components import (
CompositeQbCodeList,
DuplicatedQbConcept,
from csvcubed.models.cube.qb.components.attribute import (
ExistingQbAttribute,
ExistingQbAttributeLiteral,
ExistingQbCodeList,
ExistingQbDimension,
ExistingQbMeasure,
ExistingQbUnit,
NewQbAttribute,
NewQbAttributeLiteral,
NewQbAttributeValue,
)
from csvcubed.models.cube.qb.components.codelist import (
CompositeQbCodeList,
DuplicatedQbConcept,
ExistingQbCodeList,
NewQbCodeList,
NewQbDimension,
NewQbMeasure,
NewQbUnit,
QbCodeList,
QbMultiMeasureDimension,
QbMultiUnits,
QbObservationValue,
)
from csvcubed.models.cube.qb.components.concept import NewQbConcept
from csvcubed.models.cube.qb.components.dimension import (
ExistingQbDimension,
NewQbDimension,
)
from csvcubed.models.cube.qb.components.measure import ExistingQbMeasure, NewQbMeasure
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unit import ExistingQbUnit, NewQbUnit
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits
from csvcubed.models.jsonvalidationerrors import JsonSchemaValidationError
from csvcubed.readers.cubeconfig.utils import load_resource
from csvcubed.utils.file import code_list_config_json_exists
Expand Down
13 changes: 6 additions & 7 deletions src/csvcubed/utils/qb/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@

from csvcubed.models.cube.cube import Cube
from csvcubed.models.cube.cube_shape import CubeShape
from csvcubed.models.cube.qb.components import (
from csvcubed.models.cube.qb.components.datastructuredefinition import (
QbColumnStructuralDefinition,
QbMeasure,
QbMultiMeasureDimension,
QbMultiUnits,
QbObservationValue,
QbUnit,
)
from csvcubed.models.cube.qb.components.measure import QbMeasure
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits, QbUnit

_logger = logging.getLogger(__name__)


QbColumnarDsdType = TypeVar("QbColumnarDsdType", bound=QbColumnStructuralDefinition)
"""Anything which inherits from :class:`ColumnarQbDataStructureDefinition
"""Anything which inherits from :class:`ColumnarQbDataStructureDefinition
<csvcubed.models.cube.qb.components.datastructuredefinition.ColumnarQbDataStructureDefinition>`."""


Expand Down
20 changes: 8 additions & 12 deletions src/csvcubed/utils/qb/standardise.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,14 @@
from pandas.core.arrays.categorical import Categorical

from csvcubed.models.cube.cube import QbColumn, QbCube
from csvcubed.models.cube.qb.components import (
NewQbCodeList,
NewQbDimension,
NewQbMeasure,
NewQbUnit,
QbAttribute,
QbAttributeLiteral,
QbDimension,
QbMultiMeasureDimension,
QbMultiUnits,
QbObservationValue,
)
from csvcubed.models.cube.qb.components.attribute import QbAttribute, QbAttributeLiteral
from csvcubed.models.cube.qb.components.codelist import NewQbCodeList
from csvcubed.models.cube.qb.components.dimension import NewQbDimension, QbDimension
from csvcubed.models.cube.qb.components.measure import NewQbMeasure
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unit import NewQbUnit
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits

from .cube import get_all_measures, get_all_units

Expand Down
5 changes: 2 additions & 3 deletions src/csvcubed/utils/qb/validation/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from csvcubed.models.cube.cube import Cube
from csvcubed.models.cube.qb.columns import QbColumn
from csvcubed.models.cube.qb.components import (
from csvcubed.models.cube.qb.components.attribute import QbAttribute, QbAttributeLiteral
from csvcubed.models.cube.qb.components.dimension import (
ExistingQbDimension,
QbAttribute,
QbAttributeLiteral,
QbDimension,
)
from csvcubed.models.cube.qb.validationerrors import (
Expand Down
2 changes: 1 addition & 1 deletion src/csvcubed/writers/skoscodelistwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import pandas as pd
from csvcubedmodels.rdf import ExistingResource

from csvcubed.models.cube.qb.components import (
from csvcubed.models.cube.qb.components.codelist import (
CompositeQbCodeList,
DuplicatedQbConcept,
NewQbCodeList,
Expand Down
2 changes: 0 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .behaviour import *
robons marked this conversation as resolved.
Show resolved Hide resolved
from .unit import *
1 change: 1 addition & 0 deletions tests/unit/cli/inspect/test_inspectdatasetmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
)
from csvcubed.models.csvwtype import CSVWType
from csvcubed.models.cube.cube_shape import CubeShape
from csvcubed.models.cube.qb.validationerrors import BothMeasureTypesDefinedError
from csvcubed.models.inspectdataframeresults import (
DatasetObservationsByMeasureUnitInfoResult,
DatasetObservationsInfoResult,
Expand Down
1 change: 1 addition & 0 deletions tests/unit/cli/inspect/test_metadataprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from csvcubed.cli.inspect.metadataprinter import MetadataPrinter
from csvcubed.models.csvwtype import CSVWType
from csvcubed.models.cube.cube_shape import CubeShape
from csvcubed.models.cube.qb.validationerrors import BothMeasureTypesDefinedError
from csvcubed.models.inspectdataframeresults import (
DatasetObservationsByMeasureUnitInfoResult,
DatasetObservationsInfoResult,
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/cube/qb/test_qb_dimension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pandas as pd

from csvcubed.models.cube.qb.components import NewQbCodeList, NewQbDimension
from csvcubed.models.cube.qb.components.codelist import NewQbCodeList
from csvcubed.models.cube.qb.components.dimension import NewQbDimension


def test_newqbdimension_extracts_newqbcodelist_newqbconcept():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/cube/qb/test_qb_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from csvcubed.definitions import APP_ROOT_DIR_PATH
from csvcubed.models.cube.qb import QbColumn
from csvcubed.models.cube.qb.columns import QbColumn
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unit import ExistingQbUnit, NewQbUnit
from csvcubed.readers.cubeconfig.v1.columnschema import (
Expand Down
26 changes: 12 additions & 14 deletions tests/unit/readers/cubeconfig/v1_0/test_cube_from_config_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,31 @@
from csvcubed.cli.build import build as cli_build
from csvcubed.definitions import APP_ROOT_DIR_PATH
from csvcubed.models.cube.cube import Cube
from csvcubed.models.cube.qb import QbColumn
from csvcubed.models.cube.qb.catalog import CatalogMetadata
from csvcubed.models.cube.qb.components import (
NewQbAttribute,
NewQbCodeList,
NewQbConcept,
NewQbDimension,
NewQbMeasure,
NewQbUnit,
QbMultiMeasureDimension,
QbMultiUnits,
)
from csvcubed.models.cube.qb.columns import QbColumn
from csvcubed.models.cube.qb.components.attribute import (
ExistingQbAttribute,
ExistingQbAttributeLiteral,
NewQbAttribute,
NewQbAttributeLiteral,
)
from csvcubed.models.cube.qb.components.attributevalue import NewQbAttributeValue
from csvcubed.models.cube.qb.components.codelist import (
CompositeQbCodeList,
ExistingQbCodeList,
NewQbCodeList,
NewQbConcept,
)
from csvcubed.models.cube.qb.components.concept import DuplicatedQbConcept
from csvcubed.models.cube.qb.components.dimension import ExistingQbDimension
from csvcubed.models.cube.qb.components.measure import ExistingQbMeasure
from csvcubed.models.cube.qb.components.dimension import (
ExistingQbDimension,
NewQbDimension,
)
from csvcubed.models.cube.qb.components.measure import ExistingQbMeasure, NewQbMeasure
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unit import ExistingQbUnit
from csvcubed.models.cube.qb.components.unit import ExistingQbUnit, NewQbUnit
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits
from csvcubed.readers.catalogmetadata.v1.catalog_metadata_reader import (
metadata_from_dict,
)
Expand Down
17 changes: 7 additions & 10 deletions tests/unit/readers/cubeconfig/v1_0/test_cube_from_convention.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@
from csvcubed.models.csvcubedexception import UnsupportedColumnDefinitionException
from csvcubed.models.cube.columns import SuppressedCsvColumn
from csvcubed.models.cube.cube import Cube
from csvcubed.models.cube.qb import QbColumn
from csvcubed.models.cube.qb.catalog import CatalogMetadata
from csvcubed.models.cube.qb.components import (
NewQbCodeList,
NewQbConcept,
NewQbDimension,
NewQbMeasure,
NewQbUnit,
QbMultiMeasureDimension,
QbMultiUnits,
)
from csvcubed.models.cube.qb.columns import QbColumn
from csvcubed.models.cube.qb.components.codelist import NewQbCodeList, NewQbConcept
from csvcubed.models.cube.qb.components.dimension import NewQbDimension
from csvcubed.models.cube.qb.components.measure import NewQbMeasure
from csvcubed.models.cube.qb.components.measuresdimension import QbMultiMeasureDimension
from csvcubed.models.cube.qb.components.observedvalue import QbObservationValue
from csvcubed.models.cube.qb.components.unit import NewQbUnit
from csvcubed.models.cube.qb.components.unitscolumn import QbMultiUnits
from csvcubed.readers.cubeconfig.v1.configdeserialiser import get_deserialiser
from csvcubed.utils.iterables import first
from tests.unit.test_baseunit import get_test_cases_dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
RdfSerialisationHint,
TripleFragment,
)
from csvcubed.models.cube.qb.components.codelist import NewQbCodeList
from csvcubed.models.cube.qb.components.codelist import (
CompositeQbCodeList,
NewQbCodeList,
)
from csvcubed.models.cube.qb.components.concept import NewQbConcept
from csvcubed.models.cube.uristyle import URIStyle
from csvcubed.writers.skoscodelistwriter import SkosCodeListWriter
Expand Down