Skip to content

Commit

Permalink
Add docstring to create_project, get_projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Only-bottle committed Dec 7, 2024
1 parent 61687fa commit 3ce3515
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions netspresso/netspresso.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,31 @@ def get_user(self) -> UserResponse:
return user_info

def create_project(self, project_name: str, project_path: str = "./projects") -> Project:
"""
Create a new project with the specified name and path.
This method creates a project directory structure on the file system
and saves the project information in the database. It also handles
scenarios where the project name is too long or already exists.
Args:
project_name (str): The name of the project to create.
Must not exceed 30 characters.
project_path (str, optional): The base path where the project
will be created. Defaults to "./projects".
Returns:
Project: The created project object containing information
such as project name, user ID, and absolute path.
Raises:
ProjectNameTooLongException: If the `project_name` exceeds the
maximum allowed length of 30 characters.
ProjectAlreadyExistsException: If a project with the same name
already exists at the specified `project_path`.
ProjectSaveException: If an error occurs while saving the project
to the database.
"""
if len(project_name) > 30:
raise ProjectNameTooLongException(max_length=30, actual_length=len(project_name))

Expand Down Expand Up @@ -93,6 +118,18 @@ def create_project(self, project_name: str, project_path: str = "./projects") ->
db and db.close()

def get_projects(self) -> List[Project]:
"""
Retrieve all projects associated with the current user.
This method fetches project information from the database for
the user identified by `self.user_info.user_id`.
Returns:
List[Project]: A list of projects associated with the current user.
Raises:
Exception: If an error occurs while querying the database.
"""
db = None
try:
db = SessionLocal()
Expand Down

0 comments on commit 3ce3515

Please sign in to comment.