Skip to content

Commit

Permalink
Merge pull request #2885 from SwissDataScienceCenter/release/v1.2.4
Browse files Browse the repository at this point in the history
chore: release v1.2.4
  • Loading branch information
Panaetius authored May 6, 2022
2 parents a5d96a8 + cccb90f commit 11f753c
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 97 deletions.
20 changes: 20 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
Changes
=======

`1.2.4 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.2.3...v1.2.4>`__ (2022-05-06)
-------------------------------------------------------------------------------------------------------

Bug Fixes
~~~~~~~~~

- **core:** fix using float values in renku workflow iterate
(`#2875 <https://github.com/SwissDataScienceCenter/renku-python/issues/2875>`__)
(`07934a8 <https://github.com/SwissDataScienceCenter/renku-python/commit/07934a8df49a4b8a7a4c25eddaae93b97943ac59>`__)
- **service:** set oauth token when using gitlab APIs
(`#2884 <https://github.com/SwissDataScienceCenter/renku-python/issues/2884>`__)
(`11a69d7 <https://github.com/SwissDataScienceCenter/renku-python/commit/11a69d71fc08854a03bf3e524f0d68d3e86a5685>`__)

Features
~~~~~~~~

- **core:** preserve staged files when editing renku config
(`#2871 <https://github.com/SwissDataScienceCenter/renku-python/issues/2871>`__)
(`3c3cc66 <https://github.com/SwissDataScienceCenter/renku-python/commit/3c3cc66a426c71d742d13b5fb394791d8425a5c6>`__)

`1.2.3 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.2.2...v1.2.3>`__ (2022-04-29)
-------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion helm-chart/renku-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ appVersion: "1.0"
description: A Helm chart for Kubernetes
name: renku-core
icon: https://avatars0.githubusercontent.com/u/53332360?s=400&u=a4311d22842343604ef61a8c8a1e5793209a67e9&v=4
version: 1.2.3
version: 1.2.4
2 changes: 1 addition & 1 deletion helm-chart/renku-core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ versions:
fullnameOverride: ""
image:
repository: renku/renku-core
tag: "v1.2.3"
tag: "v1.2.4"
pullPolicy: IfNotPresent
v8:
name: v8
Expand Down
3 changes: 2 additions & 1 deletion renku/command/command_builder/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def with_commit(
commit_if_empty: bool = False,
raise_if_empty: bool = False,
commit_only: Optional[bool] = None,
skip_staging: bool = False,
) -> "Command":
"""Create a commit.
Expand All @@ -426,7 +427,7 @@ def with_commit(
"""
from renku.command.command_builder.repo import Commit

return Commit(self, message, commit_if_empty, raise_if_empty, commit_only)
return Commit(self, message, commit_if_empty, raise_if_empty, commit_only, skip_staging)

@check_finalized
def lock_project(self) -> "Command":
Expand Down
7 changes: 6 additions & 1 deletion renku/command/command_builder/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
commit_if_empty: Optional[bool] = False,
raise_if_empty: Optional[bool] = False,
commit_only: Optional[bool] = None,
skip_staging: bool = False,
) -> None:
"""__init__ of Commit.
Expand All @@ -49,6 +50,7 @@ def __init__(
self._commit_if_empty = commit_if_empty
self._raise_if_empty = raise_if_empty
self._commit_filter_paths = commit_only
self._skip_staging: bool = skip_staging

def _pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None:
"""Hook to create a commit transaction.
Expand All @@ -65,7 +67,9 @@ def _pre_hook(self, builder: Command, context: dict, *args, **kwargs) -> None:
from renku.core.management.git import prepare_commit

self.diff_before = prepare_commit(
context["client_dispatcher"].current_client, commit_only=self._commit_filter_paths
context["client_dispatcher"].current_client,
commit_only=self._commit_filter_paths,
skip_staging=self._skip_staging,
)

def _post_hook(self, builder: Command, context: dict, result: CommandResult, *args, **kwargs):
Expand All @@ -90,6 +94,7 @@ def _post_hook(self, builder: Command, context: dict, result: CommandResult, *ar
commit_empty=self._commit_if_empty,
raise_if_empty=self._raise_if_empty,
commit_message=self._message,
skip_staging=self._skip_staging,
)
except errors.RenkuException as e:
result.error = e
Expand Down
2 changes: 1 addition & 1 deletion renku/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def update_config():
Command()
.command(_update_config)
.require_migration()
.with_commit(commit_if_empty=False, commit_only=CONFIG_LOCAL_PATH)
.with_commit(commit_if_empty=False, commit_only=CONFIG_LOCAL_PATH, skip_staging=True)
.with_database()
)

Expand Down
23 changes: 0 additions & 23 deletions renku/command/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from renku.core import errors

GIT_KEY = "renku.git"
GIT_ISOLATION = "renku.worktree"


def set_git_home(value: Path):
Expand Down Expand Up @@ -57,25 +56,3 @@ def get_git_home(path=".") -> Path:
return Repository(path, search_parent_directories=True).path
except errors.GitError:
raise ValueError(f"Cannot find a git repository at '{path}'")


def set_git_isolation(value):
"""Set Git isolation.
Args:
value: Git isolation level.
Returns:
The value passed.
"""
ctx = click.get_current_context()
ctx.meta[GIT_ISOLATION] = value

return value


def get_git_isolation():
"""Get Git isolation from the current context."""
ctx = click.get_current_context(silent=True)
if ctx and GIT_ISOLATION in ctx.meta:
return ctx.meta[GIT_ISOLATION]
11 changes: 0 additions & 11 deletions renku/command/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@

import click

from .git import set_git_isolation

option_isolation = click.option(
"--isolation",
is_flag=True,
default=False,
callback=lambda ctx, param, value: set_git_isolation(value),
help="Set up the isolation for invoking of the given command.",
)


option_external_storage_requested = click.option(
"external_storage_requested",
"--external-storage/--no-external-storage",
Expand Down
15 changes: 9 additions & 6 deletions renku/core/management/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
STARTED_AT = int(time.time() * 1e3)


def prepare_commit(
client,
commit_only=None,
skip_dirty_checks=False,
):
def prepare_commit(client, commit_only=None, skip_dirty_checks=False, skip_staging: bool = False):
"""Gather information about repo needed for committing later on."""
diff_before = set()

if skip_staging:
if not isinstance(commit_only, list) or len(commit_only) == 0:
raise errors.OperationError("Cannot use ``skip_staging`` without specifying files to commit.")

if commit_only == COMMIT_DIFF_STRATEGY:
if len(client.repository.staged_changes) > 0 or len(client.repository.unstaged_changes) > 0:
client.repository.reset()
Expand Down Expand Up @@ -73,6 +73,7 @@ def finalize_commit(
raise_if_empty=False,
commit_message=None,
abbreviate_message=True,
skip_staging: bool = False,
):
"""Commit modified/added paths."""
from renku.infrastructure.repository import Actor
Expand Down Expand Up @@ -127,8 +128,10 @@ def finalize_commit(
if abbreviate_message:
commit_message = shorten_message(commit_message)

# NOTE: Only commit specified paths when skipping staging area
paths = commit_only if skip_staging else []
# Ignore pre-commit hooks since we have already done everything.
client.repository.commit(commit_message + client.transaction_id, committer=committer, no_verify=True)
client.repository.commit(commit_message + client.transaction_id, committer=committer, no_verify=True, paths=paths)


def prepare_worktree(
Expand Down
10 changes: 7 additions & 3 deletions renku/core/workflow/converters/cwl.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ def _convert_step(
dirents.append(path)
jsrequirement = True

environment_variables.append(cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{output_.name}", output_.actual_value))
environment_variables.append(
cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{output_.name}", str(output_.actual_value))
)
outp, arg = CWLExporter._convert_output(output_)
tool_object.outputs.append(outp)
if arg:
Expand All @@ -280,15 +282,17 @@ def _convert_step(
cwl.Dirent(entry="$(inputs.{})".format(tool_input.id), entryname=input_.actual_value, writable=False)
)

environment_variables.append(cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{input_.name}", input_.actual_value))
environment_variables.append(
cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{input_.name}", str(input_.actual_value))
)
tool_object.inputs.append(tool_input)
if input_.mapped_to:
tool_object.stdin = "$(inputs.{}.path)".format(tool_input.id)
jsrequirement = True

for parameter in workflow.parameters:
environment_variables.append(
cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{parameter.name}", parameter.actual_value)
cwl.EnvironmentDef(f"{RENKU_ENV_PREFIX}{parameter.name}", str(parameter.actual_value))
)
tool_object.inputs.append(CWLExporter._convert_parameter(parameter))

Expand Down
10 changes: 10 additions & 0 deletions renku/data/shacl_shape.json
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,11 @@
"@id": "xsd:decimal"
}
},
{
"datatype": {
"@id": "xsd:double"
}
},
{
"datatype": {
"@id": "xsd:integer"
Expand Down Expand Up @@ -1359,6 +1364,11 @@
"nodeKind": "sh:Literal",
"path": "schema:value",
"or": [
{
"datatype": {
"@id": "xsd:double"
}
},
{
"datatype": {
"@id": "xsd:decimal"
Expand Down
8 changes: 7 additions & 1 deletion renku/infrastructure/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def commit(
committer: "Actor" = None,
no_verify: bool = False,
no_edit: bool = False,
paths: Optional[List[Union[Path, str]]] = None,
) -> "Commit":
"""Commit added files to the VCS."""
if self._repository is None:
Expand All @@ -217,7 +218,12 @@ def commit(
if committer:
env.update({"GIT_COMMITTER_NAME": committer.name, "GIT_COMMITTER_EMAIL": committer.email})

self.run_git_command("commit", message=message, no_verify=no_verify, amend=amend, no_edit=no_edit, env=env)
# NOTE: Only commit specified paths
args = ["--"] + [str(p) for p in paths] if paths else []

self.run_git_command(
"commit", *args, message=message, no_verify=no_verify, amend=amend, no_edit=no_edit, env=env
)

return Commit.from_commit(self._repository, self._repository.head.commit)

Expand Down
3 changes: 1 addition & 2 deletions renku/ui/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@

import click

from renku.command.options import option_isolation
from renku.ui.cli.utils.callback import ClickCallback


Expand All @@ -276,7 +275,7 @@
callback=lambda _, __, values: [int(value) % 256 for value in values],
help="Allowed command exit-code.",
)
@option_isolation
@click.option("--isolation", is_flag=True, default=False, help="Invoke the given command in isolation.")
@click.argument("command_line", nargs=-1, required=True, type=click.UNPROCESSED)
@click.option("--verbose", is_flag=True, default=False, help="Print generated plan after the execution.")
def run(
Expand Down
2 changes: 1 addition & 1 deletion renku/ui/service/gateways/gitlab_api_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def download_files_from_api(

git_data = GitURL.parse(remote)
try:
gl = gitlab.Gitlab(git_data.instance_url, private_token=token)
gl = gitlab.Gitlab(git_data.instance_url, oauth_token=token)
project = gl.projects.get(f"{git_data.owner}/{git_data.name}")
except gitlab.GitlabAuthenticationError:
# NOTE: Invalid or expired tokens fail even on public projects. Let's give it a try without tokens
Expand Down
20 changes: 20 additions & 0 deletions tests/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""Test ``config`` command."""
import os
import subprocess
import sys
from threading import Thread
Expand Down Expand Up @@ -272,3 +273,22 @@ def test_config_interpolation_is_disabled(client, runner, value):

assert 0 == result.exit_code, format_result_exception(result)
assert f"{value}\n" == result.output


def test_config_commit(client, runner, data_repository, global_config_dir):
"""Test config changes only commits the renku config file."""
commit_sha_before = client.repository.head.commit.hexsha

(client.path / "untracked").write_text("untracked")
(client.path / "staged").write_text("staged")
client.repository.add("staged")

result = runner.invoke(cli, ["config", "set", "key", "value"])

assert 0 == result.exit_code, format_result_exception(result)
assert {os.path.join(".renku", "renku.ini")} == {f.a_path for f in client.repository.head.commit.get_changes()}
assert {"untracked"} == set(client.repository.untracked_files)
assert {"staged"} == {f.a_path for f in client.repository.staged_changes}

commit_sha_after = client.repository.head.commit.hexsha
assert commit_sha_after != commit_sha_before
Loading

0 comments on commit 11f753c

Please sign in to comment.