Skip to content
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

feat(service): improve migrations_check performance #2443

Merged
merged 44 commits into from Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
99b1f3d
feat(service): improve formatting or migrationscheck response
Panaetius Jun 2, 2021
39bfc40
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 8, 2021
002062d
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 10, 2021
8fa15df
chore: enable extra values on deploy
rokroskar Jun 14, 2021
8911d57
fix(service): do not require json on get
rokroskar Jun 14, 2021
9b491ae
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 16, 2021
d9f4bb6
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 17, 2021
5810c6b
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 21, 2021
434705f
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 21, 2021
259ec8c
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jun 25, 2021
eb37031
update documentation
Panaetius Jul 5, 2021
748daac
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Jul 5, 2021
0368557
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Sep 16, 2021
795e8a3
fix merge problems
Panaetius Sep 16, 2021
fdb01c8
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Sep 17, 2021
509b2e3
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Nov 1, 2021
d8d6921
change new endpoint to api version 1.0
Panaetius Nov 1, 2021
f99fb98
fix IT
Panaetius Nov 1, 2021
51f62b2
Merge branch 'master' into 2048-finegrained-migration-information
Panaetius Nov 5, 2021
c915605
Merge branch 'master' into 2048-finegrained-migration-information
rokroskar Nov 9, 2021
5b57b8a
address PR comments
Panaetius Nov 15, 2021
948f676
feat(service): improve migrations_check peformance
Panaetius Nov 2, 2021
a8b1053
feat(core): add renku workflow loop command (#2425)
vigsterkr Nov 10, 2021
8bf87fd
fix(core): encoding format for output (#2459)
vigsterkr Nov 10, 2021
7a819b5
chore: update dependencies (#2453)
Panaetius Nov 11, 2021
cd60d4b
fix(core): fix creation of output folders on rerun/update (#2452)
Panaetius Nov 12, 2021
7ee3711
fix(cli): fix renku run called with absolute path to executable outsi…
Panaetius Nov 15, 2021
ebd3246
fix(core): add dummy metadata.yml for backwards compatibility (#2444)
Panaetius Nov 15, 2021
70ffd13
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 15, 2021
2ccbce9
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 15, 2021
836f589
fix migration check after merge
Panaetius Nov 16, 2021
1d26b01
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 16, 2021
5ae22e7
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 22, 2021
6feba5d
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 26, 2021
1d49a2c
address PR comments
Panaetius Nov 26, 2021
f0cc3ec
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 26, 2021
90c674e
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 26, 2021
fbcc54e
address PR review
Panaetius Nov 26, 2021
83543cb
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Nov 26, 2021
6981cd6
fix gitlab api call
Panaetius Nov 29, 2021
159956f
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Dec 1, 2021
8694fe2
Merge remote-tracking branch 'origin/master' into 2432-optimize-check…
Panaetius Dec 1, 2021
52ab429
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Dec 1, 2021
53b998c
Merge branch 'master' into 2432-optimize-check-migrations
Panaetius Dec 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
113 changes: 77 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -141,6 +141,7 @@ werkzeug = "<2.0.3,>=0.15.5"
yagup = ">=0.1.1"
"zc.relation" = "<1.2,>=1.1"
zodb = "==5.6.0"
python-gitlab = ">=2.10.1,<2.11"

[tool.poetry.extras]
# TODO: replace these with dependency groups (especially `all`) once poetry 1.2 is released
Expand Down
4 changes: 0 additions & 4 deletions renku/core/management/migrate.py
Expand Up @@ -58,7 +58,6 @@
read_project_version,
)
from renku.core.utils import communication
from renku.core.utils.git import is_valid_git_repository

SUPPORTED_PROJECT_VERSION = 9

Expand Down Expand Up @@ -348,9 +347,6 @@ def is_renku_project(client_dispatcher: IClientDispatcher) -> bool:
"""Check if repository is a renku project."""
client = client_dispatcher.current_client

if not is_valid_git_repository(client.repository):
return False

try:
return client.project is not None
except ValueError: # NOTE: Error in loading due to an older schema
Expand Down
10 changes: 10 additions & 0 deletions renku/core/models/git.py
Expand Up @@ -140,6 +140,16 @@ def parse(cls, href):
else:
raise errors.GitConfigurationError(f"`{href}` is not a valid Git remote")

@property
def instance_url(self):
"""Get the url of the git instance."""
url = urlparse(self.href)

path = self.pathname.split(self.owner, 1)[0]
url._replace(path=path)

return url.geturl()

@property
def image(self):
"""Return image name."""
Expand Down
35 changes: 33 additions & 2 deletions renku/service/controllers/cache_migrations_check.py
Expand Up @@ -17,9 +17,16 @@
# limitations under the License.
"""Renku service migrations check controller."""

import tempfile
from pathlib import Path

from renku.core.commands.migrate import migrations_check
from renku.core.errors import RenkuException
from renku.core.utils.contexts import click_context
from renku.service.controllers.api.abstract import ServiceCtrl
from renku.service.controllers.api.mixins import RenkuOperationMixin
from renku.service.controllers.utils.remote_project import ANONYMOUS_SESSION
from renku.service.interfaces.git_api_provider import IGitAPIProvider
from renku.service.serializers.cache import ProjectMigrationCheckRequest, ProjectMigrationCheckResponseRPC
from renku.service.views import result_response

Expand All @@ -30,20 +37,44 @@ class MigrationsCheckCtrl(ServiceCtrl, RenkuOperationMixin):
REQUEST_SERIALIZER = ProjectMigrationCheckRequest()
RESPONSE_SERIALIZER = ProjectMigrationCheckResponseRPC()

def __init__(self, cache, user_data, request_data):
def __init__(self, cache, user_data, request_data, git_api_provider: IGitAPIProvider):
"""Construct migration check controller."""
self.ctx = MigrationsCheckCtrl.REQUEST_SERIALIZER.load(request_data)
self.git_api_provider = git_api_provider
super(MigrationsCheckCtrl, self).__init__(cache, user_data, request_data)

@property
def context(self):
"""Controller operation context."""
return self.ctx

def _fast_op_without_cache(self):
"""Execute renku_op with only necessary files, without cloning the whole repo."""
if "git_url" not in self.context:
raise RenkuException("context does not contain `project_id` or `git_url`")

with tempfile.TemporaryDirectory() as tempdir:
tempdir = Path(tempdir)

self.git_api_provider.download_files_from_api(
[".renku/metadata/root", ".renku/metadata/project", ".renku/metadata.yml", "Dockerfile"],
tempdir,
remote=self.ctx["git_url"],
ref=self.request_data.get("ref", None),
token=self.user_data.get("token", ANONYMOUS_SESSION),
)
with click_context(tempdir, "renku_op"):
return self.renku_op()

def renku_op(self):
"""Renku operation for the controller."""
return migrations_check().build().execute().output

def to_response(self):
"""Execute controller flow and serialize to service response."""
return result_response(self.RESPONSE_SERIALIZER, self.execute_op())

if "project_id" in self.context:
# use regular flow using cache
return result_response(self.RESPONSE_SERIALIZER, self.execute_op())

return result_response(self.RESPONSE_SERIALIZER, self._fast_op_without_cache())
18 changes: 18 additions & 0 deletions renku/service/gateways/__init__.py
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 - Swiss Data Science Center (SDSC)
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
# Eidgenössische Technische Hochschule Zürich (ETHZ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Renku service adapters/gateways."""