-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
3f0c8ea
commit 6b229f2
Showing
12 changed files
with
168 additions
and
29 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from sqlalchemy.orm import Session | ||
|
||
from app.services.user import user_service | ||
from netspresso.netspresso import NetsPresso | ||
from netspresso.utils.db.models.project import Project | ||
|
||
|
||
class ProjectService: | ||
def create_project(self, db: Session, project_name: str, api_key: str) -> Project: | ||
user = user_service.get_user_by_api_key(db=db, api_key=api_key) | ||
|
||
netspresso = NetsPresso(email=user.email, password=user.password) | ||
|
||
project = netspresso.create_project(project_name=project_name) | ||
|
||
return project | ||
|
||
|
||
project_service = ProjectService() |
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
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,34 @@ | ||
from netspresso.exceptions.common import AdditionalData, Origin, PyNPException | ||
|
||
|
||
class ProjectNameTooLongException(PyNPException): | ||
def __init__(self, max_length: int, actual_length: int): | ||
message = f"The project_name exceeds maximum length. Max: {max_length}, Actual: {actual_length}" | ||
super().__init__( | ||
data=AdditionalData(origin=Origin.CORE), | ||
error_code="PROJECT40001", | ||
name=self.__class__.__name__, | ||
message=message, | ||
) | ||
|
||
|
||
class ProjectAlreadyExistsException(PyNPException): | ||
def __init__(self, project_name: str, project_path: str): | ||
message = f"The project_name '{project_name}' already exists at '{project_path}'." | ||
super().__init__( | ||
data=AdditionalData(origin=Origin.CORE), | ||
error_code="PROJECT40901", | ||
name=self.__class__.__name__, | ||
message=message, | ||
) | ||
|
||
|
||
class ProjectSaveException(PyNPException): | ||
def __init__(self, error: Exception, project_name: str): | ||
message = f"Failed to save project '{project_name}' to the database: {str(error)}" | ||
super().__init__( | ||
data=AdditionalData(origin=Origin.REPOSITORY), | ||
error_code="PROJECT50001", | ||
name=self.__class__.__name__, | ||
message=message, | ||
) |
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,7 @@ | ||
from fastapi import status | ||
|
||
STATUS_MAP = { | ||
"PROJECT40001": status.HTTP_400_BAD_REQUEST, | ||
"PROJECT40901": status.HTTP_409_CONFLICT, | ||
"PROJECT50001": status.HTTP_500_INTERNAL_SERVER_ERROR, | ||
} |
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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ ignore = [ | |
"C901", | ||
"B008", | ||
"SIM115", | ||
"B904", | ||
] | ||
|
||
[tool.ruff.per-file-ignores] | ||
|