Skip to content

Commit

Permalink
Pydantic Fix: Change deprecated function (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominastorm authored Mar 11, 2024
1 parent abb79a9 commit 6107e58
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion uptrain/framework/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def serialize(self, fpath: str | None = None):
if fpath is None:
fpath = os.path.join(self.logs_folder, "settings.json")
with open(fpath, "w") as f:
jsondump(self.dict(), f)
jsondump(self.model_dump(), f)

@classmethod
def deserialize(cls, fpath: str):
Expand Down
8 changes: 4 additions & 4 deletions uptrain/framework/evalllm.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def evaluate(
)

if isinstance(m, ParametricEval):
dictm = m.dict()
dictm = m.model_dump()
dictm.update({"scenario_description": this_scenario_description})
ser_checks.append({"check_name": m.__class__.__name__, **dictm})
elif isinstance(m, Evals):
Expand Down Expand Up @@ -323,7 +323,7 @@ def evaluate(
"data": results,
"checks": checks,
"metadata": metadata,
"schema_dict": schema.dict(),
"schema_dict": schema.model_dump(),
"project": project_name,
},
)
Expand All @@ -347,8 +347,8 @@ def evaluate_on_server(self, data, ser_checks, schema):
data=data[i : i + BATCH_SIZE],
checks=ser_checks,
metadata={
"schema": schema.dict(),
"uptrain_settings": self.settings.dict(),
"schema": schema.model_dump(),
"uptrain_settings": self.settings.model_dump(),
},
)
break
Expand Down
18 changes: 9 additions & 9 deletions uptrain/framework/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def add_checkset(self, name: str, checkset: CheckSet, settings: Settings):
url = f"{self.base_url}/checkset"
response = self.client.post(
url,
json={"name": name, "config": checkset.dict(), "settings": settings.dict()},
json={"name": name, "config": checkset.dict(), "settings": settings.model_dump()},
)
return raise_or_return(response)

Expand Down Expand Up @@ -210,7 +210,7 @@ def add_experiment(
json={
"name": name,
"config": modified_checkset.dict(),
"settings": settings.dict(),
"settings": settings.model_dump(),
},
)
return raise_or_return(response)
Expand Down Expand Up @@ -422,10 +422,10 @@ def evaluate(
results = []

if params is not None:
params["uptrain_settings"] = self.settings.dict()
params["uptrain_settings"] = self.settings.model_dump()
else:
params = {}
params["uptrain_settings"] = self.settings.dict()
params["uptrain_settings"] = self.settings.model_dump()

NUM_TRIES = 3
for i in range(0, len(full_dataset), 100):
Expand Down Expand Up @@ -528,9 +528,9 @@ def perform_root_cause_analysis(
"rca_templates": ser_templates,
"metadata": {
"project": project_name,
"schema": schema.dict(),
"schema": schema.model_dump(),
**metadata,
"uptrain_settings": self.settings.dict(),
"uptrain_settings": self.settings.model_dump(),
},
},
)
Expand Down Expand Up @@ -645,7 +645,7 @@ def log_and_evaluate(
req_attrs.update([schema.question])

if isinstance(m, ParametricEval):
dictm = m.dict()
dictm = m.model_dump()
dictm.update({"scenario_description": scenario_description})
ser_checks.append({"check_name": m.__class__.__name__, **dictm})
elif isinstance(m, Evals):
Expand Down Expand Up @@ -676,9 +676,9 @@ def log_and_evaluate(
"checks": ser_checks,
"metadata": {
"project": project_name,
"schema": schema.dict(),
"schema": schema.model_dump(),
**metadata,
"uptrain_settings": self.settings.dict(),
"uptrain_settings": self.settings.model_dump(),
},
},
)
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def _check_params(cls, values):

def setup(self):
if self.algorithm == "DDM":
self._algo_obj = drift.binary.DDM(**self.params.dict()) # type: ignore
self._algo_obj = drift.binary.DDM(**self.params.model_dump()) # type: ignore
elif self.algorithm == "ADWIN":
self._algo_obj = drift.ADWIN(**self.params.dict()) # type: ignore
self._algo_obj = drift.ADWIN(**self.params.model_dump()) # type: ignore
self._counter = 0
self._avg_accuracy = 0.0
self._cuml_accuracy = 0.0
Expand Down
2 changes: 1 addition & 1 deletion uptrain/utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def to_py_types(obj: t.Any) -> t.Any:
"params": obj.dict(include=set(obj.__fields__)),
}
elif isinstance(obj, BaseModel):
return obj.dict()
return obj.model_dump()

# for numpy types
if isinstance(obj, np.integer):
Expand Down

0 comments on commit 6107e58

Please sign in to comment.