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(core): add ssh_supported flag to template and migrations_check #3294

Merged
merged 5 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions renku/command/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,23 @@ def _template_migration_check():
Returns:
Dictionary of template migration status.
"""
from renku.core.config import get_value
from renku.core.template.usecase import check_for_template_update

try:
project = project_context.project
template_source = project.template_metadata.template_source
template_ref = project.template_metadata.template_ref
template_id = project.template_metadata.template_id
ssh_supported = project.template_metadata.ssh_supported
except (ValueError, AttributeError):
project = None
template_source = None
template_ref = None
template_id = None
ssh_supported = False

ssh_supported = get_value("renku", "ssh_supported") == "true" or ssh_supported

update_available, update_allowed, current_version, new_version = check_for_template_update(project)

Expand All @@ -111,6 +116,7 @@ def _template_migration_check():
"template_source": template_source,
"template_ref": template_ref,
"template_id": template_id,
"ssh_supported": ssh_supported,
}


Expand Down
2 changes: 2 additions & 0 deletions renku/core/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def create_from_template_local(
description: Optional[str] = None,
keywords: Optional[List[str]] = None,
data_dir: Optional[str] = None,
ssh_supported: bool = False,
):
"""Initialize a new project from a template.

Expand Down Expand Up @@ -381,6 +382,7 @@ def create_from_template_local(
description="",
parameters={},
icon="",
ssh_supported=ssh_supported,
immutable_files=immutable_template_files or [],
allow_update=automated_template_update,
source=metadata["__template_source__"],
Expand Down
3 changes: 2 additions & 1 deletion renku/core/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def login(endpoint: Optional[str], git_login: bool, yes: bool):
remote_name, remote_url = remote.name, remote.url

if remote_name and remote_url:
if not yes and not get_value("renku", "show_login_warning"):
show_login_warning = get_value("renku", "show_login_warning")
if not yes and (show_login_warning is None or show_login_warning.lower() == "true"):
message = (
"Remote URL will be changed. Do you want to continue "
"(to disable this warning, pass '--yes' or run 'renku config set show_login_warning False')?"
Expand Down
6 changes: 3 additions & 3 deletions renku/core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def check_external_storage_wrapper(fn):
``errors.ExternalStorageNotInstalled``: If external storage isn't installed.
``errors.ExternalStorageDisabled``: If external storage isn't enabled.
"""
# noqa

@functools.wraps(fn)
def wrapper(*args, **kwargs):
if not check_external_storage():
Expand Down Expand Up @@ -219,11 +219,11 @@ def track_paths_in_storage(*paths):
raise errors.ParameterError(f"Couldn't run 'git lfs':\n{e}")

show_message = get_value("renku", "show_lfs_message")
if track_paths and (show_message is None or show_message == "True"):
if track_paths and (show_message is None or show_message.lower() == "true"):
files_list = "\n\t".join(track_paths)
communication.info(
f"Adding these files to Git LFS:\n\t{files_list}"
"\nTo disable this message in the future, run:\n\trenku config set show_lfs_message False"
"\nTo disable this message in the future, run:\n\trenku config set show_lfs_message false"
)

return track_paths
Expand Down
1 change: 1 addition & 0 deletions renku/core/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def copy_template_metadata_to_project():
template_version=rendered_template.template.version,
immutable_template_files=rendered_template.template.immutable_files.copy(),
metadata=json.dumps(rendered_template.metadata),
ssh_supported=rendered_template.template.ssh_supported,
)

actions_mapping: Dict[FileAction, Tuple[str, str]] = {
Expand Down
1 change: 1 addition & 0 deletions renku/domain_model/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ProjectTemplateMetadata:
template_source: Optional[str] = None
template_version: Optional[str] = None
immutable_template_files: Optional[List[str]] = None
ssh_supported: bool = False


class Project(persistent.Persistent):
Expand Down
3 changes: 3 additions & 0 deletions renku/domain_model/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def templates(self) -> List["Template"]:
description=cast(str, t.get("description")),
parameters=cast(Dict[str, Dict[str, Any]], t.get("variables") or t.get("parameters")),
icon=cast(str, t.get("icon")),
ssh_supported=t.get("ssh_supported", False),
immutable_files=t.get("immutable_template_files", []),
allow_update=t.get("allow_template_update", True),
source=None,
Expand Down Expand Up @@ -208,6 +209,7 @@ def __init__(
description: str,
parameters: Dict[str, Dict[str, Any]],
icon: str,
ssh_supported: bool,
immutable_files: List[str],
allow_update: bool,
source: Optional[str],
Expand All @@ -224,6 +226,7 @@ def __init__(
self.name: str = name
self.description: str = description
self.icon = icon
self.ssh_supported = ssh_supported
self.immutable_files: List[str] = immutable_files or []
self.allow_update: bool = allow_update
parameters = parameters or {}
Expand Down
10 changes: 8 additions & 2 deletions renku/ui/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@
| ``lfs_threshold`` | Threshold file size below which | ``100kb`` |
| | files are not added to git LFS | |
+--------------------------------+-------------------------------------+-----------+
| ``show_lfs_message`` | Whether to show messages about | ``True`` |
| ``show_lfs_message`` | Whether to show messages about | ``true`` |
Panaetius marked this conversation as resolved.
Show resolved Hide resolved
| | files being added to git LFS or not | |
+--------------------------------+-------------------------------------+-----------+
| ``show_login_warning`` | Whether to warn when logging in to | ``True`` |
| ``show_login_warning`` | Whether to warn when logging in to | ``true`` |
Panaetius marked this conversation as resolved.
Show resolved Hide resolved
| | Renku inside a project that causes | |
| | project's git remote to be changed. | |
+--------------------------------+-------------------------------------+-----------+
| ``ssh_supported`` | Whether the image in this project | ``false`` |
| | contains an SSH server on port 22 | |
| | for SSH connections. Used to | |
| | override the corresponding project | |
| | template setting. | |
+--------------------------------+-------------------------------------+-----------+
| ``zenodo.access_token`` | Access token for Zenodo API | ``None`` |
+--------------------------------+-------------------------------------+-----------+

Expand Down
4 changes: 2 additions & 2 deletions renku/ui/cli/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@
change the repository's remote URL to an endpoint in the deployment that adds
authentication to gitlab requests. Renku warns you each time that the remote
URL will change. To disable this warning, either pass ``--yes`` to the command
or set ``show_login_warning`` to ``False`` for the project or globally:
or set ``show_login_warning`` to ``false`` for the project or globally:

.. code-block:: console

$ renku config set [--global] show_login_warning False
$ renku config set [--global] show_login_warning false

You can avoid the remote from being changed by passing ``--no-git`` option to
the login command.
Expand Down
8 changes: 7 additions & 1 deletion renku/ui/service/controllers/cache_migrations_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ def _fast_op_without_cache(self):
tempdir_path = Path(tempdir)

self.git_api_provider.download_files_from_api(
[".renku/metadata/root", ".renku/metadata/project", ".renku/metadata.yml", "Dockerfile"],
[
".renku/metadata/root",
".renku/metadata/project",
".renku/metadata.yml",
".renku/renku.ini",
"Dockerfile",
],
tempdir_path,
remote=self.ctx["git_url"],
ref=self.request_data.get("ref", None),
Expand Down
1 change: 1 addition & 0 deletions renku/ui/service/controllers/templates_create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def new_project(self):
commit_message=self.ctx["commit_message"],
description=self.ctx["project_description"],
data_dir=self.ctx.get("data_directory"),
ssh_supported=self.template.ssh_supported,
)

self.new_project_push(new_project_path)
Expand Down
4 changes: 4 additions & 0 deletions renku/ui/service/serializers/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ class TemplateStatusResponse(Schema):
allow_none=True, metadata={"description": "The current version of the template in the template repository."}
)

ssh_supported = fields.Boolean(
metadata={"description": "Whether this project supports ssh connections to sessions or not."}
)


class ProjectMigrationCheckResponse(Schema):
"""Response schema for project migration check."""
Expand Down
18 changes: 0 additions & 18 deletions renku/ui/service/serializers/v0_9/__init__.py

This file was deleted.

46 changes: 0 additions & 46 deletions renku/ui/service/serializers/v0_9/cache.py

This file was deleted.

105 changes: 105 additions & 0 deletions renku/ui/service/serializers/v1/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# -*- 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 cache serializers."""

from marshmallow import Schema, fields

from renku.ui.service.serializers.cache import DockerfileStatusResponse, ProjectCompatibilityResponse
from renku.ui.service.serializers.common import RenkuSyncSchema
from renku.ui.service.serializers.rpc import JsonRPCResponse


class ProjectMigrateResponse_1_0(RenkuSyncSchema):
"""Response schema for project migrate."""

was_migrated = fields.Boolean()
template_migrated = fields.Boolean()
docker_migrated = fields.Boolean()
messages = fields.List(fields.String)


class ProjectMigrateResponseRPC_1_0(JsonRPCResponse):
"""RPC response schema for project migrate."""

result = fields.Nested(ProjectMigrateResponse_1_0)


class TemplateStatusResponse_1_5(Schema):
"""Response schema outlining template status for migrations check."""

automated_template_update = fields.Boolean(
metadata={"description": "Whether or not the project template explicitly supports automated updates."}
)
newer_template_available = fields.Boolean(
metadata={
"description": "Whether or not the current version of the project template differs from the "
"one used in the project."
}
)
template_source = fields.String(
metadata={
"description": "Source of the template repository, "
"either a Git URL or 'renku' if an embedded template was used."
}
)
template_ref = fields.String(
metadata={
"description": "The branch/tag/commit from the template_source repository "
"that was used to create this project."
}
)
template_id = fields.String(metadata={"description": "The id of the template in the template repository."})

project_template_version = fields.String(
allow_none=True, metadata={"description": "The version of the template last used in the user's project."}
)
latest_template_version = fields.String(
allow_none=True, metadata={"description": "The current version of the template in the template repository."}
)


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

project_supported = fields.Boolean(
metadata={
"description": "Determines whether this project is a Renku project that is supported by the version "
"running on this service (not made with a newer version)."
}
)
core_renku_version = fields.String(metadata={"description": "Version of Renku running in this service."})
project_renku_version = fields.String(metadata={"description": "Version of Renku last used to change the project."})

core_compatibility_status = fields.Nested(
ProjectCompatibilityResponse,
metadata={"description": "Fields detailing the compatibility of the project with this core service version."},
)
dockerfile_renku_status = fields.Nested(
DockerfileStatusResponse,
metadata={"description": "Fields detailing the status of the Dockerfile in the project."},
)
template_status = fields.Nested(
TemplateStatusResponse_1_5,
metadata={"description": "Fields detailing the status of the project template used by this project."},
)


class ProjectMigrationCheckResponseRPC_1_5(JsonRPCResponse):
"""RPC response schema for project migration check."""

result = fields.Nested(ProjectMigrationCheckResponse_1_5)
Loading