Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: 1155 implement project backend #1158

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b5b6762
release updates
longshuicy Jul 22, 2024
d655342
Merge branch 'main' into release/v2.0-beta-3
longshuicy Jul 24, 2024
4d136e8
1147 clowder 2 helm chart clean up (#1148)
longshuicy Jul 25, 2024
91ad4e7
turn off default extractors
longshuicy Jul 26, 2024
b3395df
initial commit new model
tcnichol Jul 29, 2024
1f73ead
adding db, out, in, etc
tcnichol Jul 29, 2024
d4c3904
save and get methods
tcnichol Jul 29, 2024
1c83600
get method
tcnichol Jul 29, 2024
a89ebbb
add users to project
tcnichol Jul 29, 2024
a15adad
adding to do
tcnichol Jul 29, 2024
f5e69b3
add a remove project member
tcnichol Jul 29, 2024
3b2cba9
routes for deleting and adding, removing members
tcnichol Jul 29, 2024
250f22a
"project" not "group"
tcnichol Jul 29, 2024
4dc5b94
methods for adding and removing datasets from projects
tcnichol Jul 30, 2024
9252bef
remove license
tcnichol Jul 30, 2024
6291cc0
adding and removing folders and files
tcnichol Jul 30, 2024
a679d7c
only add if a file, folder, dataset id not in the project already
tcnichol Jul 30, 2024
9f2c8ac
beginning project tests
tcnichol Jul 30, 2024
7a8b3d2
add test add dataset to project
tcnichol Jul 30, 2024
0bd2f4b
formatting
tcnichol Jul 30, 2024
5c508e2
adding routes to main
tcnichol Jul 30, 2024
91e14cb
get project works
tcnichol Jul 30, 2024
daf3ed0
fixing add dataset to project
tcnichol Jul 30, 2024
333f7fb
default value empty lists not none
tcnichol Jul 30, 2024
8faab21
fixing the folder part
tcnichol Jul 30, 2024
d4d8a7e
fixing filex
tcnichol Jul 30, 2024
cf1b537
add pydantic id not string
tcnichol Jul 30, 2024
67f5f40
file not folder
tcnichol Jul 30, 2024
379b605
formatting
tcnichol Jul 30, 2024
dfcdbde
Merge branch 'main' into release/v2.0-beta-3
longshuicy Aug 13, 2024
1a3df5a
Merge remote-tracking branch 'origin/release/v2.0-beta-3' into 1155-i…
tcnichol Aug 13, 2024
9fed4de
test project needs a creator
tcnichol Aug 13, 2024
4e9476e
ran pre commit
tcnichol Aug 13, 2024
7575fee
codegen
tcnichol Aug 13, 2024
36887c8
codegen
tcnichol Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .run/Python tests in tests.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<module name="clowder2" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="SDK_HOME" value="$USER_HOME$/.virtualenvs/clowder2-Ai7Xc8E9/bin/python" />
<option name="SDK_NAME" value="Python 3.7 (clowder2-Ai7Xc8E9)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/backend/app/tests" />
<option name="IS_MODULE_SDK" value="true" />
<option name="IS_MODULE_SDK" value="false" />
Copy link
Member Author

@longshuicy longshuicy Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might've accidentally committed the pycharm setting

<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
Expand All @@ -14,4 +15,4 @@
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
</component>
</component>
8 changes: 8 additions & 0 deletions backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
VisualizationDataDBViewList,
VisualizationDataFreezeDB,
)
from app.models.project import ProjectDB
from app.routers import (
authentication,
authorization,
Expand Down Expand Up @@ -66,6 +67,7 @@
thumbnails,
users,
visualization,
projects,
)

# setup loggers
Expand Down Expand Up @@ -250,6 +252,11 @@
prefix="/public_thumbnails",
tags=["public_thumbnails"],
)
api_router.include_router(
projects.router,
prefix="/projects",
tags=["projects"],
)
api_router.include_router(
licenses.router,
prefix="/licenses",
Expand Down Expand Up @@ -315,6 +322,7 @@ async def startup_beanie():
ThumbnailFreezeDB,
ThumbnailDBViewList,
LicenseDB,
ProjectDB,
],
recreate_views=True,
)
Expand Down
42 changes: 42 additions & 0 deletions backend/app/models/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from datetime import datetime
from enum import Enum, auto
from typing import List, Optional

import pymongo
from app.models.authorization import AuthorizationDB, RoleType
from app.models.groups import GroupOut
from app.models.users import UserOut
from beanie import Document, PydanticObjectId, View
from pydantic import BaseModel, Field


class Member(BaseModel):
user: UserOut
editor: bool = False


class ProjectBase(BaseModel):
id: PydanticObjectId = Field(default_factory=PydanticObjectId, alias="_id")
name: str
description: Optional[str] = None
created: datetime = Field(default_factory=datetime.utcnow)
modified: datetime = Field(default_factory=datetime.utcnow)
dataset_ids: Optional[List[PydanticObjectId]] = []
folder_ids: Optional[List[PydanticObjectId]] = []
file_ids: Optional[List[PydanticObjectId]] = []
creator: UserOut
users: List[Member] = []


class ProjectDB(Document, ProjectBase):
class Settings:
name = "projects"


class ProjectIn(ProjectBase):
pass


class ProjectOut(ProjectDB):
class Config:
fields = {"id": "id"}
Loading
Loading