Skip to content

🎨 add project template type 🚨 (πŸ—ƒοΈ) #7677

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fdcb5b9
first commit
matusdrobuliak66 May 14, 2025
48ec669
Merge branch 'master' into add-template-type-to-projects
matusdrobuliak66 May 14, 2025
acef022
expose to ProjectGet
matusdrobuliak66 May 14, 2025
705ae27
fix
matusdrobuliak66 May 14, 2025
976c6eb
fix api server
matusdrobuliak66 May 14, 2025
b1e5bfb
fix tests
matusdrobuliak66 May 14, 2025
c94981d
fix tests
matusdrobuliak66 May 14, 2025
e373f4c
fix tests
matusdrobuliak66 May 14, 2025
8530b50
fix tests
matusdrobuliak66 May 14, 2025
8d33e2d
fix tests
matusdrobuliak66 May 14, 2025
569efa5
fix tests
matusdrobuliak66 May 14, 2025
2edcdda
fix
matusdrobuliak66 May 15, 2025
a837594
fix tests
matusdrobuliak66 May 15, 2025
9a7978b
fix tests
matusdrobuliak66 May 15, 2025
8452630
fix tests
matusdrobuliak66 May 15, 2025
a1d8d9a
fix tests
matusdrobuliak66 May 15, 2025
ab569a6
Merge branch 'master' into add-template-type-to-projects
matusdrobuliak66 May 15, 2025
a3e9745
fix tests
matusdrobuliak66 May 15, 2025
51e5e11
Merge branch 'add-template-type-to-projects' of github.com:matusdrobu…
matusdrobuliak66 May 15, 2025
f2dd7db
review @GitHK
matusdrobuliak66 May 15, 2025
5b4ff52
Merge branch 'master' into add-template-type-to-projects
matusdrobuliak66 May 15, 2025
4a42384
services/webserver api version: 0.64.0 β†’ 0.65.0
matusdrobuliak66 May 15, 2025
ab23499
Merge branch 'add-template-type-to-projects' of github.com:matusdrobu…
matusdrobuliak66 May 15, 2025
a2a0135
Merge branch 'master' into add-template-type-to-projects
matusdrobuliak66 May 15, 2025
cd6277a
fix
matusdrobuliak66 May 15, 2025
428799f
Merge branch 'add-template-type-to-projects' of github.com:matusdrobu…
matusdrobuliak66 May 15, 2025
0cfab55
fix
matusdrobuliak66 May 15, 2025
1729ed5
fix
matusdrobuliak66 May 15, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
from ..emails import LowerCaseEmailStr
from ..folders import FolderID
from ..groups import GroupID
from ..projects import ClassifierID, DateTimeStr, NodesDict, ProjectID
from ..projects import (
ClassifierID,
DateTimeStr,
NodesDict,
ProjectID,
ProjectTemplateType,
ProjectType,
)
from ..projects_access import AccessRights, GroupIDStr
from ..projects_state import ProjectState
from ..utils._original_fastapi_encoders import jsonable_encoder
Expand Down Expand Up @@ -106,6 +113,9 @@ class ProjectGet(OutputSchema):
description: str
thumbnail: HttpUrl | Literal[""]

type: ProjectType
template_type: ProjectTemplateType | None

workbench: NodesDict

prj_owner: LowerCaseEmailStr
Expand Down Expand Up @@ -153,6 +163,8 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
"name": "My Project",
"description": "This is a sample project",
"thumbnail": "https://example.com/thumbnail.png",
"type": "STANDARD",
"template_type": None,
"workbench": {},
"prj_owner": "[email protected]",
"access_rights": {},
Expand Down
31 changes: 30 additions & 1 deletion packages/models-library/src/models_library/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from datetime import datetime
from enum import Enum
from enum import Enum, auto
from typing import Annotated, Any, Final, TypeAlias
from uuid import UUID

Expand All @@ -25,6 +25,7 @@
empty_str_to_none_pre_validator,
none_to_empty_str_pre_validator,
)
from .utils.enums import StrAutoEnum

ProjectID: TypeAlias = UUID
CommitID: TypeAlias = int
Expand Down Expand Up @@ -52,6 +53,12 @@ class ProjectType(str, Enum):
STANDARD = "STANDARD"


class ProjectTemplateType(StrAutoEnum):
TEMPLATE = auto()
TUTORIAL = auto()
HYPERTOOL = auto()


class BaseProjectModel(BaseModel):
# Description of the project
uuid: Annotated[
Expand Down Expand Up @@ -108,6 +115,12 @@ class ProjectAtDB(BaseProjectModel):
project_type: Annotated[
ProjectType, Field(alias="type", description="The project type")
]
template_type: Annotated[
ProjectTemplateType | None,
Field(
examples=["TEMPLATE", "TUTORIAL", "HYPERTOOL", None],
),
]

prj_owner: Annotated[int | None, Field(description="The project owner id")]

Expand Down Expand Up @@ -165,6 +178,22 @@ class Project(BaseProjectModel):
# Project state (SEE projects_state.py)
state: ProjectState | None = None

# Type of project
type: Annotated[
ProjectType,
Field(
description="The project type",
examples=["TEMPLATE", "STANDARD"],
),
]
template_type: Annotated[
ProjectTemplateType | None,
Field(
alias="templateType",
examples=["TEMPLATE", "TUTORIAL", "HYPERTOOL", None],
),
]

# UI front-end fields (SEE projects_ui.py)
ui: dict[str, Any] | None = None
dev: dict[str, Any] | None = None
Expand Down
2 changes: 2 additions & 0 deletions packages/models-library/tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def minimal_project(faker: Faker) -> dict[str, Any]:
"creationDate": "2019-05-24T10:36:57.813Z",
"lastChangeDate": "2019-05-24T10:36:57.813Z",
"workbench": {},
"type": "STANDARD",
"templateType": None,
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""add templateType to projects

Revision ID: b39f2dc87ccd
Revises: fc1701bb7e93
Create Date: 2025-05-14 11:59:27.033449+00:00

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "b39f2dc87ccd"
down_revision = "fc1701bb7e93"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
# Create enum type first
project_template_type = sa.Enum(
"TEMPLATE", "TUTORIAL", "HYPERTOOL", name="projecttemplatetype"
)
project_template_type.create(op.get_bind())

op.add_column(
"projects",
sa.Column(
"template_type",
project_template_type,
nullable=True,
default=None,
),
)
# ### end Alembic commands ###
op.execute("UPDATE projects SET template_type='TEMPLATE' WHERE type='TEMPLATE'")


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("projects", "template_type")
# ### end Alembic commands ###
sa.Enum(name="projecttemplatetype").drop(op.get_bind())
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class ProjectType(enum.Enum):
STANDARD = "STANDARD"


class ProjectTemplateType(str, enum.Enum):
TEMPLATE = "TEMPLATE"
TUTORIAL = "TUTORIAL"
HYPERTOOL = "HYPERTOOL"


projects = sa.Table(
"projects",
metadata,
Expand All @@ -29,6 +35,13 @@ class ProjectType(enum.Enum):
default=ProjectType.STANDARD,
doc="Either standard or template types",
),
sa.Column(
"template_type",
sa.Enum(ProjectTemplateType),
nullable=True,
default=None,
doc="None if type is STANDARD, otherwise it is one of the ProjectTemplateType",
),
sa.Column(
"uuid",
sa.String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def request_desc(self) -> str:
},
"dev": None,
"workspace_id": None,
"type": "STANDARD",
"templateType": None,
"folder_id": None,
"trashedAt": None,
"trashedBy": None,
Expand Down Expand Up @@ -102,6 +104,8 @@ def request_desc(self) -> str:
"lastChangeDate": "2021-12-06T10:13:03.100Z",
"workbench": {},
"workspaceId": 123,
"type": "STANDARD",
"templateType": None,
"folderId": 2,
"accessRights": {"2": {"read": True, "write": True, "delete": True}},
"dev": {},
Expand Down Expand Up @@ -157,6 +161,8 @@ def request_desc(self) -> str:
"state": {"value": "NOT_STARTED"},
},
"workspace_id": None,
"type": "STANDARD",
"templateType": None,
"folder_id": None,
"trashedAt": None,
"trashedBy": None,
Expand Down Expand Up @@ -232,6 +238,8 @@ def request_desc(self) -> str:
"creationDate": "2021-12-06T10:13:03.100Z",
"lastChangeDate": "2021-12-06T10:13:07.347Z",
"workbench": {},
"type": "STANDARD",
"templateType": None,
"accessRights": {"2": {"read": True, "write": True, "delete": True}},
"dev": {},
"classifiers": [],
Expand Down Expand Up @@ -482,6 +490,8 @@ def request_desc(self) -> str:
"accessRights": {"2": {"read": True, "write": True, "delete": True}},
"dev": {},
"workspace_id": None,
"type": "STANDARD",
"templateType": None,
"folder_id": None,
"trashedAt": None,
"trashedBy": None,
Expand Down Expand Up @@ -684,6 +694,8 @@ def request_desc(self) -> str:
"classifiers": [],
"dev": {},
"workspace_id": None,
"type": "STANDARD",
"templateType": None,
"folder_id": None,
"trashedAt": None,
"trashed_by": None,
Expand Down Expand Up @@ -935,6 +947,8 @@ def request_desc(self) -> str:
"classifiers": [],
"dev": {},
"workspace_id": None,
"type": "STANDARD",
"templateType": None,
"folder_id": None,
"trashedAt": None,
"trashedBy": None,
Expand Down
Loading
Loading