Skip to content
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
15 changes: 14 additions & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
name: Python Linting, Formatting, Testing, Coverage
on:
pull_request:
branches: [main, develop]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'
- 'pyproject.toml'
push:
branches:
- main
- develop
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'
- 'pyproject.toml'
jobs:
test:
runs-on: ubuntu-latest
Expand Down
24 changes: 7 additions & 17 deletions src/getml_io/getml/feature_learning.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from collections.abc import Set as AbstractSet
from typing import Annotated, ClassVar, Literal
from typing import Annotated, Literal

from getml.feature_learning.aggregations.types import (
FastPropAggregations,
Expand All @@ -11,12 +11,10 @@
CrossEntropyLossType,
SquareLossType,
)
from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, Field


class FastProp(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class FastProp(BaseModel, frozen=True):
aggregation: AbstractSet[FastPropAggregations]
delta_t: float
loss_function: CrossEntropyLossType | SquareLossType | None
Expand All @@ -31,9 +29,7 @@ class FastProp(BaseModel):
type: Literal["fast_prop"] = "fast_prop"


class Fastboost(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Fastboost(BaseModel, frozen=True):
gamma: float
loss_function: CrossEntropyLossType | SquareLossType | None
max_depth: int
Expand All @@ -48,9 +44,7 @@ class Fastboost(BaseModel):
type: Literal["fastboost"] = "fastboost"


class Multirel(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Multirel(BaseModel, frozen=True):
aggregation: AbstractSet[MultirelAggregations]
allow_sets: bool
delta_t: float
Expand All @@ -75,9 +69,7 @@ class Multirel(BaseModel):
type: Literal["multirel"] = "multirel"


class Relboost(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Relboost(BaseModel, frozen=True):
allow_null_weights: bool
delta_t: float
gamma: float
Expand All @@ -98,9 +90,7 @@ class Relboost(BaseModel):
type: Literal["relboost"] = "relboost"


class RelMT(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class RelMT(BaseModel, frozen=True):
allow_avg: bool
delta_t: float
gamma: float
Expand Down
7 changes: 2 additions & 5 deletions src/getml_io/getml/features.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
from collections.abc import Mapping
from typing import ClassVar

from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel


class Feature(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Feature(BaseModel, frozen=True):
name: str
index: int
target: str
Expand Down
28 changes: 8 additions & 20 deletions src/getml_io/getml/predictors.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
from __future__ import annotations

from typing import Annotated, ClassVar, Literal
from typing import Annotated, Literal

from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, Field


class LinearRegression(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class LinearRegression(BaseModel, frozen=True):
learning_rate: float
reg_lambda: float
type: Literal["linear_regression"] = "linear_regression"


class LogisticRegression(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class LogisticRegression(BaseModel, frozen=True):
learning_rate: float
reg_lambda: float
type: Literal["logistic_regression"] = "logistic_regression"


class ScaleGBMClassifier(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class ScaleGBMClassifier(BaseModel, frozen=True):
colsample_bylevel: float
colsample_bytree: float
early_stopping_rounds: int
Expand All @@ -41,9 +35,7 @@ class ScaleGBMClassifier(BaseModel):
type: Literal["scale_gbm_classifier"] = "scale_gbm_classifier"


class ScaleGBMRegressor(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class ScaleGBMRegressor(BaseModel, frozen=True):
colsample_bylevel: float
colsample_bytree: float
early_stopping_rounds: int
Expand All @@ -61,9 +53,7 @@ class ScaleGBMRegressor(BaseModel):
type: Literal["scale_gbm_regressor"] = "scale_gbm_regressor"


class XGBoostClassifier(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class XGBoostClassifier(BaseModel, frozen=True):
booster: str
colsample_bylevel: float
colsample_bytree: float
Expand All @@ -90,9 +80,7 @@ class XGBoostClassifier(BaseModel):
type: Literal["xgboost_classifier"] = "xgboost_classifier"


class XGBoostRegressor(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class XGBoostRegressor(BaseModel, frozen=True):
booster: str
colsample_bylevel: float
colsample_bytree: float
Expand Down
32 changes: 9 additions & 23 deletions src/getml_io/getml/preprocessors.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,35 @@
from __future__ import annotations

from collections.abc import Set as AbstractSet
from typing import Annotated, ClassVar, Literal
from typing import Annotated, Literal

from getml.feature_learning.aggregations.types import MappingAggregations
from pydantic import BaseModel, ConfigDict, Field
from pydantic import BaseModel, Field


class CategoryTrimmer(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class CategoryTrimmer(BaseModel, frozen=True):
max_num_categories: int
min_freq: int
type: Literal["category_trimmer"] = "category_trimmer"


class EmailDomain(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class EmailDomain(BaseModel, frozen=True):
type: Literal["email_domain"] = "email_domain"


class Imputation(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Imputation(BaseModel, frozen=True):
add_dummies: bool
type: Literal["imputation"] = "imputation"


class Mapping(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Mapping(BaseModel, frozen=True):
aggregation: AbstractSet[MappingAggregations]
min_freq: int
multithreading: bool
type: Literal["mapping"] = "mapping"


class Seasonal(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Seasonal(BaseModel, frozen=True):
disable_year: bool
disable_month: bool
disable_weekday: bool
Expand All @@ -48,18 +38,14 @@ class Seasonal(BaseModel):
type: Literal["seasonal"] = "seasonal"


class Substring(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Substring(BaseModel, frozen=True):
begin: int
length: int
unit: str
type: Literal["substring"] = "substring"


class TextFieldSplitter(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class TextFieldSplitter(BaseModel, frozen=True):
type: Literal["text_field_splitter"] = "text_field_splitter"


Expand Down
10 changes: 2 additions & 8 deletions src/getml_io/getml/project.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging
from collections.abc import Generator
from contextlib import contextmanager
from typing import ClassVar

from getml.data import Container
from getml.pipeline import Pipeline
from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel

from getml_io.getml.exception import (
PipelineNotFoundError,
Expand All @@ -25,12 +24,7 @@
logger: logging.Logger = logging.getLogger(__name__)


class Project(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(
arbitrary_types_allowed=True,
frozen=True,
)

class Project(BaseModel, frozen=True, arbitrary_types_allowed=True):
name: str
pipeline: Pipeline
container: Container
Expand Down
8 changes: 2 additions & 6 deletions src/getml_io/getml/project_information.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from typing import ClassVar
from pydantic import BaseModel

from pydantic import BaseModel, ConfigDict


class ProjectInformation(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class ProjectInformation(BaseModel, frozen=True):
project_name: str
pipeline_id: str
container_id: str
7 changes: 2 additions & 5 deletions src/getml_io/getml/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from collections.abc import Sequence
from enum import Enum
from typing import ClassVar

from getml.data import roles
from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel


class Role(str, Enum):
Expand All @@ -19,9 +18,7 @@ class Role(str, Enum):
UNUSED_STRING = roles.unused_string


class Roles(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class Roles(BaseModel, frozen=True):
categorical: Sequence[str]
join_key: Sequence[str]
numerical: Sequence[str]
Expand Down
6 changes: 3 additions & 3 deletions src/getml_io/getml/scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
from pydantic import BaseModel, Field


class _Score(BaseModel):
class _Score(BaseModel, frozen=True):
date_time: datetime
set_used: str
target: str


class ClassificationScore(_Score):
class ClassificationScore(_Score, frozen=True):
accuracy: float
auc: float
cross_entropy: float
type: Literal["classification"] = "classification"


class RegressionScore(_Score):
class RegressionScore(_Score, frozen=True):
mae: float
rmse: float
rsquared: float
Expand Down
8 changes: 2 additions & 6 deletions src/getml_io/metadata/container_information.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from __future__ import annotations

from typing import ClassVar

from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel

from getml_io.metadata.dataframe_information import (
DataFrameInformation,
DataFrameInformationByName,
)


class ContainerInformation(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class ContainerInformation(BaseModel, frozen=True):
id: str
population: DataFrameInformation | None
peripheral: DataFrameInformationByName
Expand Down
7 changes: 2 additions & 5 deletions src/getml_io/metadata/data_model_information.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from __future__ import annotations

from collections.abc import Mapping, Sequence
from typing import ClassVar

from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel

from getml_io.metadata.placeholder_information import PlaceholderInformation


class DataModelInformation(BaseModel):
model_config: ClassVar[ConfigDict] = ConfigDict(frozen=True)

class DataModelInformation(BaseModel, frozen=True):
population: PlaceholderInformation
peripheral: Mapping[str, Sequence[PlaceholderInformation]]
Loading