Skip to content

Commit

Permalink
Add get_projects function
Browse files Browse the repository at this point in the history
  • Loading branch information
Only-bottle committed Dec 6, 2024
1 parent 2c6f12d commit d6a14d2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion netspresso/netspresso.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Optional, Union
from typing import List, Optional, Union

from loguru import logger

Expand Down Expand Up @@ -80,6 +80,17 @@ def create_project(self, project_name: str, project_path: str = "./projects") ->
logger.error(f"Failed to save project '{project_name}' to the database: {e}")
raise

def get_projects(self) -> List[Project]:
try:
with get_db() as db:
projects = project_repository.get_all_by_user_id(db=db, user_id=self.user_info.user_id)

return projects

except Exception as e:
logger.error(f"Failed to get project list from the database: {e}")
raise

def trainer(
self, task: Optional[Union[str, Task]] = None, yaml_path: Optional[str] = None
) -> Trainer:
Expand Down

0 comments on commit d6a14d2

Please sign in to comment.