Skip to content

Commit

Permalink
🐛 fix version control doesn't populate projects_to_products table (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
matusdrobuliak66 authored Sep 13, 2024
1 parent d5d06ee commit 5ebce8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pydantic.fields import Field
from pydantic.types import PositiveInt

from .._constants import RQ_PRODUCT_KEY
from ..projects.models import ProjectDict
from ..utils import compute_sha1_on_small_dataset, now_str
from ..version_control.errors import UserUndefinedError
Expand Down Expand Up @@ -209,6 +210,7 @@ async def get_or_create_runnable_projects(

vc_repo = VersionControlForMetaModeling.create_from_request(request)
assert vc_repo.user_id # nosec
product_name = request[RQ_PRODUCT_KEY]

try:
project: ProjectDict = await vc_repo.get_project(str(project_uuid))
Expand Down Expand Up @@ -303,6 +305,7 @@ async def get_or_create_runnable_projects(
branch_name=branch_name,
tag_name=tag_name,
tag_message=json_dumps(parameters),
product_name=product_name,
)

workcopy_project_id = await vc_repo.get_workcopy_project_id(repo_id, commit_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from typing import cast

from aiopg.sa.result import RowProxy
from models_library.products import ProductName
from models_library.projects import ProjectIDStr
from models_library.utils.fastapi_encoders import jsonable_encoder
from simcore_postgres_database.models.projects_to_products import projects_to_products

from ..projects.models import ProjectDict
from ..version_control.db import VersionControlRepository
Expand Down Expand Up @@ -92,6 +94,7 @@ async def create_workcopy_and_branch_from_commit(
branch_name: str,
tag_name: str,
tag_message: str,
product_name: ProductName,
) -> CommitID:
"""Creates a new branch with an explicit working copy 'project' on 'start_commit_id'"""
IS_INTERNAL_OPERATION = True
Expand Down Expand Up @@ -143,6 +146,12 @@ async def create_workcopy_and_branch_from_commit(
# creates runnable version in project
await self.ProjectsOrm(conn).insert(**project)

await conn.execute(
projects_to_products.insert().values(
project_uuid=project["uuid"], product_name=product_name
)
)

# create branch and set head to last commit_id
branch = await self.BranchesOrm(conn).insert(
returning_cols="id head_commit_id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ async def context_with_logged_user(client: TestClient, logged_user: UserInfoDict
await conn.execute(projects.delete())


@pytest.mark.skip(
"Test failing because `create_workcopy_and_branch_from_commit` is not inserting to projects_to_products table"
)
@pytest.mark.acceptance_test()
async def test_iterators_workflow(
client: TestClient,
Expand Down

0 comments on commit 5ebce8d

Please sign in to comment.