Skip to content

Commit

Permalink
fix testing issues introduced by mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
blsmxiu47 committed Oct 28, 2024
1 parent 0108d3f commit 9f9a94f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
15 changes: 6 additions & 9 deletions src/onemod/stage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

from pandas import DataFrame
from pplkit.data.interface import DataInterface
from pydantic import BaseModel, ConfigDict, Field, computed_field, validate_call
from pydantic import BaseModel, ConfigDict, Field, validate_call

import onemod.stage as onemod_stages
from onemod.config import ModelConfig, StageConfig
from onemod.dtypes import Data
from onemod.io import Input, Output
from onemod.utils.decorators import computed_property
from onemod.utils.parameters import create_params, get_params
from onemod.utils.subsets import create_subsets, get_subset
from onemod.validation import ValidationErrorCollector, handle_error
Expand Down Expand Up @@ -91,8 +92,7 @@ def set_dataif(self, config_path: Path | str) -> None:
if not (directory / self.name).exists():
(directory / self.name).mkdir()

@property
@computed_field
@computed_property
def module(self) -> Path | None:
if self._module is None and not hasattr(
onemod_stages, self.type
Expand All @@ -107,8 +107,7 @@ def module(self) -> Path | None:
def skip(self) -> set[str]:
return self._skip

@property
@computed_field
@computed_property
def input(self) -> Input | None:
if self._input is None:
self._input = Input(
Expand All @@ -132,8 +131,7 @@ def dependencies(self) -> set[str]:
return set()
return self.input.dependencies

@property
@computed_field
@computed_property
def type(self) -> str:
return type(self).__name__

Expand Down Expand Up @@ -348,8 +346,7 @@ class ModelStage(Stage, ABC):
_required_input: set[str] = set() # data required for groupby
_collect_after: set[str] = set() # defined by class

@property
@computed_field
@computed_property
def crossby(self) -> set[str] | None:
return self._crossby

Expand Down
6 changes: 6 additions & 0 deletions src/onemod/utils/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pydantic import computed_field


def computed_property(func):
"""Combines @computed_field and @property."""
return computed_field(property(func))
4 changes: 2 additions & 2 deletions tests/integration/test_integration_stage_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_stage_model(stage_1, stage_2):
"config": {},
"input_validation": {},
"output_validation": {},
"module": __file__,
"module": Path(__file__),
"input": {
"data": "/path/to/data.parquet",
"covariates": "/path/to/covariates.csv",
Expand All @@ -128,7 +128,7 @@ def test_stage_model(stage_1, stage_2):
"config": {},
"input_validation": {},
"output_validation": {},
"module": __file__,
"module": Path(__file__),
"input": {
"data": {
"stage": "stage_1",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_integration_stage_io_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def stage_1_model_expected(example_base_dir):
return {
"name": "stage_1",
"type": "DummyStage",
"module": __file__,
"module": Path(__file__),
"config": {},
"input_validation": {
"covariates": {
Expand Down Expand Up @@ -222,7 +222,7 @@ def stage_2_model_expected(example_base_dir):
"name": "stage_2",
"type": "DummyStage",
"config": {},
"module": __file__,
"module": Path(__file__),
"input_validation": {
"data": {
"stage": "stage_1",
Expand Down

0 comments on commit 9f9a94f

Please sign in to comment.