Skip to content

Commit

Permalink
feat(core): add dataset entries to renku log (#2633)
Browse files Browse the repository at this point in the history
  • Loading branch information
Panaetius committed Feb 18, 2022
1 parent 6716913 commit f92fbac
Show file tree
Hide file tree
Showing 31 changed files with 1,109 additions and 137 deletions.
2 changes: 1 addition & 1 deletion renku/api/models/dataset.py
Expand Up @@ -91,7 +91,7 @@ def list(project):
dataset_gateway = DatasetGateway()
dataset_gateway.database_dispatcher = database_dispatcher

return [Dataset._from_dataset(d) for d in dataset_gateway.get_all_datasets()]
return [Dataset._from_dataset(d) for d in dataset_gateway.get_all_active_datasets()]

def __getattribute__(self, name):
dataset = object.__getattribute__(self, "_dataset")
Expand Down
4 changes: 3 additions & 1 deletion renku/cli/clone.py
Expand Up @@ -53,6 +53,8 @@

import click

import renku.cli.utils.color as color


@click.command()
@click.option("--no-pull-data", is_flag=True, help="Do not pull data from Git-LFS.", default=False)
Expand All @@ -67,4 +69,4 @@ def clone(no_pull_data, url, path):
project_clone_command().build().execute(
url=url, path=path, skip_smudge=no_pull_data, progress=get_git_progress_instance(), use_renku_credentials=True
)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)
5 changes: 3 additions & 2 deletions renku/cli/config.py
Expand Up @@ -121,6 +121,7 @@
"""
import click

import renku.cli.utils.color as color
from renku.cli.utils.click import MutuallyExclusiveOption


Expand Down Expand Up @@ -189,7 +190,7 @@ def set_(key, value, global_only):
from renku.core.commands.config import update_config

update_config().build().execute(key, value=value, global_only=global_only)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@config.command()
Expand All @@ -203,4 +204,4 @@ def remove(key, global_only):
from renku.core.commands.config import update_config

update_config().build().execute(key, remove=True, global_only=global_only)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)
35 changes: 18 additions & 17 deletions renku/cli/dataset.py
Expand Up @@ -509,6 +509,7 @@

import click

import renku.cli.utils.color as color
from renku.cli.utils.callback import ClickCallback
from renku.core.commands.format.dataset_files import DATASET_FILES_COLUMNS, DATASET_FILES_FORMATS
from renku.core.commands.format.dataset_tags import DATASET_TAGS_FORMATS
Expand Down Expand Up @@ -598,7 +599,7 @@ def create(name, title, description, creators, metadata, keyword):
new_dataset = result.output

click.echo(f'Use the name "{new_dataset.name}" to refer to this dataset.')
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command()
Expand Down Expand Up @@ -673,8 +674,8 @@ def show(name):
result = show_dataset().build().execute(name=name)
ds = result.output

click.echo(click.style("Name: ", bold=True, fg="magenta") + click.style(ds["name"], bold=True))
click.echo(click.style("Created: ", bold=True, fg="magenta") + (ds.get("created_at", "") or ""))
click.echo(click.style("Name: ", bold=True, fg=color.MAGENTA) + click.style(ds["name"], bold=True))
click.echo(click.style("Created: ", bold=True, fg=color.MAGENTA) + (ds.get("created_at", "") or ""))

creators = []
for creator in ds.get("creators", []):
Expand All @@ -683,20 +684,20 @@ def show(name):
else:
creators.append(f"{creator['name']} <{creator['email']}>")

click.echo(click.style("Creator(s): ", bold=True, fg="magenta") + ", ".join(creators))
click.echo(click.style("Creator(s): ", bold=True, fg=color.MAGENTA) + ", ".join(creators))
if ds["keywords"]:
click.echo(click.style("Keywords: ", bold=True, fg="magenta") + ", ".join(ds.get("keywords", "")))
click.echo(click.style("Keywords: ", bold=True, fg=color.MAGENTA) + ", ".join(ds.get("keywords", "")))

if ds["version"]:
click.echo(click.style("Version: ", bold=True, fg="magenta") + ds.get("version", ""))
click.echo(click.style("Version: ", bold=True, fg=color.MAGENTA) + ds.get("version", ""))

if ds["annotations"]:
click.echo(click.style("Annotations: ", bold=True, fg="magenta"))
click.echo(click.style("Annotations: ", bold=True, fg=color.MAGENTA))
click.echo(json.dumps(ds.get("annotations", ""), indent=2))

click.echo(click.style("Title: ", bold=True, fg="magenta") + click.style(ds.get("title", ""), bold=True))
click.echo(click.style("Title: ", bold=True, fg=color.MAGENTA) + click.style(ds.get("title", ""), bold=True))

click.echo(click.style("Description: ", bold=True, fg="magenta"))
click.echo(click.style("Description: ", bold=True, fg=color.MAGENTA))
print_markdown(ds.get("description", "") or "")


Expand Down Expand Up @@ -730,7 +731,7 @@ def add(name, urls, external, force, overwrite, create, sources, destination, re
destination=destination,
ref=ref,
)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("ls-files")
Expand Down Expand Up @@ -775,7 +776,7 @@ def unlink(name, include, exclude, yes):

communicator = ClickCallback()
file_unlink().with_communicator(communicator).build().execute(name=name, include=include, exclude=exclude, yes=yes)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("rm")
Expand All @@ -785,7 +786,7 @@ def remove(name):
from renku.core.commands.dataset import remove_dataset

remove_dataset().build().execute(name)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("tag")
Expand All @@ -798,7 +799,7 @@ def tag(name, tag, description, force):
from renku.core.commands.dataset import add_dataset_tag_command

add_dataset_tag_command().build().execute(name=name, tag=tag, description=description, force=force)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("rm-tags")
Expand All @@ -809,7 +810,7 @@ def remove_tags(name, tags):
from renku.core.commands.dataset import remove_dataset_tags_command

remove_dataset_tags_command().build().execute(name=name, tags=tags)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("ls-tags")
Expand Down Expand Up @@ -888,7 +889,7 @@ def export_(name, provider, publish, tag, **kwargs):
except (ValueError, errors.InvalidAccessToken, errors.DatasetNotFound, errors.RequestError) as e:
raise click.BadParameter(e)

click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("import")
Expand All @@ -907,7 +908,7 @@ def import_(uri, name, extract, yes):
import_dataset().with_communicator(communicator).build().execute(uri=uri, name=name, extract=extract, yes=yes)

click.secho(" " * 79 + "\r", nl=False)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@dataset.command("update")
Expand Down Expand Up @@ -935,4 +936,4 @@ def update(names, creators, include, exclude, ref, delete, external):
delete=delete,
external=external,
)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)
4 changes: 3 additions & 1 deletion renku/cli/doctor.py
Expand Up @@ -27,6 +27,8 @@

import click

import renku.cli.utils.color as color


@click.command()
@click.pass_context
Expand All @@ -38,7 +40,7 @@ def doctor(ctx):
is_ok, problems = doctor_check_command().build().execute().output

if is_ok:
click.secho("Everything seems to be ok.", fg="green")
click.secho("Everything seems to be ok.", fg=color.GREEN)
ctx.exit(0)

click.secho(problems)
Expand Down
15 changes: 9 additions & 6 deletions renku/cli/exception_handler.py
Expand Up @@ -63,11 +63,12 @@
import filelock
import portalocker

import renku.cli.utils.color as color
from renku.core.commands.echo import ERROR
from renku.core.errors import MigrationRequired, ParameterError, ProjectNotSupported, RenkuException, UsageError
from renku.service.config import SENTRY_ENABLED, SENTRY_SAMPLERATE

_BUG = click.style("Ahhhhhhhh! You have found a bug. 🐞\n\n", fg="red", bold=True)
_BUG = click.style("Ahhhhhhhh! You have found a bug. 🐞\n\n", fg=color.RED, bold=True)
HAS_SENTRY = SENTRY_ENABLED

if SENTRY_ENABLED:
Expand Down Expand Up @@ -130,7 +131,7 @@ def main(self, *args, **kwargs):
except (filelock.Timeout, portalocker.LockException, portalocker.AlreadyLocked):
click.echo(
(
click.style("Unable to acquire lock.\n", fg="red") + "Hint: Please wait for another renku "
click.style("Unable to acquire lock.\n", fg=color.RED) + "Hint: Please wait for another renku "
"process to finish and then try again."
)
)
Expand Down Expand Up @@ -166,9 +167,11 @@ def _handle_github(self):
"""Handle exception and submit it as GitHub issue."""
value = click.prompt(
_BUG
+ click.style('1. Open an issue by typing "open";\n', fg="green")
+ click.style("2. Print human-readable information by typing " '"print";\n', fg="yellow")
+ click.style("3. See the full traceback without submitting details " '(default: "ignore").\n\n', fg="red")
+ click.style('1. Open an issue by typing "open";\n', fg=color.GREEN)
+ click.style("2. Print human-readable information by typing " '"print";\n', fg=color.YELLOW)
+ click.style(
"3. See the full traceback without submitting details " '(default: "ignore").\n\n', fg=color.RED
)
+ "Please select an action by typing its name",
type=click.Choice(["open", "print", "ignore"]),
default="ignore",
Expand Down Expand Up @@ -208,7 +211,7 @@ def _process_open(self):
if not click.confirm("Did it work?", default=True):
click.echo()
self._process_print()
click.secho("\nOpen the line manually and copy the text above\n", fg="yellow")
click.secho("\nOpen the line manually and copy the text above\n", fg=color.YELLOW)
click.secho(" " + self.REPO_URL + self.ISSUE_SUFFIX + "\n", bold=True)

def _process_print(self):
Expand Down
6 changes: 4 additions & 2 deletions renku/cli/githooks.py
Expand Up @@ -40,6 +40,8 @@

import click

import renku.cli.utils.color as color


@click.group()
def githooks():
Expand All @@ -55,7 +57,7 @@ def install(force):

communicator = ClickCallback()
install_githooks_command().with_communicator(communicator).build().execute(force)
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)


@githooks.command()
Expand All @@ -64,4 +66,4 @@ def uninstall():
from renku.core.commands.githooks import uninstall_githooks_command

uninstall_githooks_command().build().execute()
click.secho("OK", fg="green")
click.secho("OK", fg=color.GREEN)

0 comments on commit f92fbac

Please sign in to comment.