-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add cloud storage support for session start #3629
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
63ed138
feat: add cloud storage commands
90e0b5f
chore: Update cheatsheet pdf
RenkuBot 64ca6b2
chore: Update cheatsheet json
RenkuBot bcb57ba
implement storage list and add rudimentary test
Panaetius 2e36541
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius b4f137b
fix tests
Panaetius d5afc61
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 770dc17
chore: Update cheatsheet pdf
RenkuBot b4f2f0a
chore: Update cheatsheet json
RenkuBot 99c1895
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 23553b6
fix errors
Panaetius 9287614
change toil test to log to file
fa9f513
comment out failing test line
3675827
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 322277e
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 05a90c5
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 535685e
fix storage cmmand
f3dd0d9
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 362b15f
fix pytest output to show summary at end and traceback
Panaetius 0b01efc
fix test
Panaetius f407d5a
fix test
Panaetius e9d09a7
adapt to storage changes
7abb677
Merge branch 'feat/rclone-storage-commands' of github.com:SwissDataSc…
1016961
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius e821623
Merge branch 'develop' into feat/rclone-storage-commands
6abaded
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius d9ef01f
Merge branch 'develop' into feat/rclone-storage-commands
Panaetius 85df232
Merge branch 'develop' into feat/rclone-storage-commands
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| 5316163d742bdb6792ed8bcb35031f6c cheatsheet.tex | ||
| b8a4fc75c7ba023773b0ccc2e98ebc02 cheatsheet.tex | ||
| c70c179e07f04186ec05497564165f11 sdsc_cheatsheet.cls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 1856fb451165d013777c7c4cdd56e575 cheatsheet.json | ||
| 171f230e9ec6372e52129df1bfcf485a cheatsheet.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ | |
| renku storage | ||
| ************* | ||
|
|
||
| .. automodule:: renku.ui.cli.storage | ||
| .. automodule:: renku.ui.cli.lfs | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright 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. | ||
| """Command builder for gitlab api.""" | ||
|
|
||
|
|
||
| from renku.command.command_builder.command import Command, check_finalized | ||
| from renku.core.interface.git_api_provider import IGitAPIProvider | ||
| from renku.domain_model.project_context import project_context | ||
| from renku.infrastructure.gitlab_api_provider import GitlabAPIProvider | ||
|
|
||
|
|
||
| class GitlabApiCommand(Command): | ||
| """Builder to get a gitlab api client.""" | ||
|
|
||
| PRE_ORDER = 4 | ||
|
|
||
| def __init__(self, builder: Command) -> None: | ||
| self._builder = builder | ||
|
|
||
| def _injection_pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None: | ||
| """Create a gitlab api provider.""" | ||
|
|
||
| if not project_context.has_context(): | ||
| raise ValueError("Gitlab API builder needs a ProjectContext to be set.") | ||
|
|
||
| def _get_provider(): | ||
| from renku.core.login import read_renku_token | ||
|
|
||
| token = read_renku_token(None, True) | ||
| if not token: | ||
| return None | ||
| return GitlabAPIProvider(token=token) | ||
|
|
||
| context["constructor_bindings"][IGitAPIProvider] = _get_provider | ||
|
|
||
| @check_finalized | ||
| def build(self) -> Command: | ||
| """Build the command.""" | ||
| self._builder.add_injection_pre_hook(self.PRE_ORDER, self._injection_pre_hook) | ||
|
|
||
| return self._builder.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright 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. | ||
| """Command builder for storage api.""" | ||
|
|
||
|
|
||
| from renku.command.command_builder.command import Command, check_finalized | ||
| from renku.core.interface.storage_service_gateway import IStorageService | ||
| from renku.domain_model.project_context import project_context | ||
| from renku.infrastructure.storage.storage_service import StorageService | ||
|
|
||
|
|
||
| class StorageApiCommand(Command): | ||
| """Builder to get a storage api client.""" | ||
|
|
||
| PRE_ORDER = 4 | ||
|
|
||
| def __init__(self, builder: Command) -> None: | ||
| self._builder = builder | ||
|
|
||
| def _injection_pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None: | ||
| """Create a storage api provider.""" | ||
|
|
||
| if not project_context.has_context(): | ||
| raise ValueError("storage api builder needs a ProjectContext to be set.") | ||
|
|
||
| context["constructor_bindings"][IStorageService] = lambda: StorageService() | ||
|
|
||
| @check_finalized | ||
| def build(self) -> Command: | ||
| """Build the command.""" | ||
| self._builder.add_injection_pre_hook(self.PRE_ORDER, self._injection_pre_hook) | ||
|
|
||
| return self._builder.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Copyright 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. | ||
| """Serializers for storage.""" | ||
|
|
||
| import json | ||
| from typing import List, Optional | ||
|
|
||
| from renku.command.format.tabulate import tabulate | ||
| from renku.domain_model.cloud_storage import CloudStorage | ||
|
|
||
|
|
||
| def tabular(cloud_storages: List[CloudStorage], *, columns: Optional[str] = None): | ||
| """Format cloud_storages with a tabular output.""" | ||
| if not columns: | ||
| columns = "id,name,private,type" | ||
| return tabulate(collection=cloud_storages, columns=columns, columns_mapping=CLOUD_STORAGE_COLUMNS) | ||
|
|
||
|
|
||
| def log(cloud_storages: List[CloudStorage], *, columns: Optional[str] = None): | ||
| """Format cloud_storages in a log like output.""" | ||
| from renku.ui.cli.utils.terminal import style_header, style_key | ||
|
|
||
| output = [] | ||
|
|
||
| for cloud_storage in cloud_storages: | ||
| output.append(style_header(f"CloudStorage {cloud_storage.name}")) | ||
| output.append(style_key("Id: ") + cloud_storage.storage_id) # type: ignore | ||
| output.append(style_key("Source Path: ") + cloud_storage.source_path) | ||
| output.append(style_key("Target path: ") + cloud_storage.target_path) | ||
| output.append(style_key("Private: ") + ("Yes" if cloud_storage.private else "No")) | ||
| output.append(style_key("Configuration: \n") + json.dumps(cloud_storage.configuration, indent=4)) | ||
| output.append("") | ||
| return "\n".join(output) | ||
|
|
||
|
|
||
| CLOUD_STORAGE_FORMATS = {"tabular": tabular, "log": log} | ||
| """Valid formatting options.""" | ||
|
|
||
| CLOUD_STORAGE_COLUMNS = { | ||
| "id": ("storage_id", "id"), | ||
| "name": ("name", "name"), | ||
| "source_path": ("source_path", "source path"), | ||
| "target_path": ("target_path", "target path"), | ||
| "private": ("private", "private"), | ||
| "type": ("storage_type", "type"), | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.