Skip to content

Commit ec3173a

Browse files
authored
feat: add cloud storage support for session start (#3629)
1 parent 00da768 commit ec3173a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1726
-800
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ repos:
4343
- --ignore=D105,D107,D202,D203,D212,D213,D401,D406,D407,D410,D411,D413
4444
additional_dependencies:
4545
- toml
46+
exclude: ^renku/ui/service/views/
4647
- repo: https://github.com/koalaman/shellcheck-precommit
4748
rev: v0.8.0
4849
hooks:

docs/_static/cheatsheet/cheatsheet.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441
]
442442
},
443443
{
444-
"command": "$ renku storage pull <path>...",
444+
"command": "$ renku lfs pull <path>...",
445445
"description": "Pull <path>'s from external storage (LFS).",
446446
"target": [
447447
"rp"
-2 Bytes
Binary file not shown.

docs/cheatsheet_hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
5316163d742bdb6792ed8bcb35031f6c cheatsheet.tex
1+
b8a4fc75c7ba023773b0ccc2e98ebc02 cheatsheet.tex
22
c70c179e07f04186ec05497564165f11 sdsc_cheatsheet.cls

docs/cheatsheet_json_hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1856fb451165d013777c7c4cdd56e575 cheatsheet.json
1+
171f230e9ec6372e52129df1bfcf485a cheatsheet.json

docs/reference/commands/storage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
renku storage
44
*************
55

6-
.. automodule:: renku.ui.cli.storage
6+
.. automodule:: renku.ui.cli.lfs

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pattern = """(?x) (?# ignore whitespace
241241
"""
242242

243243
[tool.pytest.ini_options]
244-
addopts = "--doctest-glob=\"*.rst\" --doctest-modules --cov --cov-report=term-missing --ignore=docs/cheatsheet/ --tb=line"
244+
addopts = "--doctest-glob=\"*.rst\" --doctest-modules --cov --cov-report=term-missing --ignore=docs/cheatsheet/ -ra"
245245
doctest_optionflags = "ALLOW_UNICODE"
246246
flake8-ignore = ["*.py", "E121", "E126", "E203", "E226", "E231", "W503", "W504", "docs/conf.py", "docs/cheatsheet/conf.py", "ALL"]
247247
flake8-max-line-length = 120

renku/command/checks/storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"""Check for large files in Git history."""
1717

1818
from renku.command.util import WARNING
19-
from renku.core.storage import check_external_storage, check_lfs_migrate_info
19+
from renku.core.lfs import check_external_storage, check_lfs_migrate_info
2020

2121

2222
def check_lfs_info(**_):

renku/command/command_builder/command.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import contextlib
1919
import functools
20+
import shutil
2021
import threading
2122
from collections import defaultdict
2223
from pathlib import Path
@@ -455,6 +456,13 @@ def require_clean(self) -> "Command":
455456

456457
return RequireClean(self)
457458

459+
@check_finalized
460+
def require_login(self) -> "Command":
461+
"""Check that the user is logged in."""
462+
from renku.command.command_builder.repo import RequireLogin
463+
464+
return RequireLogin(self)
465+
458466
@check_finalized
459467
def with_communicator(self, communicator: CommunicationCallback) -> "Command":
460468
"""Create a communicator.
@@ -479,6 +487,20 @@ def with_database(self, write: bool = False, path: Optional[str] = None, create:
479487

480488
return DatabaseCommand(self, write, path, create)
481489

490+
@check_finalized
491+
def with_gitlab_api(self) -> "Command":
492+
"""Inject gitlab api client."""
493+
from renku.command.command_builder.gitlab import GitlabApiCommand
494+
495+
return GitlabApiCommand(self)
496+
497+
@check_finalized
498+
def with_storage_api(self) -> "Command":
499+
"""Inject storage api client."""
500+
from renku.command.command_builder.storage import StorageApiCommand
501+
502+
return StorageApiCommand(self)
503+
482504

483505
class CommandResult:
484506
"""The result of a command.
@@ -496,3 +518,26 @@ def __init__(self, output, error, status) -> None:
496518
self.output = output
497519
self.error = error
498520
self.status = status
521+
522+
523+
class RequireExecutable(Command):
524+
"""Builder to check if an executable is installed."""
525+
526+
HOOK_ORDER = 4
527+
528+
def __init__(self, builder: Command, executable: str) -> None:
529+
"""__init__ of RequireExecutable."""
530+
self._builder = builder
531+
self._executable = executable
532+
533+
def _pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None:
534+
"""Check if an executable exists on the system.
535+
536+
Args:
537+
builder(Command): Current ``CommandBuilder``.
538+
context(dict): Current context.
539+
"""
540+
if not shutil.which(self._executable):
541+
raise errors.ExecutableNotFound(
542+
f"Couldn't find the executable '{self._executable}' on this system. Please make sure it's installed"
543+
)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
"""Command builder for gitlab api."""
17+
18+
19+
from renku.command.command_builder.command import Command, check_finalized
20+
from renku.core.interface.git_api_provider import IGitAPIProvider
21+
from renku.domain_model.project_context import project_context
22+
from renku.infrastructure.gitlab_api_provider import GitlabAPIProvider
23+
24+
25+
class GitlabApiCommand(Command):
26+
"""Builder to get a gitlab api client."""
27+
28+
PRE_ORDER = 4
29+
30+
def __init__(self, builder: Command) -> None:
31+
self._builder = builder
32+
33+
def _injection_pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None:
34+
"""Create a gitlab api provider."""
35+
36+
if not project_context.has_context():
37+
raise ValueError("Gitlab API builder needs a ProjectContext to be set.")
38+
39+
def _get_provider():
40+
from renku.core.login import read_renku_token
41+
42+
token = read_renku_token(None, True)
43+
if not token:
44+
return None
45+
return GitlabAPIProvider(token=token)
46+
47+
context["constructor_bindings"][IGitAPIProvider] = _get_provider
48+
49+
@check_finalized
50+
def build(self) -> Command:
51+
"""Build the command."""
52+
self._builder.add_injection_pre_hook(self.PRE_ORDER, self._injection_pre_hook)
53+
54+
return self._builder.build()

0 commit comments

Comments
 (0)