-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for Protect project creation (#7)
- Loading branch information
Showing
6 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |