Skip to content

Commit

Permalink
fix(service): fix clone depth not being respected
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Jan 15, 2024
1 parent a7f4a22 commit 90a3db4
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 22 deletions.
4 changes: 2 additions & 2 deletions renku/ui/service/cache/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""Renku service project cache management."""
from typing import cast

from marshmallow import EXCLUDE
from marshmallow import RAISE

from renku.ui.service.cache.base import BaseCache
from renku.ui.service.cache.models.project import Project
Expand All @@ -34,7 +34,7 @@ def make_project(self, user, project_data, persist=True) -> Project:
"""Store user project metadata."""
project_data.update({"user_id": user.user_id})

project_obj: Project = cast(Project, self.project_schema.load(project_data, unknown=EXCLUDE))
project_obj: Project = cast(Project, self.project_schema.load(project_data, unknown=RAISE))

if persist:
project_obj.save()
Expand Down
2 changes: 1 addition & 1 deletion renku/ui/service/cache/serializers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ProjectSchema(CreationSchema, AccessSchema, MandatoryUserSchema):

project_id = fields.String(load_default=lambda: uuid.uuid4().hex)

clone_depth = fields.Integer()
clone_depth = fields.Integer(allow_none=True)
git_url = fields.String()

name = fields.String(required=True)
Expand Down
2 changes: 1 addition & 1 deletion renku/ui/service/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
OPENAPI_VERSION = "3.0.3"
API_VERSION = "v1"

PROJECT_CLONE_NO_DEPTH = -1
PROJECT_CLONE_NO_DEPTH = None
PROJECT_CLONE_DEPTH_DEFAULT = int(os.getenv("PROJECT_CLONE_DEPTH_DEFAULT", 1))
TEMPLATE_CLONE_DEPTH_DEFAULT = int(os.getenv("TEMPLATE_CLONE_DEPTH_DEFAULT", 0))

Expand Down
4 changes: 0 additions & 4 deletions renku/ui/service/controllers/templates_create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ def setup_new_project(self):
"name": self.ctx["project_name"],
"slug": self.ctx["project_name_stripped"],
"description": self.ctx["project_description"],
"fullname": self.ctx["fullname"],
"email": self.ctx["email"],
"owner": self.ctx["project_namespace"],
"token": self.ctx["token"],
"initialized": True,
"image": self.ctx["image"],
}
project = self.cache.make_project(self.user, new_project_data)

Expand Down
2 changes: 1 addition & 1 deletion renku/ui/service/gateways/repository_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _clone_project(
"owner": parsed_git_url.owner,
"name": parsed_git_url.name,
"slug": normalize_to_ascii(parsed_git_url.name),
"depth": PROJECT_CLONE_DEPTH_DEFAULT if shallow else None,
"clone_depth": PROJECT_CLONE_DEPTH_DEFAULT if shallow else None,
"branch": branch,
"git_url": git_url,
"user_id": user.user_id,
Expand Down
5 changes: 1 addition & 4 deletions tests/service/cache/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,8 @@ def test_service_cache_make_project(svc_client_cache):
project_data = {
"name": "renku-project-template",
"slug": "renku-project-template.git",
"depth": 1,
"clone_depth": 1,
"git_url": "https://github.com/SwissDataScienceCenter/renku-project-template.git",
"email": "[email protected]",
"fullname": "renku the frog",
"token": "None",
"owner": "SwissDataScienceCenter",
}
project = cache.make_project(user, project_data)
Expand Down
3 changes: 0 additions & 3 deletions tests/service/fixtures/service_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ def project_metadata(project) -> Generator[Tuple["RenkuProject", Dict[str, Any]]
"project_id": uuid.uuid4().hex,
"name": name,
"slug": normalize_to_ascii(name),
"fullname": "full project name",
"email": "[email protected]",
"owner": "me",
"token": "awesome token",
"git_url": "https://example.com/a/b.git",
"initialized": True,
"branch": "",
Expand Down
3 changes: 0 additions & 3 deletions tests/service/jobs/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ def test_job_constructor_lock(svc_client_with_user, service_job):
"project_id": uuid.uuid4().hex,
"name": "my-project",
"slug": "my-project",
"fullname": "full project name",
"email": "[email protected]",
"owner": "me",
"token": "awesome token",
"git_url": "[email protected]",
"initialized": True,
}
Expand Down
3 changes: 0 additions & 3 deletions tests/service/views/test_dataset_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,7 @@ def test_cached_import_dataset_job(doi, svc_client_cache, project):
"project_id": uuid.uuid4().hex,
"name": name,
"slug": normalize_to_ascii(name),
"fullname": "full project name",
"email": "[email protected]",
"owner": "me",
"token": "awesome token",
"git_url": "https://example.com/a/b.git",
"initialized": True,
}
Expand Down

0 comments on commit 90a3db4

Please sign in to comment.