From e5e5e0745f05f561b131d45092a72207ad36518b Mon Sep 17 00:00:00 2001 From: Gonzalo Mellizo-Soto Date: Mon, 22 Apr 2024 13:08:08 +0200 Subject: [PATCH 1/5] Add verification client and update verify for verify and endpoints --- giza/client.py | 60 ++++++++++++++++++++++++++++++++ giza/commands/endpoints.py | 30 ++++++++++++++++ giza/commands/verify.py | 2 ++ giza/frameworks/cairo.py | 14 ++++++-- giza/schemas/verify.py | 8 +++++ tests/commands/test_endpoints.py | 22 ++++++++++++ 6 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 giza/schemas/verify.py diff --git a/giza/client.py b/giza/client.py index 66bc1ae..39947c3 100644 --- a/giza/client.py +++ b/giza/client.py @@ -20,6 +20,7 @@ from giza.schemas.models import Model, ModelCreate, ModelList, ModelUpdate from giza.schemas.proofs import Proof, ProofList from giza.schemas.token import TokenResponse +from giza.schemas.verify import VerifyResponse from giza.schemas.versions import Version, VersionCreate, VersionList, VersionUpdate from giza.schemas.workspaces import Workspace from giza.utils import echo @@ -691,6 +692,41 @@ def delete(self, endpoint_id: int) -> None: self._echo_debug(str(response)) response.raise_for_status() + @auth + def verify_proof( + self, endpoint_id: int, proof_id: Union[str, int] + ) -> VerifyResponse: + """ + Verify a proof. + + Args: + endpoint_id: Endpoint identifier + proof_id: Proof identifier + + Returns: + The verification response + """ + headers = copy.deepcopy(self.default_headers) + headers.update(self._get_auth_header()) + + response = self.session.post( + "/".join( + [ + self.url, + self.ENDPOINTS, + str(endpoint_id), + "proofs", + f"{proof_id}:verify", + ] + ), + headers=headers, + ) + + self._echo_debug(str(response)) + response.raise_for_status() + + return VerifyResponse(**response.json()) + # For downstream dependencies until they are updated DeploymentsClient = EndpointsClient @@ -1204,6 +1240,30 @@ def list(self) -> List[Proof]: return [Proof(**proof) for proof in response.json()] + @auth + def verify_proof(self, proof_id: int) -> VerifyResponse: + """ + Verify a proof. + + Args: + proof_id: Proof identifier + + Returns: + The verification response + """ + headers = copy.deepcopy(self.default_headers) + headers.update(self._get_auth_header()) + + response = self.session.post( + f"{self.url}/{self.PROOFS_ENDPOINT}/{proof_id}:verify", + headers=headers, + ) + + self._echo_debug(str(response)) + response.raise_for_status() + + return VerifyResponse(**response.json()) + class VersionsClient(ApiClient): """ diff --git a/giza/commands/endpoints.py b/giza/commands/endpoints.py index 3c6f7d5..398154b 100644 --- a/giza/commands/endpoints.py +++ b/giza/commands/endpoints.py @@ -369,3 +369,33 @@ def list_jobs( client = EndpointsClient(API_HOST) jobs = client.list_jobs(endpoint_id) print_json(jobs.json(exclude_unset=True)) + + +@app.command( + name="verify", + short_help="🔍 Verify a proof from an endpoint.", + help="""🔍 Verify a proof from an endpoint. + This command verifies a proof generated by a specific endpoint. + The verify information is printed in a json format for easy readability and further processing. + If the endpoint is not available, an error message is printed. + """, +) +def verify( + endpoint_id: int = typer.Option( + None, + "--deployment-id", + "-d", + "--endpoint-id", + "-e", + help="The ID of the endpoint", + ), + proof_id: str = typer.Option( + None, "--proof-id", "-p", help="The ID or request id of the proof" + ), + debug: Optional[bool] = DEBUG_OPTION, +) -> None: + echo(f"Verifying proof from endpoint {endpoint_id} ✅ ") + with ExceptionHandler(debug=debug): + client = EndpointsClient(API_HOST) + verification = client.verify_proof(endpoint_id, proof_id) + print_json(verification.json(exclude_unset=True)) diff --git a/giza/commands/verify.py b/giza/commands/verify.py index 0f11e76..6ac1eb1 100644 --- a/giza/commands/verify.py +++ b/giza/commands/verify.py @@ -13,6 +13,7 @@ def verify( model_id: Optional[int] = typer.Option(None, "--model-id", "-m"), version_id: Optional[int] = typer.Option(None, "--version-id", "-v"), proof_id: Optional[int] = typer.Option(None, "--proof-id", "-p"), + use_job: Optional[bool] = typer.Option(False, "--use-job"), proof: Optional[str] = typer.Option(None, "--proof", "-P"), size: JobSize = typer.Option(JobSize.S, "--size", "-s"), framework: Framework = typer.Option(Framework.CAIRO, "--framework", "-f"), @@ -26,6 +27,7 @@ def verify( size=size, debug=debug, proof=proof, + use_job=use_job, ) elif framework == Framework.EZKL: ezkl.verify( diff --git a/giza/frameworks/cairo.py b/giza/frameworks/cairo.py index 8db4732..c700e96 100644 --- a/giza/frameworks/cairo.py +++ b/giza/frameworks/cairo.py @@ -383,6 +383,7 @@ def verify( proof: Optional[str] = None, debug: Optional[bool] = False, size: JobSize = JobSize.S, + use_job: Optional[bool] = False, ): """ Create a verification job. @@ -390,8 +391,8 @@ def verify( The job size, model id, and version id can be optionally specified. """ echo = Echo() - if not model_id or not version_id: - if proof_id: + if use_job and (not model_id or not version_id): + if proof_id and use_job: echo.error("Model id and version id must be provided along with proof id.") sys.exit(1) echo.warning( @@ -403,7 +404,7 @@ def verify( try: job: Job client = JobsClient(API_HOST) - if proof_id: + if proof_id and use_job: job = client.create( JobCreate( size=size, @@ -415,6 +416,13 @@ def verify( ), None, ) + elif proof_id and not use_job: + echo("Verifying proof...") + proofs_client = ProofsClient(API_HOST) + verification_result = proofs_client.verify_proof(proof_id) + echo(f"Verification result: {verification_result.verification}") + echo(f"Verification time: {verification_result.verification_time}") + sys.exit(0) elif proof: with open(proof, "rb") as data: job = client.create( diff --git a/giza/schemas/verify.py b/giza/schemas/verify.py new file mode 100644 index 0000000..7fc412b --- /dev/null +++ b/giza/schemas/verify.py @@ -0,0 +1,8 @@ +from typing import Optional + +from pydantic import BaseModel + + +class VerifyResponse(BaseModel): + verification: Optional[bool] = None + verification_time: Optional[float] = None diff --git a/tests/commands/test_endpoints.py b/tests/commands/test_endpoints.py index 61a704a..4c0dd6c 100644 --- a/tests/commands/test_endpoints.py +++ b/tests/commands/test_endpoints.py @@ -5,6 +5,7 @@ from giza.commands.endpoints import EndpointsClient, cairo from giza.frameworks import ezkl from giza.schemas.endpoints import Endpoint, EndpointsList +from giza.schemas.verify import VerifyResponse from tests.conftest import invoke_cli_runner @@ -222,3 +223,24 @@ def test_get_deployment_http_error(): mock_deployment.assert_called_once() assert result.exit_code == 1 assert "Could not get endpoint" in result.stdout + + +def test_endpoints_verify(): + with patch.object( + EndpointsClient, + "verify_proof", + return_value=VerifyResponse(verification=True, verification_time=1.2), + ) as mock_verify: + result = invoke_cli_runner( + [ + "endpoints", + "verify", + "--deployment-id", + "1", + "--proof-id", + "1", + ], + ) + mock_verify.assert_called_once() + assert result.exit_code == 0 + assert ' "verification": true' in result.stdout From 239519a3d13f472d83f3fdea56b07e9894195072 Mon Sep 17 00:00:00 2001 From: Gonzalo Mellizo-Soto Date: Mon, 22 Apr 2024 13:24:39 +0200 Subject: [PATCH 2/5] Fix typing for decorated functions --- giza/client.py | 8 ++++---- giza/commands/endpoints.py | 2 +- giza/utils/decorators.py | 11 +++++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/giza/client.py b/giza/client.py index 39947c3..ce57c47 100644 --- a/giza/client.py +++ b/giza/client.py @@ -484,7 +484,7 @@ def create( return Endpoint(**response.json()) @auth - def list(self, params: Optional[Dict[str, str]] = None) -> EndpointsList: + def list(self, params: Optional[Dict[str, Any]] = None) -> EndpointsList: """ List endpoints. @@ -569,7 +569,7 @@ def list_proofs(self, endpoint_id: int) -> ProofList: return ProofList(root=[Proof(**proof) for proof in response.json()]) @auth - def get_proof(self, endpoint_id: int, proof_id: int) -> Proof: + def get_proof(self, endpoint_id: int, proof_id: Union[int, str]) -> Proof: """ Return information about a specific proof. `proof_if` is the identifier of the proof that can be a integer or the request id. @@ -599,7 +599,7 @@ def get_proof(self, endpoint_id: int, proof_id: int) -> Proof: return Proof(**response.json()) @auth - def download_proof(self, endpoint_id: int, proof_id: int) -> bytes: + def download_proof(self, endpoint_id: int, proof_id: Union[int, str]) -> bytes: """ Download a proof. @@ -1311,7 +1311,7 @@ def get(self, model_id: int, version_id: int) -> Version: return Version(**response.json()) @auth - def upload_cairo(self, model_id: int, version_id: int, file_path: str) -> str: + def upload_cairo(self, model_id: int, version_id: int, file_path: str) -> Version: """ Get the Cairo model URL. diff --git a/giza/commands/endpoints.py b/giza/commands/endpoints.py index 398154b..84d09bc 100644 --- a/giza/commands/endpoints.py +++ b/giza/commands/endpoints.py @@ -398,4 +398,4 @@ def verify( with ExceptionHandler(debug=debug): client = EndpointsClient(API_HOST) verification = client.verify_proof(endpoint_id, proof_id) - print_json(verification.json(exclude_unset=True)) + print_json(verification.model_dump_json(exclude_unset=True)) diff --git a/giza/utils/decorators.py b/giza/utils/decorators.py index 0bf837c..821f0fd 100644 --- a/giza/utils/decorators.py +++ b/giza/utils/decorators.py @@ -1,11 +1,14 @@ from functools import wraps -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Callable, ParamSpec, TypeVar if TYPE_CHECKING: from giza.client import ApiClient +P = ParamSpec("P") +R = TypeVar("R") -def auth(func: Callable): + +def auth(func: Callable[P, R]) -> Callable[P, R]: """ Check that we have the token and it is not expired before executing @@ -19,7 +22,7 @@ def auth(func: Callable): """ @wraps(func) - def wrapper(*args, **kwargs) -> Any: + def wrapper(*args: P.args, **kwargs: P.kwargs) -> R: """ Get the API client from the function and retrieve the token, check expiry. @@ -33,7 +36,7 @@ def wrapper(*args, **kwargs) -> Any: Returns: Any: result of the function """ - self_: ApiClient = args[0] + self_: ApiClient = args[0] # type: ignore self_.retrieve_token() self_.retrieve_api_key() From 99e4eaabffd1a21e1ca1eb90bc8e14b8a97d3dc3 Mon Sep 17 00:00:00 2001 From: Gonzalo Mellizo-Soto Date: Mon, 22 Apr 2024 13:38:08 +0200 Subject: [PATCH 3/5] Fix mypy errors --- giza/client.py | 18 ++++++++++-------- giza/commands/agents.py | 4 ++-- giza/frameworks/cairo.py | 4 ++-- giza/frameworks/ezkl.py | 3 +-- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/giza/client.py b/giza/client.py index ce57c47..5a3aa35 100644 --- a/giza/client.py +++ b/giza/client.py @@ -1,7 +1,7 @@ import copy import json import os -from io import BufferedReader +from io import BufferedReader, TextIOWrapper from pathlib import Path from typing import Any, BinaryIO, Dict, List, Optional, Tuple, Union from urllib.parse import urlparse @@ -451,7 +451,7 @@ def create( model_id: int, version_id: int, endpoint_create: EndpointCreate, - f: BufferedReader, + f: Optional[BufferedReader] = None, ) -> Endpoint: """ Create a new deployment. @@ -962,8 +962,8 @@ def get(self, job_id: int, params: Optional[dict[str, str]] = None) -> Job: def create( self, job_create: JobCreate, - trace: BufferedReader, - memory: Optional[BufferedReader] = None, + trace: Optional[Union[BufferedReader, TextIOWrapper]] = None, + memory: Optional[Union[BufferedReader, TextIOWrapper]] = None, ) -> Job: """ Create a new job. @@ -981,8 +981,10 @@ def create( headers = copy.deepcopy(self.default_headers) headers.update(self._get_auth_header()) - files = {"trace_or_proof": trace} if trace is not None else None - if trace is not None and memory is not None: + files: Optional[Dict[str, Any]] = ( + {"trace_or_proof": trace} if trace is not None else None + ) + if trace is not None and memory is not None and files is not None: files["memory"] = memory response = self.session.post( f"{self.url}/{self.JOBS_ENDPOINT}", @@ -1063,7 +1065,7 @@ def get(self, model_id: int, version_id: int, job_id: int) -> Job: @auth def create( - self, model_id: int, version_id: int, job_create: JobCreate, f: BufferedReader + self, model_id: int, version_id: int, job_create: JobCreate, f: TextIOWrapper ) -> Job: """ Create a new job. @@ -1655,7 +1657,7 @@ def create( return Agent(**response.json()) @auth - def list(self, params: Optional[Dict[str, str]] = None) -> AgentList: + def list(self, params: Optional[Dict[str, Any]] = None) -> AgentList: """ List endpoints. diff --git a/giza/commands/agents.py b/giza/commands/agents.py index 0cfdc58..97be480 100644 --- a/giza/commands/agents.py +++ b/giza/commands/agents.py @@ -27,13 +27,13 @@ """, ) def create( - model_id: int = typer.Option( + model_id: Optional[int] = typer.Option( None, "--model-id", "-m", help="The ID of the model used to create the agent", ), - version_id: int = typer.Option( + version_id: Optional[int] = typer.Option( None, "--version-id", "-v", diff --git a/giza/frameworks/cairo.py b/giza/frameworks/cairo.py index c700e96..d7631e4 100644 --- a/giza/frameworks/cairo.py +++ b/giza/frameworks/cairo.py @@ -22,7 +22,7 @@ VersionsClient, ) from giza.options import DEBUG_OPTION -from giza.schemas.endpoints import EndpointCreate, EndpointsList +from giza.schemas.endpoints import Endpoint, EndpointCreate, EndpointsList from giza.schemas.jobs import Job, JobCreate from giza.schemas.models import ModelCreate from giza.schemas.proofs import Proof @@ -125,7 +125,7 @@ def deploy( data: Optional[str] = None, size: ServiceSize = ServiceSize.S, debug: Optional[bool] = DEBUG_OPTION, -) -> str: +) -> Endpoint: """ Command to deploy a specific version of a model. This will create an endpoint for the specified version and check the status, once it finishes if COMPLETED the endpoint is ready to be used. diff --git a/giza/frameworks/ezkl.py b/giza/frameworks/ezkl.py index 100e2cd..3760d56 100644 --- a/giza/frameworks/ezkl.py +++ b/giza/frameworks/ezkl.py @@ -324,7 +324,7 @@ def deploy( version_id: int, size: ServiceSize = ServiceSize.S, debug: Optional[bool] = DEBUG_OPTION, -) -> str: +) -> None: """ Command to deploy a specific version of a model. This will create a endpoint for the specified version and check the status, once it finishes if COMPLETED the endpoint is ready to be used. @@ -391,4 +391,3 @@ def deploy( echo("Endpoint is successful ✅") echo(f"Endpoint created with id -> {endpoint.id} ✅") echo(f"Endpoint created with endpoint URL: {endpoint.uri} 🎉") - return endpoint From 5da4ed198c974010baf152c5c88a456718444319 Mon Sep 17 00:00:00 2001 From: Gonzalo Mellizo-Soto Date: Mon, 22 Apr 2024 13:57:34 +0200 Subject: [PATCH 4/5] Update docs --- docs/frameworks/cairo/deploy.md | 13 ++ docs/frameworks/cairo/verify.md | 12 +- docs/reference/api/README.md | 1 + docs/reference/api/client.md | 301 +++++++++++++++---------- docs/reference/api/commands.actions.md | 2 +- docs/reference/api/frameworks.cairo.md | 5 +- docs/reference/api/frameworks.ezkl.md | 2 +- docs/reference/api/utils.decorators.md | 4 +- giza/utils/echo.py | 4 +- 9 files changed, 217 insertions(+), 127 deletions(-) diff --git a/docs/frameworks/cairo/deploy.md b/docs/frameworks/cairo/deploy.md index 624c58f..97a7975 100644 --- a/docs/frameworks/cairo/deploy.md +++ b/docs/frameworks/cairo/deploy.md @@ -115,6 +115,19 @@ To list the proofs for an endpoint, we can use the `list-proofs` command availab ] ``` +## Verify a proof + +After successfully creating a proof for your Orion Cairo model, the next step is to verify its validity. Giza offers a verification method using the `verify` command alongside the `endpoint-id` and `proof-id`. + +```console +> giza endpoints verify --endpoint-id 1 --proof-id "b14bfbcf250b404192765d9be0811c9b" +[giza][2024-02-20 15:40:48.560] Verifying proof... +[giza][2024-02-20 15:40:49.288] Verification result: True +[giza][2024-02-20 15:40:49.288] Verification time: 2.363822541 +``` + +This way we can easily and quickly verify the proof generated for our model. + ## Download the proof We can download the proof using the `download-proof` command available for the endpoints: diff --git a/docs/frameworks/cairo/verify.md b/docs/frameworks/cairo/verify.md index 347bc51..eb7f368 100644 --- a/docs/frameworks/cairo/verify.md +++ b/docs/frameworks/cairo/verify.md @@ -10,16 +10,20 @@ To verify a proof by providing the `proof-id`, use the following command: giza verify --model-id 1 --version-id 1 --proof-id 1 --size S ``` -Upon successful submission, you will see a confirmation message indicating that the verification job has been created, along with its name and ID. Once the verification process is complete, a success message will confirm the validity of the proof: +Upon successful submission, you will see a confirmation message indicating that the verification procces has begun. Once the verification process is complete, a success message will confirm the validity of the proof: ``` -[giza][2023-12-04 19:43:37.686] Verification job created with name 'verify-cairo-20231204-32f44715' and id -> 1 ✅ -[giza][2023-12-04 19:45:18.683] Verification job is successful ✅ +[giza][2024-04-22 13:48:12.236] Verifying proof... +[giza][2024-04-22 13:48:14.985] Verification result: True +[giza][2024-04-22 13:48:14.985] Verification time: 2.363822541 +``` + +A `--use-remote` flag can be added to the command to verify the proof using a job. This flag is optional and its strongly discouraged as verification time is 10x slower than the default method. ``` ## Option 2: Verify by Providing the Proof Path -Alternatively, you can verify a proof by specifying the path to the proof file directly: +Alternatively, you can verify a proof by specifying the path to the proof file directly. This option uses by default the `--use-job` flag to verify the proof using a job. To verify a proof using the proof file path, use the following command: ``` giza verify --proof /path/to/the/proof --size S diff --git a/docs/reference/api/README.md b/docs/reference/api/README.md index 08a5576..3492011 100644 --- a/docs/reference/api/README.md +++ b/docs/reference/api/README.md @@ -76,6 +76,7 @@ - [`endpoints.list`](./commands.endpoints.md#function-list) - [`endpoints.list_jobs`](./commands.endpoints.md#function-list_jobs) - [`endpoints.list_proofs`](./commands.endpoints.md#function-list_proofs) +- [`endpoints.verify`](./commands.endpoints.md#function-verify) - [`models.create`](./commands.models.md#function-create): Command to create a model. Asks for the new model's information and validates the input, - [`models.get`](./commands.models.md#function-get): Command to create a user. Asks for the new users information and validates the input, - [`models.list`](./commands.models.md#function-list): Command to list all models. diff --git a/docs/reference/api/client.md b/docs/reference/api/client.md index 31aa326..4ac99f4 100644 --- a/docs/reference/api/client.md +++ b/docs/reference/api/client.md @@ -17,12 +17,12 @@ --- - + ## class `ApiClient` Implementation of the API client to interact with core-services - + ### method `__init__` @@ -46,7 +46,7 @@ __init__( --- - + ### method `retrieve_api_key` @@ -70,7 +70,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -103,12 +103,12 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ## class `UsersClient` Client to interact with `users` endpoint. - + ### method `__init__` @@ -132,7 +132,7 @@ __init__( --- - + ### method `create` @@ -156,7 +156,7 @@ Call the API to create a new user --- - + ### method `create_api_key` @@ -174,7 +174,7 @@ Call the API to create a new API key --- - + ### method `me` @@ -192,7 +192,7 @@ Retrieve information about the current user. Must have a valid token to perform --- - + ### method `request_reset_password_token` @@ -216,7 +216,7 @@ Sends a request to the server to generate a password reset token. The token is s --- - + ### method `resend_email` @@ -240,7 +240,7 @@ Resend the verification email to the user. --- - + ### method `reset_password` @@ -265,7 +265,7 @@ Resets the user's password using the provided token and new password. --- - + ### method `retrieve_api_key` @@ -289,7 +289,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -322,12 +322,12 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ## class `EndpointsClient` Client to interact with `endpoints` endpoint. - + ### method `__init__` @@ -351,7 +351,7 @@ __init__( --- - + ### method `create` @@ -360,7 +360,7 @@ create( model_id: int, version_id: int, endpoint_create: EndpointCreate, - f: BufferedReader + f: Optional[BufferedReader] = None ) → Endpoint ``` @@ -379,7 +379,7 @@ Create a new deployment. --- - + ### method `delete` @@ -397,12 +397,12 @@ Delete an endpoint. --- - + ### method `download_proof` ```python -download_proof(endpoint_id: int, proof_id: int) → bytes +download_proof(endpoint_id: int, proof_id: Union[int, str]) → bytes ``` Download a proof. @@ -420,7 +420,7 @@ Download a proof. --- - + ### method `get` @@ -443,12 +443,12 @@ Get a deployment. --- - + ### method `get_proof` ```python -get_proof(endpoint_id: int, proof_id: int) → Proof +get_proof(endpoint_id: int, proof_id: Union[int, str]) → Proof ``` Return information about a specific proof. `proof_if` is the identifier of the proof that can be a integer or the request id. @@ -460,12 +460,12 @@ Return information about a specific proof. `proof_if` is the identifier of the p --- - + ### method `list` ```python -list(params: Optional[Dict[str, str]] = None) → EndpointsList +list(params: Optional[Dict[str, Any]] = None) → EndpointsList ``` List endpoints. @@ -477,7 +477,7 @@ List endpoints. --- - + ### method `list_jobs` @@ -494,7 +494,7 @@ List proofs. --- - + ### method `list_proofs` @@ -511,7 +511,7 @@ List proofs. --- - + ### method `retrieve_api_key` @@ -535,7 +535,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -565,15 +565,39 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials - `Exception`: if token could not be retrieved in any way +--- + + + +### method `verify_proof` + +```python +verify_proof(endpoint_id: int, proof_id: Union[str, int]) → VerifyResponse +``` + +Verify a proof. + + + +**Args:** + + - `endpoint_id`: Endpoint identifier + - `proof_id`: Proof identifier + + + +**Returns:** + The verification response + --- - + ## class `EndpointsClient` Client to interact with `endpoints` endpoint. - + ### method `__init__` @@ -597,7 +621,7 @@ __init__( --- - + ### method `create` @@ -606,7 +630,7 @@ create( model_id: int, version_id: int, endpoint_create: EndpointCreate, - f: BufferedReader + f: Optional[BufferedReader] = None ) → Endpoint ``` @@ -625,7 +649,7 @@ Create a new deployment. --- - + ### method `delete` @@ -643,12 +667,12 @@ Delete an endpoint. --- - + ### method `download_proof` ```python -download_proof(endpoint_id: int, proof_id: int) → bytes +download_proof(endpoint_id: int, proof_id: Union[int, str]) → bytes ``` Download a proof. @@ -666,7 +690,7 @@ Download a proof. --- - + ### method `get` @@ -689,12 +713,12 @@ Get a deployment. --- - + ### method `get_proof` ```python -get_proof(endpoint_id: int, proof_id: int) → Proof +get_proof(endpoint_id: int, proof_id: Union[int, str]) → Proof ``` Return information about a specific proof. `proof_if` is the identifier of the proof that can be a integer or the request id. @@ -706,12 +730,12 @@ Return information about a specific proof. `proof_if` is the identifier of the p --- - + ### method `list` ```python -list(params: Optional[Dict[str, str]] = None) → EndpointsList +list(params: Optional[Dict[str, Any]] = None) → EndpointsList ``` List endpoints. @@ -723,7 +747,7 @@ List endpoints. --- - + ### method `list_jobs` @@ -740,7 +764,7 @@ List proofs. --- - + ### method `list_proofs` @@ -757,7 +781,7 @@ List proofs. --- - + ### method `retrieve_api_key` @@ -781,7 +805,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -811,15 +835,39 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials - `Exception`: if token could not be retrieved in any way +--- + + + +### method `verify_proof` + +```python +verify_proof(endpoint_id: int, proof_id: Union[str, int]) → VerifyResponse +``` + +Verify a proof. + + + +**Args:** + + - `endpoint_id`: Endpoint identifier + - `proof_id`: Proof identifier + + + +**Returns:** + The verification response + --- - + ## class `TranspileClient` Client to interact with `users` endpoint. - + ### method `__init__` @@ -843,7 +891,7 @@ __init__( --- - + ### method `retrieve_api_key` @@ -867,7 +915,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -899,7 +947,7 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ### method `transpile` @@ -923,7 +971,7 @@ Make a call to the API transpile endpoint with the model as a file. --- - + ### method `update_transpilation` @@ -952,12 +1000,12 @@ Make a call to the API transpile endpoint with the model as a file. --- - + ## class `ModelsClient` Client to interact with `models` endpoint. - + ### method `__init__` @@ -981,7 +1029,7 @@ __init__( --- - + ### method `create` @@ -1011,7 +1059,7 @@ Create a new model. --- - + ### method `get` @@ -1035,7 +1083,7 @@ Make a call to the API to retrieve model information. --- - + ### method `get_by_name` @@ -1059,7 +1107,7 @@ Make a call to the API to retrieve model information by its name. --- - + ### method `list` @@ -1076,7 +1124,7 @@ List all the models related to the user. --- - + ### method `retrieve_api_key` @@ -1100,7 +1148,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -1132,7 +1180,7 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ### method `update` @@ -1158,12 +1206,12 @@ Update a model. --- - + ## class `JobsClient` Client to interact with `jobs` endpoint. - + ### method `__init__` @@ -1187,15 +1235,15 @@ __init__( --- - + ### method `create` ```python create( job_create: JobCreate, - trace: BufferedReader, - memory: Optional[BufferedReader] = None + trace: Optional[BufferedReader, TextIOWrapper] = None, + memory: Optional[BufferedReader, TextIOWrapper] = None ) → Job ``` @@ -1222,7 +1270,7 @@ Create a new job. --- - + ### method `get` @@ -1246,7 +1294,7 @@ Make a call to the API to retrieve job information. --- - + ### method `list` @@ -1263,7 +1311,7 @@ List jobs. --- - + ### method `retrieve_api_key` @@ -1287,7 +1335,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -1320,12 +1368,12 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ## class `VersionJobsClient` Client to interact with `jobs` endpoint. - + ### method `__init__` @@ -1349,7 +1397,7 @@ __init__( --- - + ### method `create` @@ -1358,7 +1406,7 @@ create( model_id: int, version_id: int, job_create: JobCreate, - f: BufferedReader + f: TextIOWrapper ) → Job ``` @@ -1385,7 +1433,7 @@ Create a new job. --- - + ### method `get` @@ -1409,7 +1457,7 @@ Make a call to the API to retrieve job information. --- - + ### method `list` @@ -1426,7 +1474,7 @@ List jobs. --- - + ### method `retrieve_api_key` @@ -1450,7 +1498,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -1483,12 +1531,12 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ## class `ProofsClient` Client to interact with `proofs` endpoint. - + ### method `__init__` @@ -1512,7 +1560,7 @@ __init__( --- - + ### method `download` @@ -1535,7 +1583,7 @@ Download a proof. --- - + ### method `get` @@ -1559,7 +1607,7 @@ Make a call to the API to retrieve proof information. --- - + ### method `get_by_job_id` @@ -1583,7 +1631,7 @@ Make a call to the API to retrieve proof information based on the job id. --- - + ### method `list` @@ -1600,7 +1648,7 @@ List all the proofs related to the user. --- - + ### method `retrieve_api_key` @@ -1624,7 +1672,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -1654,15 +1702,38 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials - `Exception`: if token could not be retrieved in any way +--- + + + +### method `verify_proof` + +```python +verify_proof(proof_id: int) → VerifyResponse +``` + +Verify a proof. + + + +**Args:** + + - `proof_id`: Proof identifier + + + +**Returns:** + The verification response + --- - + ## class `VersionsClient` Client to interact with `versions` endpoint. - + ### method `__init__` @@ -1686,7 +1757,7 @@ __init__( --- - + ### method `create` @@ -1714,7 +1785,7 @@ Create a new version. --- - + ### method `download` @@ -1739,7 +1810,7 @@ Download a version. --- - + ### method `download_original` @@ -1763,7 +1834,7 @@ Download the original version. --- - + ### method `get` @@ -1787,7 +1858,7 @@ Get a version. --- - + ### method `list` @@ -1810,7 +1881,7 @@ List all the versions related to a model. --- - + ### method `retrieve_api_key` @@ -1834,7 +1905,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -1866,7 +1937,7 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ### method `update` @@ -1891,12 +1962,12 @@ Update a specific version. --- - + ### method `upload_cairo` ```python -upload_cairo(model_id: int, version_id: int, file_path: str) → str +upload_cairo(model_id: int, version_id: int, file_path: str) → Version ``` Get the Cairo model URL. @@ -1916,12 +1987,12 @@ Get the Cairo model URL. --- - + ## class `WorkspaceClient` Client to interact with `workspaces` endpoint. - + ### method `__init__` @@ -1945,7 +2016,7 @@ __init__( --- - + ### method `create` @@ -1963,7 +2034,7 @@ Call the API to create a new workspace. If the workspace already exists it will --- - + ### method `delete` @@ -1980,7 +2051,7 @@ Call the API to delete the workspace. If the workspace does not exist it will re --- - + ### method `get` @@ -1998,7 +2069,7 @@ Make a call to the API to retrieve workspace information. Only one should exist. --- - + ### method `retrieve_api_key` @@ -2022,7 +2093,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` @@ -2055,12 +2126,12 @@ First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials --- - + ## class `AgentsClient` Client to interact with `agents` endpoint. - + ### method `__init__` @@ -2084,7 +2155,7 @@ __init__( --- - + ### method `create` @@ -2107,7 +2178,7 @@ Create a new agent. --- - + ### method `delete` @@ -2125,7 +2196,7 @@ Delete an agent. --- - + ### method `get` @@ -2148,12 +2219,12 @@ Get an agent. --- - + ### method `list` ```python -list(params: Optional[Dict[str, str]] = None) → AgentList +list(params: Optional[Dict[str, Any]] = None) → AgentList ``` List endpoints. @@ -2165,7 +2236,7 @@ List endpoints. --- - + ### method `patch` @@ -2189,7 +2260,7 @@ Update an agent. --- - + ### method `retrieve_api_key` @@ -2213,7 +2284,7 @@ Retrieve the API key from the `~/.giza/.api_key.json` file. --- - + ### method `retrieve_token` diff --git a/docs/reference/api/commands.actions.md b/docs/reference/api/commands.actions.md index 9652986..f7d202d 100644 --- a/docs/reference/api/commands.actions.md +++ b/docs/reference/api/commands.actions.md @@ -15,7 +15,7 @@ ## function `new` ```python -new(project_name: str = ) +new(project_name: str = ) ``` This command will create a new action by generating a Python project. diff --git a/docs/reference/api/frameworks.cairo.md b/docs/reference/api/frameworks.cairo.md index 4a570c8..c512913 100644 --- a/docs/reference/api/frameworks.cairo.md +++ b/docs/reference/api/frameworks.cairo.md @@ -59,7 +59,7 @@ deploy( data: Optional[str] = None, size: ServiceSize = , debug: Optional[bool] = DEBUG_OPTION -) → str +) → Endpoint ``` Command to deploy a specific version of a model. This will create an endpoint for the specified version and check the status, once it finishes if COMPLETED the endpoint is ready to be used. @@ -139,7 +139,8 @@ verify( version_id: Optional[int], proof: Optional[str] = None, debug: Optional[bool] = False, - size: JobSize = + size: JobSize = , + use_job: Optional[bool] = False ) ``` diff --git a/docs/reference/api/frameworks.ezkl.md b/docs/reference/api/frameworks.ezkl.md index 65816f3..bff659d 100644 --- a/docs/reference/api/frameworks.ezkl.md +++ b/docs/reference/api/frameworks.ezkl.md @@ -86,7 +86,7 @@ deploy( version_id: int, size: ServiceSize = , debug: Optional[bool] = DEBUG_OPTION, -) → str +) → None ``` Command to deploy a specific version of a model. This will create a endpoint for the specified version and check the status, once it finishes if COMPLETED the endpoint is ready to be used. diff --git a/docs/reference/api/utils.decorators.md b/docs/reference/api/utils.decorators.md index 060c1f9..73a3de6 100644 --- a/docs/reference/api/utils.decorators.md +++ b/docs/reference/api/utils.decorators.md @@ -13,12 +13,12 @@ --- - + ## function `auth` ```python -auth(func: Callable) +auth(func: Callable[~P, ~R]) → Callable[~P, ~R] ``` Check that we have the token and it is not expired before executing diff --git a/giza/utils/echo.py b/giza/utils/echo.py index c9c0a2d..738c20d 100644 --- a/giza/utils/echo.py +++ b/giza/utils/echo.py @@ -10,7 +10,7 @@ class Echo: """ - Helper class to use when printin output of the CLI. + Helper class to use when printing output of the CLI. Provides utilities to print different levels of the messages and provides formatting capabilities to each of the levels. """ @@ -97,7 +97,7 @@ def echo(self, message: str, formatted: str) -> None: def error(self, message: str) -> None: """ - Format and echo a error message + Format and echo an error message Args: message (str): error message to format and echo From 44a77991cee0712e17a00174132bc98030388901 Mon Sep 17 00:00:00 2001 From: Gonzalo Mellizo-Soto Date: Mon, 22 Apr 2024 13:58:06 +0200 Subject: [PATCH 5/5] Bumping version from 0.15.0 to 0.15.1 --- docs/README.md | 2 +- docs/examples/full_transpilation.md | 2 +- examples/mnist/mnist_pytorch.ipynb | 2 +- examples/mnist/requirements.txt | 2 +- giza/__init__.py | 2 +- pyproject.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/README.md b/docs/README.md index 9d094a2..b674d0a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,5 @@ --- -description: Giza CLI 0.15.0 +description: Giza CLI 0.15.1 --- # Giza CLI diff --git a/docs/examples/full_transpilation.md b/docs/examples/full_transpilation.md index 470d0f3..ad47448 100644 --- a/docs/examples/full_transpilation.md +++ b/docs/examples/full_transpilation.md @@ -21,7 +21,7 @@ pip install -r requirements.txt Or: ```bash -pip install giza-cli==0.15.0 onnx==1.14.1 torch==2.1.0 torchvision==0.16.0 +pip install giza-cli==0.15.1 onnx==1.14.1 torch==2.1.0 torchvision==0.16.0 ``` We will use the libraries for the following purposes: diff --git a/examples/mnist/mnist_pytorch.ipynb b/examples/mnist/mnist_pytorch.ipynb index fe0ba78..7c8ad58 100644 --- a/examples/mnist/mnist_pytorch.ipynb +++ b/examples/mnist/mnist_pytorch.ipynb @@ -41,7 +41,7 @@ "Or:\n", "\n", "```bash\n", - "pip install giza-cli==0.15.0 onnx==1.14.1 torch==2.1.0 torchvision==0.16.0\n", + "pip install giza-cli==0.15.1 onnx==1.14.1 torch==2.1.0 torchvision==0.16.0\n", "```\n", "\n", "We will use the libraries for the following purposes:\n", diff --git a/examples/mnist/requirements.txt b/examples/mnist/requirements.txt index ae29df2..684c54f 100644 --- a/examples/mnist/requirements.txt +++ b/examples/mnist/requirements.txt @@ -1,4 +1,4 @@ -giza-cli==0.15.0 +giza-cli==0.15.1 onnx==1.14.1 tf2onnx==1.15.1 torch==2.1.0 diff --git a/giza/__init__.py b/giza/__init__.py index 3588b8c..084d16b 100644 --- a/giza/__init__.py +++ b/giza/__init__.py @@ -1,5 +1,5 @@ import os -__version__ = "0.15.0" +__version__ = "0.15.1" # Until DNS is fixed API_HOST = os.environ.get("GIZA_API_HOST", "https://api.gizatech.xyz") diff --git a/pyproject.toml b/pyproject.toml index 351d821..e781961 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "giza-cli" -version = "0.15.0" +version = "0.15.1" description = "CLI for interacting with Giza" authors = ["Gonzalo Mellizo-Soto "] readme = "README.md"