Skip to content

Commit 314786e

Browse files
authored
feat(svc): rename git_url to template_git_url and return git_url on all endpoints (#3646)
1 parent 4726f66 commit 314786e

23 files changed

+329
-105
lines changed

renku/ui/service/cache/models/project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class Project(Model):
5656
owner = TextField()
5757
initialized = BooleanField()
5858
commit_sha = TextField()
59-
branch = TextField()
6059

6160
@property
6261
def abs_path(self) -> Path:

renku/ui/service/controllers/datasets_edit.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def to_response(self):
140140
"edited": edited,
141141
"warnings": warnings,
142142
"remote_branch": remote_branch,
143+
"git_url": self.ctx["git_url"],
143144
}
144145

145146
return result_response(self.RESPONSE_SERIALIZER, response)

renku/ui/service/controllers/datasets_unlink.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def to_response(self):
7777
response = {
7878
"unlinked": [record.entity.path for record in op_result],
7979
"remote_branch": remote_branch,
80+
"git_url": self.ctx["git_url"],
8081
}
8182

8283
return result_response(self.RESPONSE_SERIALIZER, response)

renku/ui/service/controllers/templates_create_project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def default_metadata(self):
6565
"""Default metadata for project creation."""
6666

6767
metadata = {
68-
"__template_source__": self.ctx["git_url"],
69-
"__template_ref__": self.ctx["branch"],
68+
"__template_source__": self.ctx["template_git_url"],
69+
"__template_ref__": self.ctx["ref"],
7070
"__template_id__": self.ctx["identifier"],
7171
"__namespace__": self.ctx["project_namespace"],
7272
"__repository__": self.ctx["project_repository"],
@@ -117,7 +117,7 @@ def setup_new_project(self):
117117

118118
def setup_template(self):
119119
"""Reads template manifest."""
120-
templates_source = fetch_templates_source(source=self.ctx["git_url"], reference=self.ctx["branch"])
120+
templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["ref"])
121121
identifier = self.ctx["identifier"]
122122
try:
123123
self.template = templates_source.get_template(id=identifier, reference=None)

renku/ui/service/controllers/templates_read_manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def template_manifest(self):
4949
"""Reads template manifest."""
5050
from PIL import Image
5151

52-
templates_source = fetch_templates_source(source=self.ctx["git_url"], reference=self.ctx["branch"])
52+
templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["ref"])
5353
manifest = templates_source.manifest.get_raw_content()
5454

5555
# NOTE: convert icons to base64
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright Swiss Data Science Center (SDSC). A partnership between
2+
# École Polytechnique Fédérale de Lausanne (EPFL) and
3+
# Eidgenössische Technische Hochschule Zürich (ETHZ).
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
"""Renku service templates controller."""
17+
18+
from renku.ui.service.controllers.templates_create_project import TemplatesCreateProjectCtrl
19+
from renku.ui.service.controllers.templates_read_manifest import TemplatesReadManifestCtrl
20+
from renku.ui.service.serializers.v1.templates import ManifestTemplatesRequest_v2_2, ProjectTemplateRequest_v2_2
21+
22+
23+
class TemplatesCreateProjectCtrl_v2_2(TemplatesCreateProjectCtrl):
24+
"""V2.2 create project controller."""
25+
26+
REQUEST_SERIALIZER = ProjectTemplateRequest_v2_2() # type: ignore
27+
28+
29+
class TemplatesReadManifestCtrl_v2_2(TemplatesReadManifestCtrl):
30+
"""V2.2 read manifest controller."""
31+
32+
REQUEST_SERIALIZER = ManifestTemplatesRequest_v2_2() # type: ignore

renku/ui/service/serializers/cache.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
AsyncSchema,
3232
ErrorResponse,
3333
FileDetailsSchema,
34+
GitUrlResponseMixin,
3435
RemoteRepositorySchema,
3536
RenkuSyncSchema,
3637
)
@@ -240,7 +241,7 @@ class ProjectMigrateRequest(AsyncSchema, RemoteRepositorySchema):
240241
skip_migrations = fields.Boolean(dump_default=False)
241242

242243

243-
class ProjectMigrateResponse(RenkuSyncSchema):
244+
class ProjectMigrateResponse(RenkuSyncSchema, GitUrlResponseMixin):
244245
"""Response schema for project migrate."""
245246

246247
was_migrated = fields.Boolean()
@@ -375,7 +376,7 @@ def get_obj_type(self, obj):
375376
return "error"
376377

377378

378-
class ProjectMigrationCheckResponse(Schema):
379+
class ProjectMigrationCheckResponse(GitUrlResponseMixin):
379380
"""Response schema for project migration check."""
380381

381382
project_supported = fields.Boolean(

renku/ui/service/serializers/common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class RemoteRepositoryBaseSchema(Schema):
2929
"""Schema for tracking a remote repository."""
3030

31-
git_url = fields.String(metadata={"description": "Remote git repository url."})
31+
git_url = fields.String(required=True, metadata={"description": "Remote git repository url."})
3232

3333
@pre_load
3434
def normalize_url(self, data, **_):
@@ -168,3 +168,9 @@ class ErrorResponse(Schema):
168168
userReference = fields.String()
169169
devReference = fields.String()
170170
sentry = fields.String()
171+
172+
173+
class GitUrlResponseMixin(Schema):
174+
"""Response containing a git url."""
175+
176+
git_url = fields.String(required=True, metadata={"description": "Remote git repository url."})

renku/ui/service/serializers/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from renku.ui.service.serializers.common import (
2121
AsyncSchema,
2222
GitCommitSHA,
23+
GitUrlResponseMixin,
2324
MigrateSchema,
2425
RemoteRepositorySchema,
2526
RenkuSyncSchema,
@@ -37,7 +38,7 @@ class ConfigShowSchema(Schema):
3738
config = fields.Dict(metadata={"description": "Dictionary of configuration items."}, required=True)
3839

3940

40-
class ConfigShowResponse(ConfigShowSchema):
41+
class ConfigShowResponse(ConfigShowSchema, GitUrlResponseMixin):
4142
"""Response schema for project config show."""
4243

4344
default = fields.Dict(metadata={"description": "Dictionary of default configuration items."}, required=True)
@@ -53,7 +54,7 @@ class ConfigSetRequest(AsyncSchema, ConfigShowSchema, MigrateSchema, RemoteRepos
5354
"""Request schema for config set."""
5455

5556

56-
class ConfigSetResponse(ConfigShowSchema, RenkuSyncSchema):
57+
class ConfigSetResponse(ConfigShowSchema, RenkuSyncSchema, GitUrlResponseMixin):
5758
"""Response schema for project config set."""
5859

5960
default = fields.Dict(metadata={"description": "Dictionary of default configuration items."})

renku/ui/service/serializers/datasets.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from renku.ui.service.serializers.common import (
2424
AsyncSchema,
2525
GitCommitSHA,
26+
GitUrlResponseMixin,
2627
JobDetailsResponse,
2728
MigrateSchema,
2829
RemoteRepositorySchema,
@@ -55,7 +56,7 @@ class DatasetCreateRequest(AsyncSchema, DatasetDetailsRequest, RemoteRepositoryS
5556
)
5657

5758

58-
class DatasetCreateResponse(DatasetSlugSchema, RenkuSyncSchema):
59+
class DatasetCreateResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
5960
"""Response schema for a dataset create view."""
6061

6162

@@ -69,7 +70,7 @@ class DatasetRemoveRequest(AsyncSchema, DatasetSlugSchema, RemoteRepositorySchem
6970
"""Request schema for a dataset remove."""
7071

7172

72-
class DatasetRemoveResponse(DatasetSlugSchema, RenkuSyncSchema):
73+
class DatasetRemoveResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
7374
"""Response schema for a dataset create view."""
7475

7576

@@ -108,7 +109,7 @@ def check_files(self, data, **kwargs):
108109
return data
109110

110111

111-
class DatasetAddResponse(DatasetSlugSchema, RenkuSyncSchema):
112+
class DatasetAddResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
112113
"""Response schema for a dataset add file view."""
113114

114115
project_id = fields.String(required=True)
@@ -131,7 +132,7 @@ class DatasetDetailsResponse(DatasetDetails):
131132
images = fields.List(fields.Nested(ImageObject))
132133

133134

134-
class DatasetListResponse(Schema):
135+
class DatasetListResponse(GitUrlResponseMixin):
135136
"""Response schema for dataset list view."""
136137

137138
datasets = fields.List(fields.Nested(DatasetDetailsResponse), required=True)
@@ -156,7 +157,7 @@ class DatasetFileDetails(Schema):
156157
added = fields.DateTime()
157158

158159

159-
class DatasetFilesListResponse(DatasetSlugSchema):
160+
class DatasetFilesListResponse(DatasetSlugSchema, GitUrlResponseMixin):
160161
"""Response schema for dataset files list view."""
161162

162163
files = fields.List(fields.Nested(DatasetFileDetails), required=True)
@@ -212,7 +213,7 @@ class DatasetEditRequest(
212213
)
213214

214215

215-
class DatasetEditResponse(RenkuSyncSchema):
216+
class DatasetEditResponse(RenkuSyncSchema, GitUrlResponseMixin):
216217
"""Dataset edit metadata response."""
217218

218219
edited = fields.Dict(required=True)
@@ -243,7 +244,7 @@ def check_filters(self, data, **kwargs):
243244
return data
244245

245246

246-
class DatasetUnlinkResponse(RenkuSyncSchema):
247+
class DatasetUnlinkResponse(RenkuSyncSchema, GitUrlResponseMixin):
247248
"""Dataset unlink files response."""
248249

249250
unlinked = fields.List(fields.String())

0 commit comments

Comments
 (0)