Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add project description (#2235)
- Loading branch information
1 parent
e8f9ebf
commit 109a3db
Showing
25 changed files
with
568 additions
and
54 deletions.
There are no files selected for viewing
This file contains 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 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 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,71 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2017-2021 - 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. | ||
r"""Renku CLI commands for handling of projects. | ||
Editing projects | ||
~~~~~~~~~~~~~~~~ | ||
Users can edit some project's metadata using by using ``renku project edit`` | ||
command. | ||
The following options can be passed to this command to set various metadata | ||
for a project. | ||
+-------------------+------------------------------------------------------+ | ||
| Option | Description | | ||
+===================+======================================================+ | ||
| -d, --description | Project's description. | | ||
+-------------------+------------------------------------------------------+ | ||
| -c, --creator | Creator's name, email, and an optional affiliation. | | ||
| | Accepted format is | | ||
| | 'Forename Surname <email> [affiliation]'. | | ||
+-------------------+------------------------------------------------------+ | ||
""" | ||
|
||
import click | ||
|
||
from renku.cli.utils.callback import ClickCallback | ||
from renku.core.commands.project import edit_project_command | ||
|
||
|
||
@click.group() | ||
def project(): | ||
"""Project commands.""" | ||
|
||
|
||
@project.command() | ||
@click.option("-d", "--description", default=None, type=click.STRING, help="Project's description.") | ||
@click.option( | ||
"-c", | ||
"--creator", | ||
default=None, | ||
type=click.STRING, | ||
help="Creator's name, email, and affiliation. Accepted format is 'Forename Surname <email> [affiliation]'.", | ||
) | ||
def edit(description, creator): | ||
"""Edit project metadata.""" | ||
result = edit_project_command().build().execute(description=description, creator=creator) | ||
|
||
updated, no_email_warning = result.output | ||
|
||
if not updated: | ||
click.echo("Nothing to update. Check available fields with `renku project edit --help`\n") | ||
else: | ||
click.echo("Successfully updated: {}.".format(", ".join(updated.keys()))) | ||
if no_email_warning: | ||
click.echo(ClickCallback.WARNING + f"No email or wrong format for: {no_email_warning}") |
This file contains 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 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 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,47 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2017-2021 - 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. | ||
"""Project management.""" | ||
|
||
from renku.core.management.command_builder import inject | ||
from renku.core.management.command_builder.command import Command | ||
from renku.core.management.interface.project_gateway import IProjectGateway | ||
from renku.core.management.repository import DATABASE_METADATA_PATH | ||
from renku.core.utils.metadata import construct_creator | ||
|
||
|
||
@inject.autoparams() | ||
def _edit_project(description, creator, project_gateway: IProjectGateway): | ||
"""Edit dataset metadata.""" | ||
possible_updates = {"creator": creator, "description": description} | ||
|
||
creator, no_email_warnings = construct_creator(creator, ignore_email=True) | ||
|
||
updated = {k: v for k, v in possible_updates.items() if v} | ||
|
||
if updated: | ||
project = project_gateway.get_project() | ||
project.update_metadata(creator=creator, description=description) | ||
project_gateway.update_project(project) | ||
|
||
return updated, no_email_warnings | ||
|
||
|
||
def edit_project_command(): | ||
"""Command for editing project metadata.""" | ||
command = Command().command(_edit_project).lock_project().with_database(write=True) | ||
return command.require_migration().with_commit(commit_only=DATABASE_METADATA_PATH) |
This file contains 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 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
Oops, something went wrong.