Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonmeso committed Feb 27, 2024
1 parent 0f0be56 commit b07243d
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 41 deletions.
14 changes: 7 additions & 7 deletions giza/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def create(
]
),
headers=headers,
params=deployment_create.dict(),
params=deployment_create.model_dump(),
files={"sierra": f} if f is not None else None,
)
self._echo_debug(str(response))
Expand Down Expand Up @@ -826,7 +826,7 @@ def create(self, model_create: ModelCreate) -> Model:
response = self.session.post(
f"{self.url}/{self.MODELS_ENDPOINT}",
headers=headers,
json=model_create.dict(),
json=model_create.model_dump(),
)
self._echo_debug(str(response))

Expand All @@ -852,7 +852,7 @@ def update(self, model_id: int, model_update: ModelUpdate) -> Model:
response = self.session.put(
f"{self.url}/{self.MODELS_ENDPOINT}/{model_id}",
headers=headers,
json=model_update.dict(),
json=model_update.model_dump(),
)
self._echo_debug(str(response))

Expand Down Expand Up @@ -922,7 +922,7 @@ def create(
response = self.session.post(
f"{self.url}/{self.JOBS_ENDPOINT}",
headers=headers,
params=job_create.dict(),
params=job_create.model_dump(),
files=files,
)
self._echo_debug(str(response))
Expand Down Expand Up @@ -1027,7 +1027,7 @@ def create(
]
),
headers=headers,
params=job_create.dict(),
params=job_create.model_dump(),
files={"file": f},
)
self._echo_debug(str(response))
Expand Down Expand Up @@ -1279,7 +1279,7 @@ def create(
response = self.session.post(
f"{self._get_version_url(model_id)}",
headers=headers,
json=version_create.dict(),
json=version_create.model_dump(),
params={"filename": filename} if filename else None,
)
self._echo_debug(str(response))
Expand Down Expand Up @@ -1442,7 +1442,7 @@ def update(
response = self.session.put(
f"{self._get_version_url(model_id)}/{version_id}",
headers=headers,
json=version_update.dict(),
json=version_update.model_dump(),
)
self._echo_debug(str(response))

Expand Down
8 changes: 4 additions & 4 deletions giza/commands/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def list(
if debug:
raise e
sys.exit(1)
print_json(deployments.json())
print_json(deployments.model_dump_json())


# giza/commands/deployments.py
Expand Down Expand Up @@ -149,7 +149,7 @@ def get(
if debug:
raise e
sys.exit(1)
print_json(deployment.json())
print_json(deployment.model_dump_json())


@app.command(
Expand Down Expand Up @@ -194,7 +194,7 @@ def list_proofs(
if debug:
raise e
sys.exit(1)
print_json(proofs.json(exclude_unset=True))
print_json(proofs.model_dump_json(exclude_unset=True))


@app.command(
Expand Down Expand Up @@ -242,7 +242,7 @@ def get_proof(
if debug:
raise e
sys.exit(1)
print_json(proof.json(exclude_unset=True))
print_json(proof.model_dump_json(exclude_unset=True))


@app.command(
Expand Down
6 changes: 3 additions & 3 deletions giza/commands/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get(
if debug:
raise e
sys.exit(1)
print_json(model.json())
print_json(model.model_dump_json())


@app.command(
Expand Down Expand Up @@ -116,7 +116,7 @@ def list(
if debug:
raise e
sys.exit(1)
print_json(models.json())
print_json(models.model_dump_json())


@app.command(
Expand Down Expand Up @@ -174,4 +174,4 @@ def create(
if debug:
raise e
sys.exit(1)
print_json(model.json())
print_json(model.model_dump_json())
2 changes: 1 addition & 1 deletion giza/commands/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def me(debug: Optional[bool] = DEBUG_OPTION) -> None:
client = UsersClient(API_HOST, debug=debug)
user = client.me()

print_json(user.json())
print_json(user.model_dump_json())


@app.command(
Expand Down
6 changes: 3 additions & 3 deletions giza/commands/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get(
with ExceptionHandler(debug=debug):
client = VersionsClient(API_HOST)
version: Version = client.get(model_id, version_id)
print_json(version.json())
print_json(version.model_dump_json())


def transpile(
Expand Down Expand Up @@ -180,7 +180,7 @@ def update(
zip_path = zip_folder(model_path, tmp_dir)
version = client.upload_cairo(model_id, version_id, zip_path)
echo("Version updated ✅ ")
print_json(version.json())
print_json(version.model_dump_json())


@app.command(
Expand All @@ -201,7 +201,7 @@ def list(
with ExceptionHandler(debug=debug):
client = VersionsClient(API_HOST)
versions: VersionList = client.list(model_id)
print_json(versions.json())
print_json(versions.model_dump_json())


@app.command(
Expand Down
2 changes: 1 addition & 1 deletion giza/commands/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get(
echo.error("⛔️Please delete the workspace and create a new one⛔️")
else:
echo.info(f"✅ Workspace URL: {workspace.url} ✅")
print_json(workspace.json())
print_json(workspace.model_dump_json())


@app.command(
Expand Down
2 changes: 1 addition & 1 deletion giza/frameworks/cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def deploy(
client = DeploymentsClient(API_HOST)

deployments_list: DeploymentsList = client.list(model_id, version_id)
deployments: dict = json.loads(deployments_list.json())
deployments: dict = json.loads(deployments_list.model_dump_json())

if len(deployments) > 0:
echo.info(
Expand Down
2 changes: 1 addition & 1 deletion giza/frameworks/ezkl.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def deploy(
client = DeploymentsClient(API_HOST)

deployments_list: DeploymentsList = client.list(model_id, version_id)
deployments: dict = json.loads(deployments_list.json())
deployments: dict = json.loads(deployments_list.model_dump_json())

if len(deployments) > 0:
echo.info(
Expand Down
5 changes: 5 additions & 0 deletions giza/schemas/deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class DeploymentCreate(BaseModel):
service_name: Optional[str] = None
framework: Framework = Framework.CAIRO

model_config = ConfigDict(from_attributes=True)
model_config["protected_namespaces"] = ()


class Deployment(BaseModel):
id: int
Expand All @@ -24,7 +27,9 @@ class Deployment(BaseModel):
service_name: Optional[str] = None
model_id: Optional[int] = None
version_id: Optional[int] = None

model_config = ConfigDict(from_attributes=True)
model_config["protected_namespaces"] = ()


class DeploymentsList(RootModel):
Expand Down
5 changes: 4 additions & 1 deletion giza/schemas/jobs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from typing import Optional

from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict

from giza.utils.enums import Framework, JobKind, JobSize, JobStatus

Expand All @@ -23,3 +23,6 @@ class JobCreate(BaseModel):
model_id: Optional[int] = None
version_id: Optional[int] = None
proof_id: Optional[int] = None

model_config = ConfigDict(from_attributes=True)
model_config["protected_namespaces"] = ()
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ types-python-jose = "^3.3.4.8"
types-requests = "^2.31.0.2"
cookiecutter = "^2.5.0"
semver = "^3.0.2"
pydantic = "^2.6.1"
pydantic = "^2"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.3.3"
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def test_versions_update_successful():
last_update="2021-08-31T15:00:00.000000",
framework=Framework.CAIRO,
)
updated_version = version.copy()
updated_version = version.model_copy()
updated_version.status = VersionStatus.COMPLETED

with patch.object(VersionsClient, "get", return_value=version), patch.object(
Expand Down
18 changes: 9 additions & 9 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def test_versions_client_get(tmpdir):
last_update="2021-08-31T15:00:00.000000",
framework=Framework.CAIRO,
)
response = ResponseStub(version.dict(), 200)
response = ResponseStub(version.model_dump(), 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -276,7 +276,7 @@ def test_versions_client_list(tmpdir):
framework=Framework.CAIRO,
last_update="2021-08-31T15:00:00.000000",
)
response = ResponseStub([version.dict()], 200)
response = ResponseStub([version.model_dump()], 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -299,7 +299,7 @@ def test_versions_client_create(tmpdir):
framework=Framework.CAIRO,
)
response = ResponseStub(
version.dict(), 201, headers={MODEL_URL_HEADER.lower(): "url"}
version.model_dump(), 201, headers={MODEL_URL_HEADER.lower(): "url"}
)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.post", return_value=response
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_versions_client_get_non_existent(tmpdir):
def test_jobs_client_get(tmpdir):
job_id = 1
job = Job(id=1, job_name="job", size=JobSize.S, status=JobStatus.STARTING)
response = ResponseStub(job.dict(), 200)
response = ResponseStub(job.model_dump(), 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -346,7 +346,7 @@ def test_jobs_client_get(tmpdir):

def test_jobs_client_list(tmpdir):
job = Job(id=1, job_name="job", size=JobSize.S, status=JobStatus.STARTING)
response = ResponseStub([job.dict()], 200)
response = ResponseStub([job.model_dump()], 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -359,7 +359,7 @@ def test_jobs_client_list(tmpdir):

def test_jobs_client_create(tmpdir):
job = Job(id=1, job_name="job", size=JobSize.S, status=JobStatus.STARTING)
response = ResponseStub(job.dict(), 201)
response = ResponseStub(job.model_dump(), 201)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.post", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -381,7 +381,7 @@ def test_proof_client_get(tmpdir):
cairo_execution_time=100,
created_date=datetime.datetime.now(),
)
response = ResponseStub(proof.dict(), 200)
response = ResponseStub(proof.model_dump(), 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -401,7 +401,7 @@ def test_proof_client_get_by_job_id(tmpdir):
cairo_execution_time=100,
created_date=datetime.datetime.now(),
)
response = ResponseStub([proof.dict()], 200)
response = ResponseStub([proof.model_dump()], 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand All @@ -421,7 +421,7 @@ def test_proof_client_list(tmpdir):
cairo_execution_time=100,
created_date=datetime.datetime.now(),
)
response = ResponseStub([proof.dict()], 200)
response = ResponseStub([proof.model_dump()], 200)
with patch("pathlib.Path.home", return_value=tmpdir), patch(
"requests.Session.get", return_value=response
) as mock_request, patch("jose.jwt.decode"):
Expand Down

0 comments on commit b07243d

Please sign in to comment.