Skip to content

Commit

Permalink
Merge pull request #22 from demml/run-bug
Browse files Browse the repository at this point in the history
fix: explicit kwargs in run
  • Loading branch information
thorrester authored Jul 11, 2024
2 parents 0d605d4 + def2770 commit 231bcfd
Show file tree
Hide file tree
Showing 8 changed files with 695 additions and 622 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- run : |

- name: Build and tests
run : |
rm -rf /opt/hostedtoolcache/CodeQL
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
rm -rf /opt/hostedtoolcache/Ruby
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- run : |
- name: Run tests
run : |
rm -rf /opt/hostedtoolcache/CodeQL
rm -rf /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
rm -rf /opt/hostedtoolcache/Ruby
Expand Down
22 changes: 16 additions & 6 deletions opsml/app/routes/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
from typing import Any, Dict, List, Optional, Tuple, Union

from fastapi import File, Form, UploadFile
from pydantic import BaseModel, Field, field_serializer, model_validator
from pydantic import (
BaseModel,
Field,
FieldSerializationInfo,
field_serializer,
model_validator,
)

from opsml.cards.audit import AuditSections
from opsml.model.challenger import BattleReport
Expand Down Expand Up @@ -273,11 +279,15 @@ class HardwareMetricRecord(BaseModel):
metrics: HardwareMetrics

# serialize datetime
@field_serializer("created_at")
def serialize_created_at(self, value: Optional[datetime.datetime] = None) -> Optional[str]:
if value is not None:
return value.isoformat()
return value
@field_serializer("created_at", mode="plain")
def serialize_created_at(
self,
created_at: Optional[datetime.datetime],
_info: FieldSerializationInfo,
) -> Optional[str]:
if created_at is not None:
return created_at.isoformat()
return created_at


class HardwareMetricscPut(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion opsml/cards/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def log_metrics(self, metrics: Dict[str, Union[float, int]], step: Optional[int]
"""

for key, value in metrics.items():
self.log_metric(key, value, step)
self.log_metric(key=key, value=value, step=step)

def log_artifact_from_file(
self,
Expand Down
15 changes: 12 additions & 3 deletions opsml/data/interfaces/custom_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
from typing import Any, Dict, Iterator, List, Optional, Union

import pyarrow as pa
from pydantic import BaseModel, field_serializer, model_validator
from pydantic import (
BaseModel,
FieldSerializationInfo,
field_serializer,
model_validator,
)

from opsml.helpers.logging import ArtifactLogger
from opsml.types import CommonKwargs, Description, Suffix
Expand Down Expand Up @@ -177,8 +182,12 @@ class Dataset(BaseModel):
splits: Dict[Optional[str], Metadata] = {}
description: Description = Description()

@field_serializer("data_dir", return_type=str)
def serialize_data_dir(self, data_dir: Path, _info: Any) -> str:
@field_serializer("data_dir", return_type=str, mode="plain")
def serialize_data_dir(
self,
data_dir: Path,
_info: FieldSerializationInfo,
) -> str:
return data_dir.as_posix()

def split_data(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion opsml/data/splitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def trim_whitespace(cls, value: str) -> str:

return value

@field_serializer("column_value")
@field_serializer("column_value", mode="plain")
def serialize_column_value(
self,
column_value: Optional[Union[str, float, int, pd.Timestamp]],
Expand Down
1,267 changes: 659 additions & 608 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Source = "https://github.com/demml/opsml"

[tool.poetry]
name = "opsml"
version = "2.3.0"
version = "2.3.1"
readme = "README.md"
description = "Python MLOPs quality control tooling for your production ML workflows"
authors = [
Expand Down

0 comments on commit 231bcfd

Please sign in to comment.