Skip to content

Commit

Permalink
feat: Add support for Protect project creation (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
setu4993 authored Apr 8, 2024
1 parent 1e13e14 commit dab6f9f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
14 changes: 7 additions & 7 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 @@ -8,7 +8,7 @@ packages = [{include = "galileo_protect", from = "src"}]

[tool.poetry.dependencies]
python = "^3.8.1,<3.13"
galileo-core = "^0.9.3"
galileo-core = "^0.10.0"


[tool.poetry.group.test.dependencies]
Expand Down
1 change: 1 addition & 0 deletions src/galileo_protect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# flake8: noqa: F401
# ruff: noqa: F401
from galileo_protect.invoke import invoke
from galileo_protect.project import create_project

__version__ = "0.1.0"
19 changes: 19 additions & 0 deletions src/galileo_protect/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from typing import Optional

from galileo_core.helpers.project import create_project as core_create_project
from galileo_core.schemas.core.project import (
DEFAULT_PROJECT_NAME,
CreateProjectRequest,
ProjectResponse,
ProjectType,
)

from galileo_protect.helpers.config import ProtectConfig


def create_project(name: str = DEFAULT_PROJECT_NAME, config: Optional[ProtectConfig] = None) -> ProjectResponse:
config = config or ProtectConfig.get()
project = core_create_project(CreateProjectRequest(name=name, type=ProjectType.protect), config)
config.project_id = project.id
config.write()
return project
Empty file added src/galileo_protect/stage.py
Empty file.
23 changes: 23 additions & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from typing import Callable
from uuid import uuid4

from galileo_core.constants.routes import Routes as CoreRoutes
from galileo_core.schemas.core.project import DEFAULT_PROJECT_NAME, ProjectType
from requests_mock import POST

from galileo_protect.project import create_project


def test_create_project(set_validated_config: Callable, mock_request: Callable) -> None:
config = set_validated_config()
project_id = uuid4()
matcher = mock_request(
POST,
CoreRoutes.projects,
json={"id": str(project_id), "type": ProjectType.protect, "name": DEFAULT_PROJECT_NAME},
)
create_project(config=config)
assert matcher.called
# Verify that the project ID was set in the config.
assert config.project_id is not None
assert config.project_id == project_id

0 comments on commit dab6f9f

Please sign in to comment.