From e2154e7c39ffc586e60fb3bbea6190b57055a6cc Mon Sep 17 00:00:00 2001 From: kraysent Date: Thu, 13 Nov 2025 14:11:26 +0000 Subject: [PATCH 1/2] #327: remove old code --- app/domain/dataapi/actions.py | 2 - app/domain/model/__init__.py | 4 - app/domain/model/layer0/__init__.py | 4 - app/domain/model/layer0/biblio.py | 19 -- .../model/layer0/coordinates/__init__.py | 3 - .../layer0/coordinates/coordinate_descr.py | 63 ------ .../model/layer0/coordinates/icrs_descr.py | 22 --- app/domain/model/layer0/dataset.py | 12 -- app/domain/model/layer0/layer_0_meta.py | 29 --- app/domain/model/layer0/layer_0_model.py | 23 --- app/domain/model/layer0/names/__init__.py | 6 - .../model/layer0/names/comma_name_descr.py | 16 -- .../layer0/names/multi_col_name_descr.py | 21 -- app/domain/model/layer0/names/name_descr.py | 24 --- .../layer0/names/single_col_name_descr.py | 8 - .../model/layer0/transformation_0_1_fail.py | 14 -- app/domain/model/layer0/values/__init__.py | 3 - app/domain/model/layer0/values/exceptions.py | 12 -- .../model/layer0/values/no_error_value.py | 19 -- app/domain/model/layer0/values/value_descr.py | 56 ------ app/domain/model/layer1/__init__.py | 0 app/domain/model/layer1/layer_1_model.py | 31 --- app/domain/model/layer1/layer_1_value.py | 18 -- app/domain/model/layer2/__init__.py | 3 - app/domain/model/layer2/layer_2_model.py | 27 --- app/domain/model/params/__init__.py | 46 ----- .../params/cross_identification_result.py | 180 ------------------ .../params/cross_identification_user_param.py | 9 - .../model/params/layer_0_query_param.py | 6 - .../model/params/layer_1_query_param.py | 5 - .../model/params/layer_2_query_param.py | 19 -- .../model/params/transaction_0_1_stages.py | 18 -- .../model/params/transformation_0_1_stages.py | 22 --- app/domain/unification/marking.py | 1 - app/presentation/adminapi/interface.py | 20 -- pyproject.toml | 1 + tests/env_test.py | 2 - tests/unit/domain/names_parsing_test.py | 52 ----- tests/unit/domain/value_descr_test.py | 44 ----- 39 files changed, 1 insertion(+), 863 deletions(-) delete mode 100644 app/domain/model/__init__.py delete mode 100644 app/domain/model/layer0/__init__.py delete mode 100644 app/domain/model/layer0/biblio.py delete mode 100644 app/domain/model/layer0/coordinates/__init__.py delete mode 100644 app/domain/model/layer0/coordinates/coordinate_descr.py delete mode 100644 app/domain/model/layer0/coordinates/icrs_descr.py delete mode 100644 app/domain/model/layer0/dataset.py delete mode 100644 app/domain/model/layer0/layer_0_meta.py delete mode 100644 app/domain/model/layer0/layer_0_model.py delete mode 100644 app/domain/model/layer0/names/__init__.py delete mode 100644 app/domain/model/layer0/names/comma_name_descr.py delete mode 100644 app/domain/model/layer0/names/multi_col_name_descr.py delete mode 100644 app/domain/model/layer0/names/name_descr.py delete mode 100644 app/domain/model/layer0/names/single_col_name_descr.py delete mode 100644 app/domain/model/layer0/transformation_0_1_fail.py delete mode 100644 app/domain/model/layer0/values/__init__.py delete mode 100644 app/domain/model/layer0/values/exceptions.py delete mode 100644 app/domain/model/layer0/values/no_error_value.py delete mode 100644 app/domain/model/layer0/values/value_descr.py delete mode 100644 app/domain/model/layer1/__init__.py delete mode 100644 app/domain/model/layer1/layer_1_model.py delete mode 100644 app/domain/model/layer1/layer_1_value.py delete mode 100644 app/domain/model/layer2/__init__.py delete mode 100644 app/domain/model/layer2/layer_2_model.py delete mode 100644 app/domain/model/params/__init__.py delete mode 100644 app/domain/model/params/cross_identification_result.py delete mode 100644 app/domain/model/params/cross_identification_user_param.py delete mode 100644 app/domain/model/params/layer_0_query_param.py delete mode 100644 app/domain/model/params/layer_1_query_param.py delete mode 100644 app/domain/model/params/layer_2_query_param.py delete mode 100644 app/domain/model/params/transaction_0_1_stages.py delete mode 100644 app/domain/model/params/transformation_0_1_stages.py delete mode 100644 tests/unit/domain/names_parsing_test.py delete mode 100644 tests/unit/domain/value_descr_test.py diff --git a/app/domain/dataapi/actions.py b/app/domain/dataapi/actions.py index 006631da..7a4d96b5 100644 --- a/app/domain/dataapi/actions.py +++ b/app/domain/dataapi/actions.py @@ -101,5 +101,3 @@ def expression_to_filter(expr: expressions.Node) -> tuple[layer2.Filter, layer2. ) return parse_function_node(expr) - - return None diff --git a/app/domain/model/__init__.py b/app/domain/model/__init__.py deleted file mode 100644 index f8b0c39f..00000000 --- a/app/domain/model/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from app.domain.model.layer0.layer_0_model import Layer0Model -from app.domain.model.layer1.layer_1_model import Layer1Model - -__all__ = ["Layer0Model", "Layer1Model"] diff --git a/app/domain/model/layer0/__init__.py b/app/domain/model/layer0/__init__.py deleted file mode 100644 index 1f06a0d1..00000000 --- a/app/domain/model/layer0/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from app.domain.model.layer0.dataset import Dataset -from app.domain.model.layer0.transformation_0_1_fail import Transformation01Fail - -__all__ = ["Dataset", "Transformation01Fail"] diff --git a/app/domain/model/layer0/biblio.py b/app/domain/model/layer0/biblio.py deleted file mode 100644 index d85598f7..00000000 --- a/app/domain/model/layer0/biblio.py +++ /dev/null @@ -1,19 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class Biblio: - """ - Holds bibliographic information - Args: - id: Unique bibliography id - ref_str: A code, used to find an article on [https://ui.adsabs.harvard.edu/] - first_author: First author - year: Publish year - """ - - id: int | None - ref_str: str | None - authors: list[str] - year: int - title: str diff --git a/app/domain/model/layer0/coordinates/__init__.py b/app/domain/model/layer0/coordinates/__init__.py deleted file mode 100644 index f7d5014e..00000000 --- a/app/domain/model/layer0/coordinates/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from app.domain.model.layer0.coordinates.icrs_descr import ICRSDescrStr - -__all__ = ["ICRSDescrStr"] diff --git a/app/domain/model/layer0/coordinates/coordinate_descr.py b/app/domain/model/layer0/coordinates/coordinate_descr.py deleted file mode 100644 index 938c2422..00000000 --- a/app/domain/model/layer0/coordinates/coordinate_descr.py +++ /dev/null @@ -1,63 +0,0 @@ -from abc import ABC, abstractmethod -from collections.abc import Iterable, Sequence -from typing import Any - -from astropy.coordinates import ICRS, SkyCoord -from pandas import DataFrame - -from app.domain.model.layer0.values.exceptions import ColumnNotFoundException - - -class CoordinateDescr(ABC): - """ - Class, responsible to parse coordinates of certain types - """ - - def __init__(self, *col_names: str): - """ - :param col_names: Names of columns, used to make coordinates - """ - self._col_names: list[str] = list(col_names) - - def parse_coordinates(self, data: DataFrame) -> Sequence[ICRS | ValueError]: - try: - col = data[self._col_names] - except KeyError as e: - raise ColumnNotFoundException(list(set(self._col_names) - set(data.columns.values)), cause=e) from e - - return col.apply(self.__parse_row, axis=1) - - def __parse_row(self, data: Iterable[Any]) -> ICRS | ValueError: - """ - :param data: Collection of values from table row, order is as specified in column_names in constructor - :return: Parsed coordinates or ValueError if parsing ended up in error - """ - try: - return self._parse_row(data).transform_to("icrs") - except ValueError as e: - return e - - def arg_number(self, col_name: str) -> int | None: - """ - Returns argument number in constructor, if the name was passed in constructor - :param col_name: Column name - :return: Argument number or none if column not present - """ - try: - return self._col_names.index(col_name) - except ValueError: - return None - - @abstractmethod - def _parse_row(self, data: Iterable[Any]) -> SkyCoord: - """ - Should be implemented for parsing - :param data: Collection of values from table row, order is as specified in column_names in constructor - :return: Parsed coordinates - """ - - @abstractmethod - def description_id(self): - """ - Resturn's id of this coordinate description (e.g 'icrs' for ICRS system) - """ diff --git a/app/domain/model/layer0/coordinates/icrs_descr.py b/app/domain/model/layer0/coordinates/icrs_descr.py deleted file mode 100644 index 929a8b97..00000000 --- a/app/domain/model/layer0/coordinates/icrs_descr.py +++ /dev/null @@ -1,22 +0,0 @@ -from collections.abc import Iterable -from typing import Any - -import astropy.units as u -from astropy.coordinates import SkyCoord - -from app.domain.model.layer0.coordinates.coordinate_descr import CoordinateDescr - -ICRS_DESCR_ID = "icrs" - - -class ICRSDescrStr(CoordinateDescr): - """ - Parses 'icrs' string representation. Containing icrs data may be one column, with data - like '00h42m30s +41d12m00s', or two columns for 'ra' and 'dec' respectively. - """ - - def description_id(self): - return ICRS_DESCR_ID - - def _parse_row(self, data: Iterable[Any]) -> SkyCoord: - return SkyCoord(*data, frame="icrs", unit=(u.Unit("hourangle"), u.Unit("deg"))) diff --git a/app/domain/model/layer0/dataset.py b/app/domain/model/layer0/dataset.py deleted file mode 100644 index a0e3d17c..00000000 --- a/app/domain/model/layer0/dataset.py +++ /dev/null @@ -1,12 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class Dataset: - """ - Describes where data came from, measurements specifics - Args: - reliability: A string from enum [domain.model.constants.Reliability], used to determine reliability og the data - """ - - reliability: str diff --git a/app/domain/model/layer0/layer_0_meta.py b/app/domain/model/layer0/layer_0_meta.py deleted file mode 100644 index 6a02fa96..00000000 --- a/app/domain/model/layer0/layer_0_meta.py +++ /dev/null @@ -1,29 +0,0 @@ -from dataclasses import dataclass - -from app.domain.model.layer0.biblio import Biblio -from app.domain.model.layer0.coordinates.coordinate_descr import CoordinateDescr -from app.domain.model.layer0.dataset import Dataset -from app.domain.model.layer0.names import NameDescr -from app.domain.model.layer0.values.value_descr import ValueDescr - - -@dataclass -class Layer0Meta: - """ - Metadata, used for transfer from layer 0 to layer 1 - Args: - value_descriptions: List of implementations of [values.value_descr.ValueDescr], used to parse values from - columns to astropy.units.Quantity, processed by level 1 - coordinate_descr: Implementation of coordinates.CoordinateDescr, used to parse coordinates correctly - names_descr: Describes, where object names are stored - dataset: Describes where data came from, measurements specifics - comment: Optional comment - biblio: Bibliographic information - """ - - value_descriptions: list[ValueDescr] - coordinate_descr: CoordinateDescr | None - names_descr: NameDescr | None - dataset: Dataset | None - comment: str | None - biblio: Biblio | None diff --git a/app/domain/model/layer0/layer_0_model.py b/app/domain/model/layer0/layer_0_model.py deleted file mode 100644 index 2dab0b89..00000000 --- a/app/domain/model/layer0/layer_0_model.py +++ /dev/null @@ -1,23 +0,0 @@ -from dataclasses import dataclass - -from pandas import DataFrame - -from app.domain.model.layer0.layer_0_meta import Layer0Meta - - -@dataclass -class Layer0Model: - """ - Data model for layer 0 data. Represents single income to DB. E.g. a table from some article, a dataset from other DB - Args: - id: Unique layer 0 data node id - processed: True, if node processed, and data transformed further. False if not transformed, or changed after - last transformation - meta: Metadata, used to transform data further - data: Data, to be processed - """ - - id: str - processed: bool - meta: Layer0Meta - data: DataFrame diff --git a/app/domain/model/layer0/names/__init__.py b/app/domain/model/layer0/names/__init__.py deleted file mode 100644 index a08c0a73..00000000 --- a/app/domain/model/layer0/names/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from app.domain.model.layer0.names.comma_name_descr import CommaNameDescr -from app.domain.model.layer0.names.multi_col_name_descr import MultyColNameDescr -from app.domain.model.layer0.names.name_descr import NameDescr -from app.domain.model.layer0.names.single_col_name_descr import SingleColNameDescr - -__all__ = ["CommaNameDescr", "MultyColNameDescr", "NameDescr", "SingleColNameDescr"] diff --git a/app/domain/model/layer0/names/comma_name_descr.py b/app/domain/model/layer0/names/comma_name_descr.py deleted file mode 100644 index a97b0147..00000000 --- a/app/domain/model/layer0/names/comma_name_descr.py +++ /dev/null @@ -1,16 +0,0 @@ -from pandas import Series - -from app.domain.model.layer0.names.name_descr import NameDescr - - -class CommaNameDescr(NameDescr): - """Case, where different names come in single column, comma separated""" - - def __init__(self, name_col: str, main_idx: int): - self._name_col = name_col - self._main_idx = main_idx - - def _parse_row(self, data: Series) -> tuple[str, list[str]]: - names = data[self._name_col].split(",") - - return names[self._main_idx], names diff --git a/app/domain/model/layer0/names/multi_col_name_descr.py b/app/domain/model/layer0/names/multi_col_name_descr.py deleted file mode 100644 index e1678318..00000000 --- a/app/domain/model/layer0/names/multi_col_name_descr.py +++ /dev/null @@ -1,21 +0,0 @@ -from pandas import Series - -from app.domain.model.layer0.names.name_descr import NameDescr - - -class MultyColNameDescr(NameDescr): - """Case, where different names go in different columns""" - - def __init__(self, main_col, name_cols): - """ - :param main_col: Column, where main name is located - :param name_cols: Columns, containing names - """ - self._main_col = main_col - self._name_cols = name_cols - - def _parse_row(self, data: Series) -> tuple[str, list[str]]: - main_name = data[self._main_col] - all_names = data[self._name_cols] - - return main_name, list(all_names) diff --git a/app/domain/model/layer0/names/name_descr.py b/app/domain/model/layer0/names/name_descr.py deleted file mode 100644 index d09ae854..00000000 --- a/app/domain/model/layer0/names/name_descr.py +++ /dev/null @@ -1,24 +0,0 @@ -from abc import ABC, abstractmethod -from collections.abc import Sequence - -from pandas import DataFrame, Series - - -class NameDescr(ABC): - """Describes, how to extract object names from table""" - - def parse_name(self, data: DataFrame) -> Sequence[tuple[str, list[str]] | Exception]: - """ - Extract names from data - :param data: Data table - :return: For each row tuple of (main name, all names) or error if unable to parse name - """ - return data.apply(self._parse_row, axis=1) - - @abstractmethod - def _parse_row(self, data: Series) -> tuple[str, list[str]]: - """ - Should be implemented for parsing - :param data: Collection of values from table row, order is as specified in column_names in constructor - :return: Parsed main name and all names - """ diff --git a/app/domain/model/layer0/names/single_col_name_descr.py b/app/domain/model/layer0/names/single_col_name_descr.py deleted file mode 100644 index c7a88315..00000000 --- a/app/domain/model/layer0/names/single_col_name_descr.py +++ /dev/null @@ -1,8 +0,0 @@ -from app.domain.model.layer0.names.multi_col_name_descr import MultyColNameDescr - - -class SingleColNameDescr(MultyColNameDescr): - """Case, when object has single name""" - - def __init__(self, column_name): - super().__init__(column_name, [column_name]) diff --git a/app/domain/model/layer0/transformation_0_1_fail.py b/app/domain/model/layer0/transformation_0_1_fail.py deleted file mode 100644 index a7f2e113..00000000 --- a/app/domain/model/layer0/transformation_0_1_fail.py +++ /dev/null @@ -1,14 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class Transformation01Fail: - """ - Holds information about a fail and it's cause - Args: - cause: Fail cause - original_row: Row in original table - """ - - cause: BaseException - original_row: int diff --git a/app/domain/model/layer0/values/__init__.py b/app/domain/model/layer0/values/__init__.py deleted file mode 100644 index 07a1feaa..00000000 --- a/app/domain/model/layer0/values/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from app.domain.model.layer0.values.no_error_value import NoErrorValue - -__all__ = ["NoErrorValue"] diff --git a/app/domain/model/layer0/values/exceptions.py b/app/domain/model/layer0/values/exceptions.py deleted file mode 100644 index 8a95a85d..00000000 --- a/app/domain/model/layer0/values/exceptions.py +++ /dev/null @@ -1,12 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class ColumnNotFoundException(RuntimeError): - """ - Thrown when parser form metadata can not find column - """ - - column_names: list[str] - cause: BaseException | None = None - message: str | None = None diff --git a/app/domain/model/layer0/values/no_error_value.py b/app/domain/model/layer0/values/no_error_value.py deleted file mode 100644 index 47726586..00000000 --- a/app/domain/model/layer0/values/no_error_value.py +++ /dev/null @@ -1,19 +0,0 @@ -from collections.abc import Sequence - -from pandas import DataFrame - -from app.domain.model.layer0.values.value_descr import ValueDescr - - -class NoErrorValue(ValueDescr): - """ - A value with unspecified error - """ - - def __init__(self, ucd: str, column_name: str, units: str): - super().__init__(ucd, column_name, units) - - self._column_name: str = column_name - - def parse_values(self, data: DataFrame) -> Sequence: - return self._parse_column(data) diff --git a/app/domain/model/layer0/values/value_descr.py b/app/domain/model/layer0/values/value_descr.py deleted file mode 100644 index 01b55428..00000000 --- a/app/domain/model/layer0/values/value_descr.py +++ /dev/null @@ -1,56 +0,0 @@ -from abc import ABC, abstractmethod -from collections.abc import Sequence - -from astropy.units import Quantity, Unit -from pandas import DataFrame, Series - -from app.domain.model.layer0.values.exceptions import ColumnNotFoundException - - -class ValueDescr(ABC): - """ - Class, used for parsing values of certain types. Including errors for this values - """ - - def __init__(self, ucd: str, column_name: str, units: str): - """ - :param ucd: UCD key for this value. Used to map value to layer 1 data types - :param column_name: Column in DataFrame to work with - :param units: Unit string representation (e.g. 'km/s'), that will be processed by `astropy.units` - """ - self._ucd: str = ucd - self._column_name: str = column_name - self._units: str = units - - @abstractmethod - def parse_values(self, data: DataFrame) -> Sequence[Quantity]: - pass - - @property - def ucd(self): - return self._ucd - - @ucd.getter - def ucd(self) -> str: - return self._ucd - - @property - def column_name(self): - return self._column_name - - @column_name.getter - def column_name(self) -> str: - return self._column_name - - @column_name.getter - def units(self) -> str: - return self._units - - def _parse_column(self, data: DataFrame) -> Sequence: - col: Series | None = data.get(self._column_name) - unit = Unit(self.units) - - if col is None: - raise ColumnNotFoundException([self._column_name]) - - return col.apply(lambda el: el * unit) diff --git a/app/domain/model/layer1/__init__.py b/app/domain/model/layer1/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/app/domain/model/layer1/layer_1_model.py b/app/domain/model/layer1/layer_1_model.py deleted file mode 100644 index d3d8a63e..00000000 --- a/app/domain/model/layer1/layer_1_model.py +++ /dev/null @@ -1,31 +0,0 @@ -from dataclasses import dataclass - -from astropy.coordinates import SkyCoord - -from app.domain.model.layer0 import Dataset -from app.domain.model.layer1.layer_1_value import Layer1Value - - -@dataclass -class Layer1Model: - """ - Data model for layer 1 data. Represents one observation of concrete object - Args: - pgc: PGC. id of this object (e.g. galaxy). May be None, if Layer 2 object is not currently created (the object - is just identified as new) - source_id: Layer0Model id, from where this data came - processed: True, if object processed, and data transformed further. False if not transformed, or changed after - last transformation - coordinates: SkyCoord frame in 'icrs'. Fully describes position on sky - name: Generally known name of the object, may be used to identify objects in other data sources - measurements: Measured values - dataset: Describes where data came from, measurements specifics - """ - - pgc: int | None - source_id: int - processed: bool - coordinates: SkyCoord | None - name: str | None - measurements: list[Layer1Value] - dataset: Dataset | None diff --git a/app/domain/model/layer1/layer_1_value.py b/app/domain/model/layer1/layer_1_value.py deleted file mode 100644 index 13eac978..00000000 --- a/app/domain/model/layer1/layer_1_value.py +++ /dev/null @@ -1,18 +0,0 @@ -from abc import ABC -from dataclasses import dataclass - -from astropy.units import Quantity - - -@dataclass -class Layer1Value(ABC): - """ - Some value (measurement) of concrete data type (e.g. km/s). - Args: - value: astropy.units.Quantity, representing a value, and it's unit - ucd: UCD (https://www.ivoa.net/documents/REC/VOTable/VOTable-20040811.html#ToC28) key, - describing this value type, and maps to Layer0Meta.columnMap - """ - - value: Quantity - ucd: str diff --git a/app/domain/model/layer2/__init__.py b/app/domain/model/layer2/__init__.py deleted file mode 100644 index e7210103..00000000 --- a/app/domain/model/layer2/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from app.domain.model.layer2.layer_2_model import Layer2Model - -__all__ = ["Layer2Model"] diff --git a/app/domain/model/layer2/layer_2_model.py b/app/domain/model/layer2/layer_2_model.py deleted file mode 100644 index a22fd6f7..00000000 --- a/app/domain/model/layer2/layer_2_model.py +++ /dev/null @@ -1,27 +0,0 @@ -import datetime -from dataclasses import dataclass - -from astropy.coordinates import ICRS, Angle - - -@dataclass -class Layer2Model: - """ - Data model for layer 2. Represents processed (averaged) measurements - Args: - `pgc`: PGC. This object unique id - `coordinates`: This object averaged coordinates in ICRS - `names`: All known names for this object - `common_name`: Common name for this object - `err_ra`: RA error - `err_dec`: DEC error - `modified`: Last modification time - """ - - pgc: int - coordinates: ICRS - names: list[str] - common_name: str | None - err_ra: Angle - err_dec: Angle - modified: datetime.datetime diff --git a/app/domain/model/params/__init__.py b/app/domain/model/params/__init__.py deleted file mode 100644 index e98cd3c9..00000000 --- a/app/domain/model/params/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from abc import ABC, abstractmethod -from dataclasses import dataclass - -from astropy.coordinates import ICRS, Angle - -__all__ = ["TmpDataRepositoryQueryParam"] - - -class TmpDataRepositoryQueryParam(ABC): - @abstractmethod - def table_name(self): - pass - - -@dataclass -class TmpCoordinateTableQueryParam(TmpDataRepositoryQueryParam): - """ - Parameter to query coordinates in some circle on the sky - Args: - `name`: Name of temporary table - `center`: Center of query circle - `r`: Radius of query circle - """ - - name: str - center: ICRS - r: Angle - - def table_name(self): - return self.name - - -@dataclass -class TmpNameTableQueryParam(TmpDataRepositoryQueryParam): - """ - Parameter to query by names - Args: - `t_name`: Name of temporary table - `names`: Names to be queried - """ - - t_name: str - names: list[str] - - def table_name(self): - return self.t_name diff --git a/app/domain/model/params/cross_identification_result.py b/app/domain/model/params/cross_identification_result.py deleted file mode 100644 index 2a74e173..00000000 --- a/app/domain/model/params/cross_identification_result.py +++ /dev/null @@ -1,180 +0,0 @@ -import abc -from dataclasses import dataclass - -from astropy.coordinates import ICRS, Angle - -from app.domain.model.layer2 import Layer2Model - - -class CrossIdentificationException(abc.ABC): - """ - Base cross identification exception - """ - - -class CrossIdentifyResult: - def __init__(self, result: Layer2Model | None, fail: CrossIdentificationException | None): - """ - :param result: None if new object, Layer2Model if existing object - :param fail: None if success, CrossIdentificationException if fail - """ - self.result: Layer2Model | None = result - self.fail: CrossIdentificationException | None = fail - - -@dataclass -class CrossIdentificationEmptyException(CrossIdentificationException): - """Both coordinates and name provided are empty""" - - -@dataclass -class CrossIdentificationNamesNotFoundException(CrossIdentificationException): - """Case, when only name known, but it has no matches in DB""" - - def __init__(self, names: list[str]): - """ - :param names: Names, provided in raw table - """ - self.names = names - - -@dataclass -class CrossIdentificationNamesDuplicateException(CrossIdentificationException): - """Case, when provided names found for multiple objects in DB""" - - def __init__(self, names: list[str]): - """ - :param names: Names, provided in raw table - """ - self.names = names - - -@dataclass -class CrossIdentificationCoordCollisionException(CrossIdentificationException): - """ - Describes collisions from cross identification use case - """ - - def __init__(self, coordinates: ICRS, r1: Angle, r2: Angle, collisions: list[Layer2Model]): - """ - :param coordinates: Coordinates to identify - :param r1: Inner radius - :param r2: Outer radius - :param collisions: The collided objects from DB - """ - self.coordinates: ICRS = coordinates - self.r1: Angle = r1 - self.r2: Angle = r2 - self.collisions: list[Layer2Model] = collisions - - -@dataclass -class ObjectInfo: - pass - - -@dataclass -class CrossIdentificationNameCoordCollisionException(CrossIdentificationException): - """ - Describes collision, when cross identified name and coordinates mismatch - """ - - def __init__(self, target_param: ObjectInfo, name_hit: Layer2Model | None, coord_hit: Layer2Model | None): - """ - :param target_param: The configuration, that caused collision - :param name_hit: Cross identification by name result - :param coord_hit: Cross identification by coordinates result - """ - self.target_param = target_param - self.name_hit = name_hit - self.coord_hit = coord_hit - - -@dataclass -class CrossIdentificationNameCoordFailException(CrossIdentificationException): - """ - Describes collision, when both cross identification by name and by coordinates need user interaction - """ - - def __init__( - self, - target_param: ObjectInfo, - name_collision: CrossIdentificationException, - coord_collision: CrossIdentificationException, - ): - """ - :param target_param: The configuration, that caused collision - :param name_collision: Cross identification by name collision - :param coord_collision: Cross identification by coordinates collision - """ - self.target_param = target_param - self.name_collision = name_collision - self.coord_collision = coord_collision - - -@dataclass -class CrossIdentificationNameCoordCoordException(CrossIdentificationException): - """ - Describes collision, name cross identification is successful, but coordinate cross identification needs user - interaction - """ - - def __init__( - self, - target_param: ObjectInfo, - name_hit: Layer2Model | None, - coord_collision: CrossIdentificationException, - ): - """ - :param target_param: The configuration, that caused collision - :param name_hit: Cross identification by name result - :param coord_collision: Cross identification by coordinates collision - """ - self.target_param = target_param - self.name_hit = name_hit - self.coord_collision = coord_collision - - -@dataclass -class CrossIdentificationNameCoordNameFailException(CrossIdentificationException): - """ - Describes collision, coordinate cross identification is successful, but name cross identification needs user - interaction - """ - - def __init__( - self, - target_param: ObjectInfo, - name_collision: CrossIdentificationException, - coord_hit: Layer2Model | None, - ): - """ - :param target_param: The configuration, that caused collision - :param name_collision: Cross identification by name collision - :param coord_hit: Cross identification by coordinates result - """ - self.target_param = target_param - self.name_collision = name_collision - self.coord_hit = coord_hit - - -@dataclass -class CrossIdentificationDuplicateException(CrossIdentificationException): - """ - When collision found between simultaneously processed objects - """ - - def __init__( - self, - target_param: ObjectInfo, - collisions: list[ObjectInfo], - db_cross_id_result: CrossIdentifyResult | CrossIdentificationCoordCollisionException, - ): - """ - :param target_param: The configuration, that caused collision - :param collisions: Collisions with simultaneously processed objects - :param db_cross_id_result: The result of cross identification with DB objects - """ - self.target_param: ObjectInfo = target_param - self.collisions: list[ObjectInfo] = collisions - self.db_cross_id_result: CrossIdentifyResult | CrossIdentificationCoordCollisionException = db_cross_id_result diff --git a/app/domain/model/params/cross_identification_user_param.py b/app/domain/model/params/cross_identification_user_param.py deleted file mode 100644 index d0a3ea58..00000000 --- a/app/domain/model/params/cross_identification_user_param.py +++ /dev/null @@ -1,9 +0,0 @@ -from dataclasses import dataclass - -from astropy.coordinates import Angle - - -@dataclass -class CrossIdentificationUserParam: - r1: Angle | None - r2: Angle | None diff --git a/app/domain/model/params/layer_0_query_param.py b/app/domain/model/params/layer_0_query_param.py deleted file mode 100644 index f663e80a..00000000 --- a/app/domain/model/params/layer_0_query_param.py +++ /dev/null @@ -1,6 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class Layer0QueryParam: - pass diff --git a/app/domain/model/params/layer_1_query_param.py b/app/domain/model/params/layer_1_query_param.py deleted file mode 100644 index 7a487065..00000000 --- a/app/domain/model/params/layer_1_query_param.py +++ /dev/null @@ -1,5 +0,0 @@ -from abc import ABC - - -class Layer1QueryParam(ABC): - pass diff --git a/app/domain/model/params/layer_2_query_param.py b/app/domain/model/params/layer_2_query_param.py deleted file mode 100644 index 4d5169ff..00000000 --- a/app/domain/model/params/layer_2_query_param.py +++ /dev/null @@ -1,19 +0,0 @@ -from abc import ABC -from dataclasses import dataclass - -from astropy.coordinates import ICRS, Angle - - -class Layer2QueryParam(ABC): - pass - - -@dataclass -class Layer2QueryByNames(Layer2QueryParam): - names: list[str] - - -@dataclass -class Layer2QueryInCircle(Layer2QueryParam): - center: ICRS - r: Angle diff --git a/app/domain/model/params/transaction_0_1_stages.py b/app/domain/model/params/transaction_0_1_stages.py deleted file mode 100644 index 42fdc8a0..00000000 --- a/app/domain/model/params/transaction_0_1_stages.py +++ /dev/null @@ -1,18 +0,0 @@ -from abc import ABC -from dataclasses import dataclass - -from app.domain.model.params.transformation_0_1_stages import Transformation01Stage - - -class TransactionO1Sage(ABC): - pass - - -@dataclass -class AwaitingQueue(TransactionO1Sage): - pass - - -@dataclass -class TransformingData(TransactionO1Sage): - stage: Transformation01Stage diff --git a/app/domain/model/params/transformation_0_1_stages.py b/app/domain/model/params/transformation_0_1_stages.py deleted file mode 100644 index bef070a1..00000000 --- a/app/domain/model/params/transformation_0_1_stages.py +++ /dev/null @@ -1,22 +0,0 @@ -from abc import ABC -from dataclasses import dataclass - - -class Transformation01Stage(ABC): - pass - - -@dataclass -class ParseCoordinates(Transformation01Stage): - pass - - -@dataclass -class ParseValues(Transformation01Stage): - pass - - -@dataclass -class CrossIdentification(Transformation01Stage): - total: int - progress: int diff --git a/app/domain/unification/marking.py b/app/domain/unification/marking.py index b9d63a83..2efecba1 100644 --- a/app/domain/unification/marking.py +++ b/app/domain/unification/marking.py @@ -57,7 +57,6 @@ def mark_objects( layer1_repo: repositories.Layer1Repository, table_name: str, batch_size: int, - cache_enabled: bool = False, initial_offset: str | None = None, ignore_homogenization_errors: bool = True, ) -> None: diff --git a/app/presentation/adminapi/interface.py b/app/presentation/adminapi/interface.py index 46ddecfe..bd3cfd83 100644 --- a/app/presentation/adminapi/interface.py +++ b/app/presentation/adminapi/interface.py @@ -130,26 +130,6 @@ class PatchTableResponse(pydantic.BaseModel): pass -class CrossIdentification(pydantic.BaseModel): - inner_radius_arcsec: float = 1.5 - outer_radius_arcsec: float = 3 - - -class SetTableStatusOverrides(pydantic.BaseModel): - id: str - pgc: int | None = None - - -class SetTableStatusRequest(pydantic.BaseModel): - table_id: int - overrides: list[SetTableStatusOverrides] | None = None - batch_size: int = 100 - - -class SetTableStatusResponse(pydantic.BaseModel): - pass - - class CreateSourceRequest(pydantic.BaseModel): title: str authors: list[str] = pydantic.Field(examples=[["Ivanov V.", "Johnson H."]]) diff --git a/pyproject.toml b/pyproject.toml index afe6c5e9..5f8cb794 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,7 @@ dependencies = [ "starlette>=0.47.2", "pydantic-settings>=2.10.1", "uncertainties>=3.2.3", + "vulture>=2.14", ] [project.optional-dependencies] diff --git a/tests/env_test.py b/tests/env_test.py index 2d5a1a84..bb6b605f 100644 --- a/tests/env_test.py +++ b/tests/env_test.py @@ -1,6 +1,5 @@ import sys import unittest -from pathlib import Path from parameterized import parameterized @@ -8,7 +7,6 @@ import app.commands.dataapi.command as dataapi import app.commands.runtask.command as runtask -REQUIREMENTS_PATH = Path("requirements.txt") MINIMAL_PYTHON_VERSION = (3, 10) diff --git a/tests/unit/domain/names_parsing_test.py b/tests/unit/domain/names_parsing_test.py deleted file mode 100644 index caa86ee2..00000000 --- a/tests/unit/domain/names_parsing_test.py +++ /dev/null @@ -1,52 +0,0 @@ -import unittest - -from pandas import DataFrame - -from app.domain.model.layer0.names.comma_name_descr import CommaNameDescr -from app.domain.model.layer0.names.multi_col_name_descr import MultyColNameDescr -from app.domain.model.layer0.names.single_col_name_descr import SingleColNameDescr - - -class NamesParsingTest(unittest.TestCase): - def test_multi_name_descr(self): - data = DataFrame( - { - "name_1": ["a", "b", "c", "d"], - "name_2": ["f", "g", "h", "j"], - "col1": [1, 2, 3, 4], - } - ) - name_descr = MultyColNameDescr("name_1", ["name_1", "name_2"]) - - res = name_descr.parse_name(data) - - self.assertEqual(res[0], ("a", ["a", "f"])) - self.assertEqual(res[2], ("c", ["c", "h"])) - - def test_single_name_descr(self): - data = DataFrame( - { - "name_1": ["a", "b", "c", "d"], - "col1": [1, 2, 3, 4], - } - ) - name_descr = SingleColNameDescr("name_1") - - res = name_descr.parse_name(data) - - self.assertEqual(res[0], ("a", ["a"])) - self.assertEqual(res[3], ("d", ["d"])) - - def test_comma_name_descr(self): - data = DataFrame( - { - "name_1": ["a,s", "b,d", "c,f", "d,g"], - "col1": [1, 2, 3, 4], - } - ) - name_descr = CommaNameDescr("name_1", 1) - - res = name_descr.parse_name(data) - - self.assertEqual(res[0], ("s", ["a", "s"])) - self.assertEqual(res[2], ("f", ["c", "f"])) diff --git a/tests/unit/domain/value_descr_test.py b/tests/unit/domain/value_descr_test.py deleted file mode 100644 index a1623a6a..00000000 --- a/tests/unit/domain/value_descr_test.py +++ /dev/null @@ -1,44 +0,0 @@ -import unittest - -import astropy.units as u -from pandas import DataFrame - -from app.domain.model.layer0.values import NoErrorValue -from app.domain.model.layer0.values.exceptions import ColumnNotFoundException - - -class ValueDescrTest(unittest.TestCase): - def test_no_error_value(self): - df = DataFrame( - { - "speed": [1, 2, 3, 4], - } - ) - value_descr = NoErrorValue("placeholder", "speed", "km/s") - - speeds = value_descr.parse_values(df) - - # one km/sec == 1000 m/sec - self.assertEqual(speeds[1].to(u.Unit("m") / u.Unit("s")).value, df["speed"][1] * 1000) - - def test_column_not_found(self): - df = DataFrame( - { - "not_speed": [1, 2, 3, 4], - } - ) - value_descr = NoErrorValue("placeholder", "speed", "km/s") - - with self.assertRaises(ColumnNotFoundException) as scope: - value_descr.parse_values(df) - self.assertEqual(scope.exception.column_names, ["speed"]) - - def test_wrong_units(self): - df = DataFrame( - { - "speed": [1, 2, 3, 4], - } - ) - value_descr = NoErrorValue("placeholder", "speed", "not units") - - self.assertRaises(ValueError, lambda: value_descr.parse_values(df)) From 985f66646a6e22813a71dc97a6e407f3a402c80b Mon Sep 17 00:00:00 2001 From: kraysent Date: Thu, 13 Nov 2025 14:14:50 +0000 Subject: [PATCH 2/2] fix deps --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f8cb794..afe6c5e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ dependencies = [ "starlette>=0.47.2", "pydantic-settings>=2.10.1", "uncertainties>=3.2.3", - "vulture>=2.14", ] [project.optional-dependencies]