Skip to content

Commit

Permalink
add git_url return parameter in core svc
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius authored and Ralf Grubenmann committed Oct 20, 2023
1 parent 50c68f0 commit 05446b4
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 76 deletions.
1 change: 0 additions & 1 deletion renku/ui/service/cache/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class Project(Model):
owner = TextField()
initialized = BooleanField()
commit_sha = TextField()
branch = TextField()

@property
def abs_path(self) -> Path:
Expand Down
1 change: 1 addition & 0 deletions renku/ui/service/controllers/datasets_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def to_response(self):
"edited": edited,
"warnings": warnings,
"remote_branch": remote_branch,
"git_url": self.ctx["git_url"],
}

return result_response(self.RESPONSE_SERIALIZER, response)
1 change: 1 addition & 0 deletions renku/ui/service/controllers/datasets_unlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def to_response(self):
response = {
"unlinked": [record.entity.path for record in op_result],
"remote_branch": remote_branch,
"git_url": self.ctx["git_url"],
}

return result_response(self.RESPONSE_SERIALIZER, response)
5 changes: 3 additions & 2 deletions renku/ui/service/serializers/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
AsyncSchema,
ErrorResponse,
FileDetailsSchema,
GitUrlResponseMixin,
RemoteRepositorySchema,
RenkuSyncSchema,
)
Expand Down Expand Up @@ -240,7 +241,7 @@ class ProjectMigrateRequest(AsyncSchema, RemoteRepositorySchema):
skip_migrations = fields.Boolean(dump_default=False)


class ProjectMigrateResponse(RenkuSyncSchema):
class ProjectMigrateResponse(RenkuSyncSchema, GitUrlResponseMixin):
"""Response schema for project migrate."""

was_migrated = fields.Boolean()
Expand Down Expand Up @@ -375,7 +376,7 @@ def get_obj_type(self, obj):
return "error"


class ProjectMigrationCheckResponse(Schema):
class ProjectMigrationCheckResponse(GitUrlResponseMixin):
"""Response schema for project migration check."""

project_supported = fields.Boolean(
Expand Down
6 changes: 6 additions & 0 deletions renku/ui/service/serializers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,9 @@ class ErrorResponse(Schema):
userReference = fields.String()
devReference = fields.String()
sentry = fields.String()


class GitUrlResponseMixin(Schema):
"""Response containing a git url."""

git_url = fields.String(required=True, metadata={"description": "Remote git repository url."})
5 changes: 3 additions & 2 deletions renku/ui/service/serializers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from renku.ui.service.serializers.common import (
AsyncSchema,
GitCommitSHA,
GitUrlResponseMixin,
MigrateSchema,
RemoteRepositorySchema,
RenkuSyncSchema,
Expand All @@ -37,7 +38,7 @@ class ConfigShowSchema(Schema):
config = fields.Dict(metadata={"description": "Dictionary of configuration items."}, required=True)


class ConfigShowResponse(ConfigShowSchema):
class ConfigShowResponse(ConfigShowSchema, GitUrlResponseMixin):
"""Response schema for project config show."""

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


class ConfigSetResponse(ConfigShowSchema, RenkuSyncSchema):
class ConfigSetResponse(ConfigShowSchema, RenkuSyncSchema, GitUrlResponseMixin):
"""Response schema for project config set."""

default = fields.Dict(metadata={"description": "Dictionary of default configuration items."})
Expand Down
15 changes: 8 additions & 7 deletions renku/ui/service/serializers/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from renku.ui.service.serializers.common import (
AsyncSchema,
GitCommitSHA,
GitUrlResponseMixin,
JobDetailsResponse,
MigrateSchema,
RemoteRepositorySchema,
Expand Down Expand Up @@ -55,7 +56,7 @@ class DatasetCreateRequest(AsyncSchema, DatasetDetailsRequest, RemoteRepositoryS
)


class DatasetCreateResponse(DatasetSlugSchema, RenkuSyncSchema):
class DatasetCreateResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
"""Response schema for a dataset create view."""


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


class DatasetRemoveResponse(DatasetSlugSchema, RenkuSyncSchema):
class DatasetRemoveResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
"""Response schema for a dataset create view."""


Expand Down Expand Up @@ -108,7 +109,7 @@ def check_files(self, data, **kwargs):
return data


class DatasetAddResponse(DatasetSlugSchema, RenkuSyncSchema):
class DatasetAddResponse(DatasetSlugSchema, RenkuSyncSchema, GitUrlResponseMixin):
"""Response schema for a dataset add file view."""

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


class DatasetListResponse(Schema):
class DatasetListResponse(GitUrlResponseMixin):
"""Response schema for dataset list view."""

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


class DatasetFilesListResponse(DatasetSlugSchema):
class DatasetFilesListResponse(DatasetSlugSchema, GitUrlResponseMixin):
"""Response schema for dataset files list view."""

files = fields.List(fields.Nested(DatasetFileDetails), required=True)
Expand Down Expand Up @@ -212,7 +213,7 @@ class DatasetEditRequest(
)


class DatasetEditResponse(RenkuSyncSchema):
class DatasetEditResponse(RenkuSyncSchema, GitUrlResponseMixin):
"""Dataset edit metadata response."""

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


class DatasetUnlinkResponse(RenkuSyncSchema):
class DatasetUnlinkResponse(RenkuSyncSchema, GitUrlResponseMixin):
"""Dataset unlink files response."""

unlinked = fields.List(fields.String())
Expand Down
3 changes: 2 additions & 1 deletion renku/ui/service/serializers/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from renku.domain_model.dataset import ImageObjectRequestJson
from renku.ui.service.config import TEMPLATE_CLONE_DEPTH_DEFAULT
from renku.ui.service.errors import UserRepoUrlInvalidError
from renku.ui.service.serializers.common import GitUrlResponseMixin
from renku.ui.service.serializers.rpc import JsonRPCResponse
from renku.ui.service.utils import normalize_git_url

Expand Down Expand Up @@ -154,7 +155,7 @@ class ManifestTemplatesResponseRPC(JsonRPCResponse):
result = fields.Nested(ManifestTemplatesResponse)


class ProjectTemplateResponse(Schema):
class ProjectTemplateResponse(GitUrlResponseMixin):
"""Response schema for dataset list view."""

url = fields.String(required=True)
Expand Down
8 changes: 4 additions & 4 deletions renku/ui/service/serializers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from renku.domain_model.dataset import DatasetCreatorsJson
from renku.infrastructure.persistent import Persistent
from renku.ui.cli.utils.plugins import get_supported_formats
from renku.ui.service.serializers.common import GitCommitSHA, RemoteRepositorySchema
from renku.ui.service.serializers.common import GitCommitSHA, GitUrlResponseMixin, RemoteRepositorySchema
from renku.ui.service.serializers.rpc import JsonRPCResponse


Expand Down Expand Up @@ -73,7 +73,7 @@ class WorflowPlanEntryResponse(AbstractPlanResponse):
children = fields.List(fields.String)


class WorkflowPlansListResponse(Schema):
class WorkflowPlansListResponse(GitUrlResponseMixin):
"""Response schema for plan list view."""

plans = fields.List(fields.Nested(WorflowPlanEntryResponse), required=True)
Expand Down Expand Up @@ -136,7 +136,7 @@ class ParameterSchema(ParameterBaseSchema):
pass


class PlanDetailsResponse(AbstractPlanResponse):
class PlanDetailsResponse(AbstractPlanResponse, GitUrlResponseMixin):
"""Schema for Plan details."""

last_executed = fields.DateTime()
Expand Down Expand Up @@ -190,7 +190,7 @@ class LinkSchema(Schema):
sink_entries = fields.List(fields.Nested(ParameterTargetSchema), data_key="sinks")


class CompositePlanDetailsResponse(AbstractPlanResponse):
class CompositePlanDetailsResponse(AbstractPlanResponse, GitUrlResponseMixin):
"""Schema for Plan details."""

steps = fields.List(fields.Nested(PlanReferenceSchema), data_key="plans")
Expand Down
9 changes: 3 additions & 6 deletions renku/ui/service/views/api_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ def add_url_rule(
V1_5 = ApiVersion("1.5")
V2_0 = ApiVersion("2.0")
V2_1 = ApiVersion("2.1")
V2_2 = ApiVersion("2.2")
V2_3 = ApiVersion("2.3", is_base_version=True)
V2_2 = ApiVersion("2.2", is_base_version=True)

VERSIONS_FROM_V2_3 = [V2_3]
VERSIONS_FROM_V2_2 = [V2_2] + VERSIONS_FROM_V2_3
VERSIONS_FROM_V2_2 = [V2_2]
VERSIONS_FROM_V2_1 = [V2_1] + VERSIONS_FROM_V2_2
VERSIONS_FROM_V2_0 = [V2_0] + VERSIONS_FROM_V2_1
VERSIONS_FROM_V1_5 = [V1_5] + VERSIONS_FROM_V2_0
Expand All @@ -78,7 +76,6 @@ def add_url_rule(
VERSIONS_BEFORE_1_1 = [V1_0]
VERSIONS_BEFORE_2_0 = [V1_1, V1_2, V1_3, V1_4, V1_5] + VERSIONS_BEFORE_1_1
VERSIONS_BEFORE_2_2 = [V2_0, V2_1] + VERSIONS_BEFORE_2_0
VERSIONS_BEFORE_2_3 = [V2_3] + VERSIONS_BEFORE_2_2

MINIMUM_VERSION = V1_0
MAXIMUM_VERSION = V2_3
MAXIMUM_VERSION = V2_2
6 changes: 3 additions & 3 deletions renku/ui/service/views/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from renku.ui.service.config import SERVICE_PREFIX
from renku.ui.service.controllers.templates_create_project import TemplatesCreateProjectCtrl
from renku.ui.service.controllers.templates_read_manifest import TemplatesReadManifestCtrl
from renku.ui.service.views.api_versions import VERSIONS_FROM_V2_3, VersionedBlueprint
from renku.ui.service.views.api_versions import VERSIONS_FROM_V2_2, VersionedBlueprint
from renku.ui.service.views.decorators import accepts_json, requires_cache, requires_identity
from renku.ui.service.views.error_handlers import (
handle_common_except,
Expand All @@ -33,7 +33,7 @@


@templates_blueprint.route(
"/templates.read_manifest", methods=["GET"], provide_automatic_options=False, versions=VERSIONS_FROM_V2_3
"/templates.read_manifest", methods=["GET"], provide_automatic_options=False, versions=VERSIONS_FROM_V2_2
)
@handle_common_except
@handle_templates_read_errors
Expand Down Expand Up @@ -73,7 +73,7 @@ def read_manifest_from_template(user_data, cache):


@templates_blueprint.route(
"/templates.create_project", methods=["POST"], provide_automatic_options=False, versions=VERSIONS_FROM_V2_3
"/templates.create_project", methods=["POST"], provide_automatic_options=False, versions=VERSIONS_FROM_V2_2
)
@handle_common_except
@handle_templates_create_errors
Expand Down
2 changes: 1 addition & 1 deletion tests/service/jobs/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_delay_config_set(svc_client_cache, it_remote_repo_url, view_user_data):
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"config", "remote_branch"} == set(updated_job.ctrl_result["result"].keys())
assert {"config", "remote_branch", "git_url"} == set(updated_job.ctrl_result["result"].keys())


@pytest.mark.service
Expand Down
14 changes: 7 additions & 7 deletions tests/service/jobs/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def test_dataset_add_remote_file(url, svc_client_with_repo):
response = svc_client.post("/datasets.add", data=json.dumps(payload), headers=headers)

assert_rpc_response(response)
assert {"files", "slug", "project_id", "remote_branch"} == set(response.json["result"].keys())
assert {"files", "slug", "project_id", "remote_branch", "git_url"} == set(response.json["result"].keys())

dest = make_project_path(
user,
Expand Down Expand Up @@ -324,7 +324,7 @@ def test_delay_add_file_job(svc_client_cache, it_remote_repo_url_temp_branch, vi
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"remote_branch", "project_id", "files", "slug"} == updated_job.ctrl_result["result"].keys()
assert {"remote_branch", "project_id", "files", "slug", "git_url"} == updated_job.ctrl_result["result"].keys()


@pytest.mark.service
Expand Down Expand Up @@ -402,7 +402,7 @@ def test_delay_create_dataset_job(svc_client_cache, it_remote_repo_url_temp_bran
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"slug", "remote_branch"} == updated_job.ctrl_result["result"].keys()
assert {"slug", "remote_branch", "git_url"} == updated_job.ctrl_result["result"].keys()


@pytest.mark.service
Expand Down Expand Up @@ -469,7 +469,7 @@ def test_delay_remove_dataset_job(svc_client_cache, it_remote_repo_url_temp_bran
updated_job = delayed_ctrl_job(context, view_user_data, delete_job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"slug", "remote_branch"} == updated_job.ctrl_result["result"].keys()
assert {"slug", "remote_branch", "git_url"} == updated_job.ctrl_result["result"].keys()


@pytest.mark.service
Expand Down Expand Up @@ -538,7 +538,7 @@ def test_delay_edit_dataset_job(svc_client_cache, it_remote_repo_url_temp_branch
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"warnings", "remote_branch", "edited"} == updated_job.ctrl_result["result"].keys()
assert {"warnings", "remote_branch", "edited", "git_url"} == updated_job.ctrl_result["result"].keys()
assert {"name"} == updated_job.ctrl_result["result"]["edited"].keys()


Expand Down Expand Up @@ -610,7 +610,7 @@ def test_delay_unlink_dataset_job(svc_client_cache, it_remote_repo_url_temp_bran
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"unlinked", "remote_branch"} == updated_job.ctrl_result["result"].keys()
assert {"unlinked", "remote_branch", "git_url"} == updated_job.ctrl_result["result"].keys()
assert ["data/data1"] == updated_job.ctrl_result["result"]["unlinked"]


Expand Down Expand Up @@ -674,7 +674,7 @@ def test_unlink_dataset_sync(svc_client_cache, it_remote_repo_url_temp_branch, v
updated_job = delayed_ctrl_job(context, view_user_data, job.job_id, renku_module, renku_ctrl)

assert updated_job
assert {"unlinked", "remote_branch"} == updated_job.ctrl_result["result"].keys()
assert {"unlinked", "remote_branch", "git_url"} == updated_job.ctrl_result["result"].keys()
assert ["data/data1"] == updated_job.ctrl_result["result"]["unlinked"]


Expand Down
2 changes: 1 addition & 1 deletion tests/service/views/test_cache_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ def test_cache_gets_synchronized(local_remote_repository, directory_tree, quick_
assert response
assert 200 == response.status_code

assert {"datasets"} == set(response.json["result"].keys()), response.json
assert {"datasets", "git_url"} == set(response.json["result"].keys()), response.json
assert 1 == len(response.json["result"]["datasets"])

payload = {
Expand Down
Loading

0 comments on commit 05446b4

Please sign in to comment.