Skip to content

Commit 0d3c176

Browse files
feat(cli): gc command (#2866)
1 parent 73f2198 commit 0d3c176

File tree

34 files changed

+239
-39
lines changed

34 files changed

+239
-39
lines changed
83 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-
8f835f7c5c76b60f8cd9785fd1e0cf31 cheatsheet.tex
1+
3e7d7567c17eba64945b70a3c1009343 cheatsheet.tex
22
c70c179e07f04186ec05497564165f11 sdsc_cheatsheet.cls

docs/reference/commands.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ Renku Command Line
6262

6363
.. automodule:: renku.ui.cli.dataset
6464

65+
.. _cli-gc:
66+
67+
``renku gc``
68+
------------
69+
70+
.. automodule:: renku.ui.cli.gc
71+
6572
.. _cli-graph:
6673

6774
``renku graph``

renku/command/command_builder/client_dispatcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
# limitations under the License.
1818
"""Renku client dispatcher."""
1919
from pathlib import Path
20-
from typing import Optional, Union
20+
from typing import Union
2121

2222
from renku.core import errors
23+
from renku.core.constant import RENKU_HOME
2324
from renku.core.interface.client_dispatcher import IClientDispatcher
24-
from renku.core.management import RENKU_HOME
2525
from renku.core.management.client import LocalClient
2626

2727

@@ -35,7 +35,7 @@ def __init__(self):
3535
self.client_stack = []
3636

3737
@property
38-
def current_client(self) -> Optional[LocalClient]:
38+
def current_client(self) -> LocalClient:
3939
"""Get the currently active client."""
4040
if len(self.client_stack) == 0:
4141
raise errors.ConfigurationError("No client configured for injection")

renku/command/gc.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2020 - Swiss Data Science Center (SDSC)
4+
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
5+
# Eidgenössische Technische Hochschule Zürich (ETHZ).
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""Garbage collection and cleanup command."""
19+
20+
from renku.command.command_builder.command import Command
21+
22+
23+
def gc_command():
24+
"""Command to clean up project's caches."""
25+
from renku.core.misc.gc import remove_caches
26+
27+
return Command().command(remove_caches).lock_project()

renku/command/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
from renku.command.command_builder.command import Command, inject
2727
from renku.command.git import set_git_home
2828
from renku.core import errors
29+
from renku.core.constant import RENKU_HOME
2930
from renku.core.interface.client_dispatcher import IClientDispatcher
3031
from renku.core.interface.database_dispatcher import IDatabaseDispatcher
3132
from renku.core.interface.database_gateway import IDatabaseGateway
32-
from renku.core.management import RENKU_HOME
3333
from renku.core.migration.utils import OLD_METADATA_PATH
3434
from renku.core.template.template import (
3535
FileAction,

renku/core/constant.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2017-2022 - Swiss Data Science Center (SDSC)
4+
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and
5+
# Eidgenössische Technische Hochschule Zürich (ETHZ).
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""Renku core constants."""
19+
20+
CACHE = "cache"
21+
"""Directory to cache transient data."""
22+
23+
RENKU_HOME = ".renku"
24+
"""Project directory name."""
25+
26+
RENKU_TMP = "tmp"

renku/core/dataset/constant.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@
1919

2020
from pathlib import Path
2121

22-
from renku.core.management import RENKU_HOME
22+
from renku.core.constant import RENKU_HOME
2323
from renku.core.management.repository import RepositoryApiMixin
2424
from renku.domain_model.refs import LinkReference
2525

2626
POINTERS = "pointers"
2727
"""Directory for storing external pointer files."""
2828

29-
CACHE = "cache"
30-
"""Directory to cache transient data."""
31-
3229
DATASET_IMAGES = "dataset_images"
3330
"""Directory for dataset images."""
3431

renku/core/dataset/dataset_add.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030

3131
from renku.command.command_builder.command import inject
3232
from renku.core import errors
33-
from renku.core.dataset.constant import CACHE, renku_pointers_path
33+
from renku.core.constant import CACHE
34+
from renku.core.dataset.constant import renku_pointers_path
3435
from renku.core.dataset.context import DatasetContext
3536
from renku.core.dataset.datasets_provenance import DatasetsProvenance
3637
from renku.core.dataset.pointer_file import create_external_file

renku/core/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import click
2525

26-
from renku.core.management import RENKU_HOME
26+
from renku.core.constant import RENKU_HOME
2727

2828

2929
class RenkuException(Exception):

0 commit comments

Comments
 (0)