diff --git a/.github/workflows/onpush.yml b/.github/workflows/onpush.yml index 74d5675..1f2df1b 100644 --- a/.github/workflows/onpush.yml +++ b/.github/workflows/onpush.yml @@ -33,4 +33,4 @@ jobs: poetry run pre-commit run --all-files - name: Testing run: | - poetry run pytest --cov=giza --cov-report term-missing --cov-fail-under=60 + poetry run pytest --cov=giza.cli--cov-report term-missing --cov-fail-under=60 diff --git a/.github/workflows/onrelease.yml b/.github/workflows/onrelease.yml index fd35bd4..f52ba0c 100644 --- a/.github/workflows/onrelease.yml +++ b/.github/workflows/onrelease.yml @@ -33,7 +33,7 @@ jobs: poetry run ruff giza - name: Testing run: | - poetry run pytest --cov=giza --cov-report term-missing --cov-fail-under=60 + poetry run pytest --cov=giza.cli--cov-report term-missing --cov-fail-under=60 - name: Build dist run: poetry build diff --git a/giza/__init__.py b/giza/cli/__init__.py similarity index 100% rename from giza/__init__.py rename to giza/cli/__init__.py diff --git a/giza/__main__.py b/giza/cli/__main__.py similarity index 55% rename from giza/__main__.py rename to giza/cli/__main__.py index c67f5c4..af47b43 100644 --- a/giza/__main__.py +++ b/giza/cli/__main__.py @@ -1,4 +1,4 @@ -from giza.cli import entrypoint +from giza.cli.cli import entrypoint if __name__ == "__main__": entrypoint() diff --git a/giza/callbacks.py b/giza/cli/callbacks.py similarity index 93% rename from giza/callbacks.py rename to giza/cli/callbacks.py index af6c3b2..2a4818e 100644 --- a/giza/callbacks.py +++ b/giza/cli/callbacks.py @@ -2,8 +2,8 @@ import typer -from giza import __version__ -from giza.utils import echo +from giza.cli import __version__ +from giza.cli.utils import echo def version_callback(value: bool) -> None: diff --git a/giza/cli.py b/giza/cli/cli.py similarity index 89% rename from giza/cli.py rename to giza/cli/cli.py index 2681929..3f73133 100644 --- a/giza/cli.py +++ b/giza/cli/cli.py @@ -3,20 +3,20 @@ import typer.rich_utils from rich.traceback import install -from giza.commands.actions import app as actions_app -from giza.commands.agents import app as agents_app -from giza.commands.endpoints import app as deployments_app -from giza.commands.endpoints import deploy -from giza.commands.models import app as models_app -from giza.commands.prove import prove -from giza.commands.reset_password import request_reset_password_token, reset_password -from giza.commands.users import app as users_app -from giza.commands.verify import verify -from giza.commands.version import check_version -from giza.commands.versions import app as versions_app -from giza.commands.versions import transpile -from giza.commands.workspaces import app as workspaces_app -from giza.utils import echo +from giza.cli.commands.actions import app as actions_app +from giza.cli.commands.agents import app as agents_app +from giza.cli.commands.endpoints import app as deployments_app +from giza.cli.commands.endpoints import deploy +from giza.cli.commands.models import app as models_app +from giza.cli.commands.prove import prove +from giza.cli.commands.reset_password import request_reset_password_token, reset_password +from giza.cli.commands.users import app as users_app +from giza.cli.commands.verify import verify +from giza.cli.commands.version import check_version +from giza.cli.commands.versions import app as versions_app +from giza.cli.commands.versions import transpile +from giza.cli.commands.workspaces import app as workspaces_app +from giza.cli.utils import echo install(suppress=[click]) diff --git a/giza/client.py b/giza/cli/client.py similarity index 98% rename from giza/client.py rename to giza/cli/client.py index cae818e..9b035d5 100644 --- a/giza/client.py +++ b/giza/cli/client.py @@ -12,20 +12,20 @@ from requests import HTTPError, Response, Session from rich import print, print_json -from giza.schemas import users -from giza.schemas.agents import Agent, AgentCreate, AgentList, AgentUpdate -from giza.schemas.endpoints import Endpoint, EndpointCreate, EndpointsList -from giza.schemas.jobs import Job, JobCreate, JobList -from giza.schemas.message import Msg -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 -from giza.utils.decorators import auth -from giza.utils.enums import VersionStatus +from giza.cli.schemas import users +from giza.cli.schemas.agents import Agent, AgentCreate, AgentList, AgentUpdate +from giza.cli.schemas.endpoints import Endpoint, EndpointCreate, EndpointsList +from giza.cli.schemas.jobs import Job, JobCreate, JobList +from giza.cli.schemas.message import Msg +from giza.cli.schemas.models import Model, ModelCreate, ModelList, ModelUpdate +from giza.cli.schemas.proofs import Proof, ProofList +from giza.cli.schemas.token import TokenResponse +from giza.cli.schemas.verify import VerifyResponse +from giza.cli.schemas.versions import Version, VersionCreate, VersionList, VersionUpdate +from giza.cli.schemas.workspaces import Workspace +from giza.cli.utils import echo +from giza.cli.utils.decorators import auth +from giza.cli.utils.enums import VersionStatus DEFAULT_API_VERSION = "v1" GIZA_TOKEN_VARIABLE = "GIZA_TOKEN" diff --git a/giza/commands/__init__.py b/giza/cli/commands/__init__.py similarity index 100% rename from giza/commands/__init__.py rename to giza/cli/commands/__init__.py diff --git a/giza/commands/actions.py b/giza/cli/commands/actions.py similarity index 95% rename from giza/commands/actions.py rename to giza/cli/commands/actions.py index 52e15c4..0824328 100644 --- a/giza/commands/actions.py +++ b/giza/cli/commands/actions.py @@ -2,7 +2,7 @@ from cookiecutter.main import cookiecutter # type: ignore from slugify import slugify -from giza.utils import echo +from giza.cli.utils import echo app = typer.Typer() diff --git a/giza/commands/agents.py b/giza/cli/commands/agents.py similarity index 95% rename from giza/commands/agents.py rename to giza/cli/commands/agents.py index 97be480..b000bee 100644 --- a/giza/commands/agents.py +++ b/giza/cli/commands/agents.py @@ -7,13 +7,13 @@ from rich.console import Console from rich.table import Table -from giza import API_HOST -from giza.client import AgentsClient, EndpointsClient -from giza.options import DEBUG_OPTION -from giza.schemas.agents import AgentCreate, AgentList, AgentUpdate -from giza.utils import echo -from giza.utils.exception_handling import ExceptionHandler -from giza.utils.misc import get_ape_accounts, get_parameters_from_str, load_json_file +from giza.cli import API_HOST +from giza.cli.client import AgentsClient, EndpointsClient +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.agents import AgentCreate, AgentList, AgentUpdate +from giza.cli.utils import echo +from giza.cli.utils.exception_handling import ExceptionHandler +from giza.cli.utils.misc import get_ape_accounts, get_parameters_from_str, load_json_file app = typer.Typer() diff --git a/giza/commands/endpoints.py b/giza/cli/commands/endpoints.py similarity index 97% rename from giza/commands/endpoints.py rename to giza/cli/commands/endpoints.py index 16e1226..dabc1bc 100644 --- a/giza/commands/endpoints.py +++ b/giza/cli/commands/endpoints.py @@ -6,15 +6,15 @@ from requests import HTTPError from rich import print_json -from giza import API_HOST -from giza.client import EndpointsClient -from giza.frameworks import cairo, ezkl -from giza.options import DEBUG_OPTION -from giza.schemas.endpoints import EndpointsList -from giza.schemas.proofs import Proof, ProofList -from giza.utils import echo, get_response_info -from giza.utils.enums import Framework, ServiceSize -from giza.utils.exception_handling import ExceptionHandler +from giza.cli import API_HOST +from giza.cli.client import EndpointsClient +from giza.cli.frameworks import cairo, ezkl +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.endpoints import EndpointsList +from giza.cli.schemas.proofs import Proof, ProofList +from giza.cli.utils import echo, get_response_info +from giza.cli.utils.enums import Framework, ServiceSize +from giza.cli.utils.exception_handling import ExceptionHandler app = typer.Typer() diff --git a/giza/commands/models.py b/giza/cli/commands/models.py similarity index 96% rename from giza/commands/models.py rename to giza/cli/commands/models.py index cc0d039..fac6204 100644 --- a/giza/commands/models.py +++ b/giza/cli/commands/models.py @@ -6,11 +6,11 @@ from requests import HTTPError from rich import print_json -from giza import API_HOST -from giza.client import ModelsClient -from giza.options import DEBUG_OPTION -from giza.schemas.models import ModelCreate -from giza.utils import echo, get_response_info +from giza.cli import API_HOST +from giza.cli.client import ModelsClient +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.models import ModelCreate +from giza.cli.utils import echo, get_response_info app = typer.Typer() diff --git a/giza/commands/prove.py b/giza/cli/commands/prove.py similarity index 88% rename from giza/commands/prove.py rename to giza/cli/commands/prove.py index 8d7528c..464acba 100644 --- a/giza/commands/prove.py +++ b/giza/cli/commands/prove.py @@ -2,9 +2,9 @@ import typer -from giza.frameworks import cairo, ezkl -from giza.options import DEBUG_OPTION -from giza.utils.enums import Framework, JobSize +from giza.cli.frameworks import cairo, ezkl +from giza.cli.options import DEBUG_OPTION +from giza.cli.utils.enums import Framework, JobSize app = typer.Typer() diff --git a/giza/commands/reset_password.py b/giza/cli/commands/reset_password.py similarity index 93% rename from giza/commands/reset_password.py rename to giza/cli/commands/reset_password.py index e67c8fe..52f6f9f 100644 --- a/giza/commands/reset_password.py +++ b/giza/cli/commands/reset_password.py @@ -4,12 +4,12 @@ import typer from requests import HTTPError -from giza import API_HOST -from giza.client import UsersClient -from giza.exceptions import PasswordError -from giza.options import DEBUG_OPTION -from giza.utils import echo, get_response_info -from giza.utils.misc import _check_password_strength +from giza.cli import API_HOST +from giza.cli.client import UsersClient +from giza.cli.exceptions import PasswordError +from giza.cli.options import DEBUG_OPTION +from giza.cli.utils import echo, get_response_info +from giza.cli.utils.misc import _check_password_strength def prompt_for_input( diff --git a/giza/commands/users.py b/giza/cli/commands/users.py similarity index 96% rename from giza/commands/users.py rename to giza/cli/commands/users.py index d9d2b1c..4242383 100644 --- a/giza/commands/users.py +++ b/giza/cli/commands/users.py @@ -7,13 +7,13 @@ from requests import HTTPError from rich import print_json -from giza import API_HOST -from giza.client import UsersClient -from giza.exceptions import PasswordError -from giza.options import DEBUG_OPTION -from giza.schemas import users -from giza.utils import echo, get_response_info -from giza.utils.misc import _check_password_strength +from giza.cli import API_HOST +from giza.cli.client import UsersClient +from giza.cli.exceptions import PasswordError +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas import users +from giza.cli.utils import echo, get_response_info +from giza.cli.utils.misc import _check_password_strength app = typer.Typer() diff --git a/giza/commands/verify.py b/giza/cli/commands/verify.py similarity index 90% rename from giza/commands/verify.py rename to giza/cli/commands/verify.py index 6ac1eb1..fd6791c 100644 --- a/giza/commands/verify.py +++ b/giza/cli/commands/verify.py @@ -2,9 +2,9 @@ import typer -from giza.frameworks import cairo, ezkl -from giza.options import DEBUG_OPTION -from giza.utils.enums import Framework, JobSize +from giza.cli.frameworks import cairo, ezkl +from giza.cli.options import DEBUG_OPTION +from giza.cli.utils.enums import Framework, JobSize app = typer.Typer() diff --git a/giza/commands/version.py b/giza/cli/commands/version.py similarity index 90% rename from giza/commands/version.py rename to giza/cli/commands/version.py index baebbc5..a597190 100644 --- a/giza/commands/version.py +++ b/giza/cli/commands/version.py @@ -1,8 +1,8 @@ import requests import semver -from giza import __version__ -from giza.utils.echo import Echo +from giza.cli import __version__ +from giza.cli.utils.echo import Echo # TODO: Make sure that this works offline, currently it doesn't diff --git a/giza/commands/versions.py b/giza/cli/commands/versions.py similarity index 95% rename from giza/commands/versions.py rename to giza/cli/commands/versions.py index bd036af..ee2e809 100644 --- a/giza/commands/versions.py +++ b/giza/cli/commands/versions.py @@ -8,15 +8,15 @@ import typer from rich import print_json -from giza import API_HOST -from giza.client import TranspileClient, VersionsClient -from giza.frameworks import cairo, ezkl -from giza.options import DEBUG_OPTION -from giza.schemas.versions import Version, VersionList -from giza.utils import echo -from giza.utils.enums import Framework, VersionStatus -from giza.utils.exception_handling import ExceptionHandler -from giza.utils.misc import download_model_or_sierra, scarb_build, zip_folder +from giza.cli import API_HOST +from giza.cli.client import TranspileClient, VersionsClient +from giza.cli.frameworks import cairo, ezkl +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.versions import Version, VersionList +from giza.cli.utils import echo +from giza.cli.utils.enums import Framework, VersionStatus +from giza.cli.utils.exception_handling import ExceptionHandler +from giza.cli.utils.misc import download_model_or_sierra, scarb_build, zip_folder app = typer.Typer() diff --git a/giza/commands/workspaces.py b/giza/cli/commands/workspaces.py similarity index 97% rename from giza/commands/workspaces.py rename to giza/cli/commands/workspaces.py index 78d7cdf..458cf37 100644 --- a/giza/commands/workspaces.py +++ b/giza/cli/commands/workspaces.py @@ -8,10 +8,10 @@ from rich import print_json from rich.live import Live -from giza import API_HOST -from giza.client import WorkspaceClient -from giza.options import DEBUG_OPTION -from giza.utils import echo, get_response_info +from giza.cli import API_HOST +from giza.cli.client import WorkspaceClient +from giza.cli.options import DEBUG_OPTION +from giza.cli.utils import echo, get_response_info app = typer.Typer() diff --git a/giza/exceptions.py b/giza/cli/exceptions.py similarity index 100% rename from giza/exceptions.py rename to giza/cli/exceptions.py diff --git a/giza/frameworks/__init__.py b/giza/cli/frameworks/__init__.py similarity index 100% rename from giza/frameworks/__init__.py rename to giza/cli/frameworks/__init__.py diff --git a/giza/frameworks/cairo.py b/giza/cli/frameworks/cairo.py similarity index 97% rename from giza/frameworks/cairo.py rename to giza/cli/frameworks/cairo.py index 269fc40..8e2c25d 100644 --- a/giza/frameworks/cairo.py +++ b/giza/cli/frameworks/cairo.py @@ -13,22 +13,22 @@ from rich.progress import Progress, SpinnerColumn, TextColumn from rich.spinner import Spinner -from giza import API_HOST -from giza.client import ( +from giza.cli import API_HOST +from giza.cli.client import ( EndpointsClient, JobsClient, ModelsClient, ProofsClient, VersionsClient, ) -from giza.options import DEBUG_OPTION -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 -from giza.schemas.versions import VersionCreate, VersionUpdate -from giza.utils import Echo, echo, get_response_info -from giza.utils.enums import ( +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.endpoints import Endpoint, EndpointCreate, EndpointsList +from giza.cli.schemas.jobs import Job, JobCreate +from giza.cli.schemas.models import ModelCreate +from giza.cli.schemas.proofs import Proof +from giza.cli.schemas.versions import VersionCreate, VersionUpdate +from giza.cli.utils import Echo, echo, get_response_info +from giza.cli.utils.enums import ( Framework, JobKind, JobSize, @@ -36,7 +36,7 @@ ServiceSize, VersionStatus, ) -from giza.utils.misc import download_model_or_sierra +from giza.cli.utils.misc import download_model_or_sierra app = typer.Typer() diff --git a/giza/frameworks/ezkl.py b/giza/cli/frameworks/ezkl.py similarity index 96% rename from giza/frameworks/ezkl.py rename to giza/cli/frameworks/ezkl.py index 9a2e3e6..a8f462a 100644 --- a/giza/frameworks/ezkl.py +++ b/giza/cli/frameworks/ezkl.py @@ -10,8 +10,8 @@ from rich.live import Live from rich.progress import Progress, Spinner, SpinnerColumn, TextColumn -from giza import API_HOST -from giza.client import ( +from giza.cli import API_HOST +from giza.cli.client import ( EndpointsClient, JobsClient, ModelsClient, @@ -19,14 +19,14 @@ VersionJobsClient, VersionsClient, ) -from giza.options import DEBUG_OPTION -from giza.schemas.endpoints import EndpointCreate, EndpointsList -from giza.schemas.jobs import Job, JobCreate -from giza.schemas.models import ModelCreate -from giza.schemas.proofs import Proof -from giza.schemas.versions import VersionCreate, VersionStatus, VersionUpdate -from giza.utils import Echo, get_response_info -from giza.utils.enums import Framework, JobKind, JobSize, JobStatus, ServiceSize +from giza.cli.options import DEBUG_OPTION +from giza.cli.schemas.endpoints import EndpointCreate, EndpointsList +from giza.cli.schemas.jobs import Job, JobCreate +from giza.cli.schemas.models import ModelCreate +from giza.cli.schemas.proofs import Proof +from giza.cli.schemas.versions import VersionCreate, VersionStatus, VersionUpdate +from giza.cli.utils import Echo, get_response_info +from giza.cli.utils.enums import Framework, JobKind, JobSize, JobStatus, ServiceSize def setup( diff --git a/giza/options.py b/giza/cli/options.py similarity index 81% rename from giza/options.py rename to giza/cli/options.py index ba8f352..a719d11 100644 --- a/giza/options.py +++ b/giza/cli/options.py @@ -1,6 +1,6 @@ import typer -from giza.callbacks import debug_callback +from giza.cli.callbacks import debug_callback DEBUG_OPTION = typer.Option( False, diff --git a/giza/schemas/agents.py b/giza/cli/schemas/agents.py similarity index 100% rename from giza/schemas/agents.py rename to giza/cli/schemas/agents.py diff --git a/giza/schemas/endpoints.py b/giza/cli/schemas/endpoints.py similarity index 94% rename from giza/schemas/endpoints.py rename to giza/cli/schemas/endpoints.py index 92f9e3c..1b50175 100644 --- a/giza/schemas/endpoints.py +++ b/giza/cli/schemas/endpoints.py @@ -2,7 +2,7 @@ from pydantic import BaseModel, ConfigDict, RootModel -from giza.utils.enums import Framework, ServiceSize +from giza.cli.utils.enums import Framework, ServiceSize class EndpointCreate(BaseModel): diff --git a/giza/schemas/jobs.py b/giza/cli/schemas/jobs.py similarity index 91% rename from giza/schemas/jobs.py rename to giza/cli/schemas/jobs.py index 8721252..c4e1b73 100644 --- a/giza/schemas/jobs.py +++ b/giza/cli/schemas/jobs.py @@ -3,7 +3,7 @@ from pydantic import BaseModel, ConfigDict, RootModel -from giza.utils.enums import Framework, JobKind, JobSize, JobStatus +from giza.cli.utils.enums import Framework, JobKind, JobSize, JobStatus class Job(BaseModel): diff --git a/giza/schemas/message.py b/giza/cli/schemas/message.py similarity index 100% rename from giza/schemas/message.py rename to giza/cli/schemas/message.py diff --git a/giza/schemas/models.py b/giza/cli/schemas/models.py similarity index 100% rename from giza/schemas/models.py rename to giza/cli/schemas/models.py diff --git a/giza/schemas/proofs.py b/giza/cli/schemas/proofs.py similarity index 100% rename from giza/schemas/proofs.py rename to giza/cli/schemas/proofs.py diff --git a/giza/schemas/token.py b/giza/cli/schemas/token.py similarity index 100% rename from giza/schemas/token.py rename to giza/cli/schemas/token.py diff --git a/giza/schemas/users.py b/giza/cli/schemas/users.py similarity index 100% rename from giza/schemas/users.py rename to giza/cli/schemas/users.py diff --git a/giza/schemas/verify.py b/giza/cli/schemas/verify.py similarity index 100% rename from giza/schemas/verify.py rename to giza/cli/schemas/verify.py diff --git a/giza/schemas/versions.py b/giza/cli/schemas/versions.py similarity index 91% rename from giza/schemas/versions.py rename to giza/cli/schemas/versions.py index bebf0e1..97bf4a6 100644 --- a/giza/schemas/versions.py +++ b/giza/cli/schemas/versions.py @@ -3,7 +3,7 @@ from pydantic import BaseModel, RootModel -from giza.utils.enums import Framework, VersionStatus +from giza.cli.utils.enums import Framework, VersionStatus class VersionCreate(BaseModel): diff --git a/giza/schemas/workspaces.py b/giza/cli/schemas/workspaces.py similarity index 100% rename from giza/schemas/workspaces.py rename to giza/cli/schemas/workspaces.py diff --git a/giza/utils/__init__.py b/giza/cli/utils/__init__.py similarity index 96% rename from giza/utils/__init__.py rename to giza/cli/utils/__init__.py index 9df346c..4dee834 100644 --- a/giza/utils/__init__.py +++ b/giza/cli/utils/__init__.py @@ -3,7 +3,7 @@ from requests import Response -from giza.utils.echo import Echo +from giza.cli.utils.echo import Echo # Provided an instance for ease of use echo = Echo() diff --git a/giza/utils/decorators.py b/giza/cli/utils/decorators.py similarity index 97% rename from giza/utils/decorators.py rename to giza/cli/utils/decorators.py index 821f0fd..75bca81 100644 --- a/giza/utils/decorators.py +++ b/giza/cli/utils/decorators.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, Callable, ParamSpec, TypeVar if TYPE_CHECKING: - from giza.client import ApiClient + from giza.cli.client import ApiClient P = ParamSpec("P") R = TypeVar("R") diff --git a/giza/utils/echo.py b/giza/cli/utils/echo.py similarity index 100% rename from giza/utils/echo.py rename to giza/cli/utils/echo.py diff --git a/giza/utils/enums.py b/giza/cli/utils/enums.py similarity index 100% rename from giza/utils/enums.py rename to giza/cli/utils/enums.py diff --git a/giza/utils/exception_handling.py b/giza/cli/utils/exception_handling.py similarity index 95% rename from giza/utils/exception_handling.py rename to giza/cli/utils/exception_handling.py index 894a0ff..c139f5e 100644 --- a/giza/utils/exception_handling.py +++ b/giza/cli/utils/exception_handling.py @@ -4,8 +4,8 @@ from pydantic import ValidationError from requests import HTTPError -from giza.exceptions import ScarbBuildError, ScarbNotFound -from giza.utils import echo, get_response_info +from giza.cli.exceptions import ScarbBuildError, ScarbNotFound +from giza.cli.utils import echo, get_response_info class ExceptionHandler: diff --git a/giza/utils/misc.py b/giza/cli/utils/misc.py similarity index 97% rename from giza/utils/misc.py rename to giza/cli/utils/misc.py index 37b8755..db64de6 100644 --- a/giza/utils/misc.py +++ b/giza/cli/utils/misc.py @@ -7,8 +7,8 @@ from pathlib import Path from typing import Dict, List, Optional -from giza.exceptions import PasswordError, ScarbBuildError, ScarbNotFound -from giza.utils import echo +from giza.cli.exceptions import PasswordError, ScarbBuildError, ScarbNotFound +from giza.cli.utils import echo def _check_password_strength(password: str) -> None: diff --git a/pyproject.toml b/pyproject.toml index a908a28..6a48ae6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ readme = "README.md" packages = [{include = "giza"}] [tool.poetry.scripts] -giza = "giza.cli:entrypoint" +giza = "giza.cli.cli:entrypoint" [tool.poetry.dependencies] python = "^3.11" diff --git a/tests/commands/test_agents.py b/tests/commands/test_agents.py index 465c032..6004cd3 100644 --- a/tests/commands/test_agents.py +++ b/tests/commands/test_agents.py @@ -1,9 +1,9 @@ from pathlib import Path from unittest.mock import patch -from giza.commands.agents import AgentsClient, EndpointsClient -from giza.schemas.agents import Agent, AgentList, AgentUpdate -from giza.schemas.endpoints import Endpoint, EndpointsList +from giza.cli.commands.agents import AgentsClient, EndpointsClient +from giza.cli.schemas.agents import Agent, AgentList, AgentUpdate +from giza.cli.schemas.endpoints import Endpoint, EndpointsList from tests.conftest import invoke_cli_runner @@ -44,12 +44,12 @@ def test_create_agent_with_model_id_and_version_id(): parameters={}, ) with patch.object(AgentsClient, "create", return_value=agent) as mock_create, patch( - "giza.commands.agents.get_ape_accounts", + "giza.cli.commands.agents.get_ape_accounts", return_value={"test": Path("dummy.json")}, ) as mock_accounts, patch( "typer.prompt", side_effect=["test"] ) as mock_prompt, patch( - "giza.commands.agents.load_json_file", return_value={} + "giza.cli.commands.agents.load_json_file", return_value={} ) as mock_load, patch.object( EndpointsClient, "list", @@ -94,12 +94,12 @@ def test_create_agent_with_endpoint_id(): parameters={}, ) with patch.object(AgentsClient, "create", return_value=agent) as mock_create, patch( - "giza.commands.agents.get_ape_accounts", + "giza.cli.commands.agents.get_ape_accounts", return_value={"test": Path("dummy.json")}, ) as mock_accounts, patch( "typer.prompt", side_effect=["test"] ) as mock_prompt, patch( - "giza.commands.agents.load_json_file", return_value={} + "giza.cli.commands.agents.load_json_file", return_value={} ) as mock_load, patch.object( EndpointsClient, "get", diff --git a/tests/commands/test_endpoints.py b/tests/commands/test_endpoints.py index 4c0dd6c..56b3b8b 100644 --- a/tests/commands/test_endpoints.py +++ b/tests/commands/test_endpoints.py @@ -2,10 +2,10 @@ from requests import HTTPError -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 giza.cli.commands.endpoints import EndpointsClient, cairo +from giza.cli.frameworks import ezkl +from giza.cli.schemas.endpoints import Endpoint, EndpointsList +from giza.cli.schemas.verify import VerifyResponse from tests.conftest import invoke_cli_runner diff --git a/tests/commands/test_models.py b/tests/commands/test_models.py index 86be149..ef69033 100644 --- a/tests/commands/test_models.py +++ b/tests/commands/test_models.py @@ -4,8 +4,8 @@ from pydantic_core import InitErrorDetails from requests import HTTPError -from giza.commands.models import ModelsClient -from giza.schemas.models import Model, ModelList +from giza.cli.commands.models import ModelsClient +from giza.cli.schemas.models import Model, ModelList from tests.conftest import invoke_cli_runner @@ -35,7 +35,7 @@ def test_models_get_invalid_id(): line_errors=[InitErrorDetails(type="missing")], title="Resource validation error", ), - ), patch("giza.commands.models.get_response_info", return_value={}): + ), patch("giza.cli.commands.models.get_response_info", return_value={}): result = invoke_cli_runner( ["models", "get", "--model-id", "1"], expected_error=True ) @@ -68,7 +68,7 @@ def test_models_list(): # Test model listing with server error def test_models_list_server_error(): with patch.object(ModelsClient, "list", side_effect=HTTPError), patch( - "giza.commands.models.get_response_info", return_value={} + "giza.cli.commands.models.get_response_info", return_value={} ): result = invoke_cli_runner(["models", "list"], expected_error=True) @@ -79,7 +79,7 @@ def test_models_list_server_error(): # Test model retrieval with HTTPError in normal mode def test_models_get_httperror(): with patch.object(ModelsClient, "get", side_effect=HTTPError), patch( - "giza.commands.models.get_response_info", return_value={"request_id": 1} + "giza.cli.commands.models.get_response_info", return_value={"request_id": 1} ): result = invoke_cli_runner( ["models", "get", "--model-id", "1"], expected_error=True @@ -96,7 +96,7 @@ def test_models_get_httperror(): # Test model retrieval with HTTPError in debug mode def test_models_get_httperror_debug(): with patch.object(ModelsClient, "get", side_effect=HTTPError), patch( - "giza.commands.models.get_response_info", return_value={"request_id": 1} + "giza.cli.commands.models.get_response_info", return_value={"request_id": 1} ): result = invoke_cli_runner( ["models", "get", "--model-id", "1", "--debug"], expected_error=True diff --git a/tests/commands/test_reset_password.py b/tests/commands/test_reset_password.py index 5231f05..955dde1 100644 --- a/tests/commands/test_reset_password.py +++ b/tests/commands/test_reset_password.py @@ -3,14 +3,14 @@ import pytest from requests.exceptions import HTTPError -from giza.commands.reset_password import handle_http_error, prompt_for_input +from giza.cli.commands.reset_password import handle_http_error, prompt_for_input from tests.conftest import invoke_cli_runner # Test for successful request of reset password token def test_request_reset_password_token_success(): with patch( - "giza.client.UsersClient.request_reset_password_token" + "giza.cli.client.UsersClient.request_reset_password_token" ) as mock_request_token, patch( "typer.prompt", return_value="test@test.com", @@ -25,12 +25,13 @@ def test_request_reset_password_token_success(): # Test for HTTP error during request of reset password token def test_request_reset_password_token_http_error(): with patch( - "giza.client.UsersClient.request_reset_password_token", side_effect=HTTPError + "giza.cli.client.UsersClient.request_reset_password_token", + side_effect=HTTPError, ) as mock_request_token, patch( "typer.prompt", return_value="test@test.com", ), patch( - "giza.commands.reset_password.get_response_info", return_value={} + "giza.cli.commands.reset_password.get_response_info", return_value={} ): result = invoke_cli_runner( ["request-reset-password-token"], expected_error=True @@ -43,7 +44,9 @@ def test_request_reset_password_token_http_error(): # Test for successful password reset def test_reset_password_success(): - with patch("giza.client.UsersClient.reset_password") as mock_reset_password, patch( + with patch( + "giza.cli.client.UsersClient.reset_password" + ) as mock_reset_password, patch( "typer.prompt", side_effect=["request-reset-password-token", "New_password1", "New_password1"], ): @@ -85,12 +88,12 @@ def test_reset_password_invalid_password(): # Test for HTTP error during password reset def test_reset_password_http_error(): with patch( - "giza.client.UsersClient.reset_password", side_effect=HTTPError + "giza.cli.client.UsersClient.reset_password", side_effect=HTTPError ) as mock_reset_password, patch( "typer.prompt", side_effect=["reset_token", "New_password1", "New_password1"], ), patch( - "giza.commands.reset_password.get_response_info", return_value={} + "giza.cli.commands.reset_password.get_response_info", return_value={} ): result = invoke_cli_runner(["reset-password"], expected_error=True) @@ -101,8 +104,8 @@ def test_reset_password_http_error(): # Test for handling HTTP error def test_handle_http_error(): - with patch("giza.commands.reset_password.echo.error") as mock_echo_error, patch( - "giza.commands.reset_password.get_response_info", return_value={} + with patch("giza.cli.commands.reset_password.echo.error") as mock_echo_error, patch( + "giza.cli.commands.reset_password.get_response_info", return_value={} ), pytest.raises(HTTPError): handle_http_error(HTTPError("error"), "Test error", True) assert mock_echo_error.call_count == 5 diff --git a/tests/commands/test_users.py b/tests/commands/test_users.py index 9fcebe0..d1f7cde 100644 --- a/tests/commands/test_users.py +++ b/tests/commands/test_users.py @@ -4,8 +4,8 @@ from pydantic import ValidationError from requests import HTTPError -from giza.client import UsersClient -from giza.schemas.users import UserResponse +from giza.cli.client import UsersClient +from giza.cli.schemas.users import UserResponse from tests.conftest import invoke_cli_runner @@ -111,7 +111,7 @@ def test_users_create_invalid_response(): "giza@gizatech.xyz", ], ), patch.object(UsersClient, "create", side_effect=HTTPError), patch( - "giza.commands.users.get_response_info", return_value={} + "giza.cli.commands.users.get_response_info", return_value={} ): result = invoke_cli_runner(["users", "create", "--debug"], expected_error=True) @@ -122,7 +122,7 @@ def test_users_create_invalid_response(): def test_users_login_successfully(): - with patch("giza.client.UsersClient.retrieve_token") as mock_login, patch( + with patch("giza.cli.client.UsersClient.retrieve_token") as mock_login, patch( "typer.prompt", side_effect=["gizabrain", "gizapassword"], ): @@ -134,12 +134,12 @@ def test_users_login_successfully(): def test_users_login_no_auth(): with patch( - "giza.client.UsersClient.retrieve_token", side_effect=HTTPError + "giza.cli.client.UsersClient.retrieve_token", side_effect=HTTPError ) as mock_login, patch( "typer.prompt", side_effect=["gizabrain", "gizapassword"], ), patch( - "giza.commands.users.get_response_info", return_value={} + "giza.cli.commands.users.get_response_info", return_value={} ) as mock_info: result = invoke_cli_runner(["users", "login"], expected_error=True) @@ -151,12 +151,12 @@ def test_users_login_no_auth(): def test_users_login_no_auth_debug(): with patch( - "giza.client.UsersClient.retrieve_token", side_effect=HTTPError + "giza.cli.client.UsersClient.retrieve_token", side_effect=HTTPError ) as mock_login, patch( "typer.prompt", side_effect=["gizabrain", "gizapassword"], ), patch( - "giza.commands.users.get_response_info", return_value={} + "giza.cli.commands.users.get_response_info", return_value={} ) as mock_info: result = invoke_cli_runner(["users", "login", "--debug"], expected_error=True) @@ -172,7 +172,7 @@ def test_users_me(): user_response = UserResponse( username="giza", email="giza@gizatech.xyz", is_active=True ) - with patch("giza.client.UsersClient.me", return_value=user_response) as mock_me: + with patch("giza.cli.client.UsersClient.me", return_value=user_response) as mock_me: result = invoke_cli_runner(["users", "me"]) mock_me.assert_called_once() @@ -182,10 +182,10 @@ def test_users_me(): def test_resend_email_success(): # Test successful email resend - with patch("giza.client.UsersClient.resend_email") as mock_resend, patch( + with patch("giza.cli.client.UsersClient.resend_email") as mock_resend, patch( "typer.prompt", return_value="giza@gizatech.xyz", - ), patch("giza.commands.users.validate_email") as mock_validate: + ), patch("giza.cli.commands.users.validate_email") as mock_validate: result = invoke_cli_runner(["users", "resend-email"]) mock_resend.assert_called_once() @@ -230,8 +230,8 @@ def test_resend_email_invalid_response(): return_value="giza@gizatech.xyz", ), patch.object( UsersClient, "resend_email", side_effect=HTTPError - ), patch("giza.commands.users.get_response_info", return_value={}), patch( - "giza.commands.users.validate_email" + ), patch("giza.cli.commands.users.get_response_info", return_value={}), patch( + "giza.cli.commands.users.validate_email" ) as mock_validate: result = invoke_cli_runner( ["users", "resend-email", "--debug"], expected_error=True diff --git a/tests/commands/test_versions.py b/tests/commands/test_versions.py index 3f7f10a..5a2df1c 100644 --- a/tests/commands/test_versions.py +++ b/tests/commands/test_versions.py @@ -6,10 +6,10 @@ from pydantic_core import InitErrorDetails from requests.exceptions import HTTPError -from giza.commands.versions import VersionsClient, VersionStatus -from giza.schemas.models import Model, ModelList -from giza.schemas.versions import Version, VersionList -from giza.utils.enums import Framework +from giza.cli.commands.versions import VersionsClient, VersionStatus +from giza.cli.schemas.models import Model, ModelList +from giza.cli.schemas.versions import Version, VersionList +from giza.cli.utils.enums import Framework from tests.conftest import invoke_cli_runner @@ -58,7 +58,7 @@ def test_versions_get(): # Test version retrieval that throws an HTTPError def test_versions_get_http_error(): with patch.object(VersionsClient, "get", side_effect=HTTPError), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ): result = invoke_cli_runner( ["versions", "get", "--model-id", "1", "--version-id", "1"], @@ -78,7 +78,7 @@ def test_versions_get_invalid_id(): line_errors=[InitErrorDetails(type="missing")], title="Resource validation error", ), - ), patch("giza.utils.exception_handling.get_response_info", return_value={}): + ), patch("giza.cli.utils.exception_handling.get_response_info", return_value={}): result = invoke_cli_runner( ["versions", "get", "--model-id", "1", "--version-id", "1"], expected_error=True, @@ -114,7 +114,7 @@ def test_versions_list(): # Test version listing with server error def test_versions_list_server_error(): with patch.object(VersionsClient, "list", side_effect=HTTPError), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ): result = invoke_cli_runner( ["versions", "list", "--model-id", "1"], expected_error=True @@ -155,13 +155,13 @@ def return_content(): ) with patch( - "giza.frameworks.cairo.VersionsClient", + "giza.cli.frameworks.cairo.VersionsClient", return_value=ClientStub(version, return_content()), ), patch( - "giza.frameworks.cairo.ModelsClient.list", + "giza.cli.frameworks.cairo.ModelsClient.list", return_value=models, ), patch( - "giza.frameworks.cairo.Path" + "giza.cli.frameworks.cairo.Path" ), patch.object( VersionsClient, "get", return_value=version ), patch( @@ -169,7 +169,7 @@ def return_content(): ) as mock_open, patch.object( VersionsClient, "_load_credentials_file" ), patch( - "giza.frameworks.cairo.ModelsClient._load_credentials_file" + "giza.cli.frameworks.cairo.ModelsClient._load_credentials_file" ): result = invoke_cli_runner( ["versions", "transpile", "model", "--output-path", tmpdir, "--debug"] @@ -186,9 +186,11 @@ def return_content(): # Test version transpilation with HTTP error def test_versions_transpile_http_error(tmpdir): with patch( - "giza.frameworks.cairo.ModelsClient.get_by_name", side_effect=HTTPError - ), patch("giza.utils.exception_handling.get_response_info", return_value={}), patch( - "giza.frameworks.cairo.Path" + "giza.cli.frameworks.cairo.ModelsClient.get_by_name", side_effect=HTTPError + ), patch( + "giza.cli.utils.exception_handling.get_response_info", return_value={} + ), patch( + "giza.cli.frameworks.cairo.Path" ), patch.object( VersionsClient, "_load_credentials_file" ): @@ -229,13 +231,13 @@ def return_content(): ) with patch( - "giza.frameworks.cairo.VersionsClient", + "giza.cli.frameworks.cairo.VersionsClient", return_value=ClientStub(version, return_content()), ), patch( - "giza.frameworks.cairo.ModelsClient.list", + "giza.cli.frameworks.cairo.ModelsClient.list", return_value=models, ), patch( - "giza.frameworks.cairo.Path" + "giza.cli.frameworks.cairo.Path" ), patch.object( VersionsClient, "get", return_value=version ), patch( @@ -243,7 +245,7 @@ def return_content(): ) as mock_open, patch.object( VersionsClient, "_load_credentials_file" ), patch( - "giza.frameworks.cairo.ModelsClient._load_credentials_file" + "giza.cli.frameworks.cairo.ModelsClient._load_credentials_file" ): result = invoke_cli_runner( ["versions", "transpile", "model", "--output-path", tmpdir], @@ -278,7 +280,7 @@ def return_content(): with patch.object(VersionsClient, "get", return_value=version), patch.object( VersionsClient, "download", return_value=return_content() ), patch("builtins.open") as mock_open, patch( - "giza.client.VersionsClient._load_credentials_file" + "giza.cli.client.VersionsClient._load_credentials_file" ): result = invoke_cli_runner( [ @@ -301,7 +303,7 @@ def return_content(): # Test version download with server error def test_versions_download_server_error(): with patch.object(VersionsClient, "get", side_effect=HTTPError), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ): result = invoke_cli_runner( [ @@ -360,7 +362,7 @@ def return_content(): # Test version download with missing model_id and version_id def test_versions_download_missing_ids(): with patch.object(VersionsClient, "get", side_effect=HTTPError), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ): result = invoke_cli_runner( [ @@ -391,10 +393,10 @@ def test_versions_update_successful(): with patch.object(VersionsClient, "get", return_value=version), patch.object( VersionsClient, "upload_cairo", return_value=updated_version - ), patch("giza.commands.versions.scarb_build"), patch( - "giza.commands.versions.zip_folder" + ), patch("giza.cli.commands.versions.scarb_build"), patch( + "giza.cli.commands.versions.zip_folder" ), patch( - "giza.commands.versions.update_sierra" + "giza.cli.commands.versions.update_sierra" ): result = invoke_cli_runner( [ @@ -427,13 +429,13 @@ def test_versions_update_server_error(): with patch.object( VersionsClient, "upload_cairo", side_effect=HTTPError ), patch.object(VersionsClient, "get", return_value=version), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ), patch( - "giza.commands.versions.scarb_build" + "giza.cli.commands.versions.scarb_build" ), patch( - "giza.commands.versions.zip_folder" + "giza.cli.commands.versions.zip_folder" ), patch( - "giza.commands.versions.update_sierra", + "giza.cli.commands.versions.update_sierra", ): result = invoke_cli_runner( [ @@ -455,7 +457,7 @@ def test_versions_update_server_error(): def test_versions_update_missing_ids(): with patch.object(VersionsClient, "update", side_effect=HTTPError), patch( - "giza.utils.exception_handling.get_response_info", return_value={} + "giza.cli.utils.exception_handling.get_response_info", return_value={} ): result = invoke_cli_runner( [ diff --git a/tests/commands/test_workspaces.py b/tests/commands/test_workspaces.py index 276b410..017216f 100644 --- a/tests/commands/test_workspaces.py +++ b/tests/commands/test_workspaces.py @@ -3,8 +3,8 @@ import pytest from requests import HTTPError -from giza.commands.workspaces import WorkspaceClient -from giza.schemas.workspaces import Workspace +from giza.cli.commands.workspaces import WorkspaceClient +from giza.cli.schemas.workspaces import Workspace from tests.conftest import invoke_cli_runner @@ -23,7 +23,7 @@ def test_workspaces_create(debug): ) as mock_create, patch.object( WorkspaceClient, "get", return_value=workspace_done ) as mock_get, patch( - "giza.commands.workspaces.time.sleep" + "giza.cli.commands.workspaces.time.sleep" ): args = ( ["workspaces", "create"] if not debug else ["workspaces", "create", debug] diff --git a/tests/conftest.py b/tests/conftest.py index 7459469..81e0233 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,7 @@ import pytest from typer.testing import CliRunner -from giza.cli import app +from giza.cli.cli import app def invoke_cli_runner(*args, **kwargs): diff --git a/tests/test_client.py b/tests/test_client.py index d84836e..91e2a34 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -7,7 +7,7 @@ from jose import ExpiredSignatureError from requests import HTTPError -from giza.client import ( +from giza.cli.client import ( DEFAULT_API_VERSION, MODEL_URL_HEADER, ApiClient, @@ -16,11 +16,11 @@ ProofsClient, VersionsClient, ) -from giza.schemas.jobs import Job, JobCreate -from giza.schemas.models import Model, ModelCreate, ModelUpdate -from giza.schemas.proofs import Proof -from giza.schemas.versions import Version, VersionCreate, VersionList -from giza.utils.enums import Framework, JobSize, JobStatus, VersionStatus +from giza.cli.schemas.jobs import Job, JobCreate +from giza.cli.schemas.models import Model, ModelCreate, ModelUpdate +from giza.cli.schemas.proofs import Proof +from giza.cli.schemas.versions import Version, VersionCreate, VersionList +from giza.cli.utils.enums import Framework, JobSize, JobStatus, VersionStatus class ResponseStub: diff --git a/tests/utils/test_decorators.py b/tests/utils/test_decorators.py index 2d2376d..a9ef87e 100644 --- a/tests/utils/test_decorators.py +++ b/tests/utils/test_decorators.py @@ -3,8 +3,8 @@ import pytest -from giza.client import GIZA_TOKEN_VARIABLE, ApiClient -from giza.utils.decorators import auth +from giza.cli.client import GIZA_TOKEN_VARIABLE, ApiClient +from giza.cli.utils.decorators import auth def get_client(): diff --git a/tests/utils/test_echo.py b/tests/utils/test_echo.py index d078dcc..1f2b624 100644 --- a/tests/utils/test_echo.py +++ b/tests/utils/test_echo.py @@ -2,7 +2,7 @@ import pytest -from giza.utils.echo import Echo +from giza.cli.utils.echo import Echo def test_format_message(): @@ -55,7 +55,7 @@ def test_echo_ok(): echo = Echo() message = "Dummy Message" formatted = f"[red]{message}[/red]" - with patch("giza.utils.echo.rich_print") as print_mock: + with patch("giza.cli.utils.echo.rich_print") as print_mock: echo.echo(message, formatted) print_mock.assert_called_once_with(formatted) @@ -68,7 +68,7 @@ def test_echo_ok_fallback(capsys): echo = Echo() message = "Dummy Message" formatted = f"[red]{message}[/red]" - with patch("giza.utils.echo.rich_print", side_effect=UnicodeError): + with patch("giza.cli.utils.echo.rich_print", side_effect=UnicodeError): echo.echo(message, formatted) captured = capsys.readouterr() @@ -84,7 +84,7 @@ def test_echo_methods(method): """ echo = Echo(debug=True) echo_func = getattr(echo, method) - with patch("giza.utils.echo.Echo.echo") as mock_echo: + with patch("giza.cli.utils.echo.Echo.echo") as mock_echo: echo_func("Dummy message") mock_echo.assert_called_once() @@ -95,7 +95,7 @@ def test_echo__call(): Test that the `__call__` soes indeed call the `info` method """ echo = Echo() - with patch("giza.utils.echo.Echo.info") as mock_echo: + with patch("giza.cli.utils.echo.Echo.info") as mock_echo: echo("Message") mock_echo.assert_called_once_with("Message") diff --git a/tests/utils/test_init.py b/tests/utils/test_init.py index defc430..617bd35 100644 --- a/tests/utils/test_init.py +++ b/tests/utils/test_init.py @@ -3,7 +3,7 @@ from requests import Response -from giza.utils import get_response_info +from giza.cli.utils import get_response_info def test_get_response_info_json(): diff --git a/tests/utils/test_misc.py b/tests/utils/test_misc.py index 5599330..ab24c48 100644 --- a/tests/utils/test_misc.py +++ b/tests/utils/test_misc.py @@ -1,7 +1,7 @@ import pytest -from giza.exceptions import PasswordError -from giza.utils.misc import _check_password_strength +from giza.cli.exceptions import PasswordError +from giza.cli.utils.misc import _check_password_strength # Test check strength password