Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resovles breaking changes introduced by pydantic 2.0.3 (fixes #66) #68

Merged
merged 1 commit into from
Jul 20, 2023
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
4 changes: 2 additions & 2 deletions hugie/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def modify(

if overwrite:
try:
srsly.write_json(path, config.dict())
srsly.write_json(path, config.model_dump())
typer.secho(f"Updated config at {path}", fg=typer.colors.GREEN)
except Exception:
typer.secho(f"Failed to update config at {path}", fg=typer.colors.RED)

else:
typer.secho(srsly.json_dumps(config.dict()), fg=typer.colors.YELLOW)
typer.secho(srsly.json_dumps(config.model_dump()), fg=typer.colors.YELLOW)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions hugie/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def create(
data (str): Path to JSON data to create the endpoint
"""

data = InferenceEndpointConfig.from_json(data).dict()
data = InferenceEndpointConfig.from_json(data).model_dump()

try:
response = requests.post(settings.endpoint_url, headers=headers, json=data)
Expand Down Expand Up @@ -126,7 +126,7 @@ def update(
"""
Update an endpoint
"""
data = InferenceEndpointConfig.from_json(data).dict()
data = InferenceEndpointConfig.from_json(data).model_dump()

try:
response = requests.put(
Expand Down
6 changes: 4 additions & 2 deletions hugie/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from pydantic import BaseModel, BaseSettings
from pydantic import BaseModel
from pydantic_settings import BaseSettings
from typing import Optional

from hugie.utils import load_json

Expand Down Expand Up @@ -35,7 +37,7 @@ class InferenceEndpointConfig(BaseSettings):
Config for the inference endpoint
"""

accountId: str = None
accountId: Optional[str] = None
type: str = None
compute: ComputeModel = ComputeModel()
model: ModelModel = ModelModel()
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ install_requires =
requests
pydantic
srsly
pydantic-settings
python_requires = >= 3.6


Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def data_path(tmp_path):

def test_inference_endpoint_config_serialization(data_path):
config = InferenceEndpointConfig.from_json(data_path)
config = config.dict()
config = config.model_dump()
assert isinstance(config, dict)
assert config["compute"]["instanceSize"] == "small"
assert config["model"]["framework"] == "custom"
Expand Down