Skip to content

Commit c332b86

Browse files
committed
fix(cli): fix renku rerun/update with unicode paths
1 parent b23a80d commit c332b86

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

renku/core/commands/cwl_runner.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
"""Wrap CWL runner."""
1919

2020
import os
21+
import re
2122
import shutil
2223
import sys
24+
from urllib.parse import unquote
2325

2426
import click
2527

@@ -32,11 +34,15 @@ def execute(client, output_file, output_paths=None):
3234
"""Run the generated workflow using cwltool library."""
3335
output_paths = output_paths or set()
3436

37+
import cwltool.command_line_tool
3538
import cwltool.factory
3639
from cwltool import workflow
3740
from cwltool.context import LoadingContext, RuntimeContext
3841
from cwltool.utils import visit_class
3942

43+
# NOTE: cwltool does not support unicode characters, patch it in (plus emojis 😁)
44+
cwltool.command_line_tool.ACCEPTLIST_RE = re.compile("^[\w\-. \u2600-\u26FF]+$")
45+
4046
def construct_tool_object(toolpath_object, *args, **kwargs):
4147
"""Fix missing locations."""
4248
protocol = "file://"
@@ -71,8 +77,8 @@ def addLocation(d):
7177

7278
def remove_prefix(location, prefix="file://"):
7379
if location.startswith(prefix):
74-
return location[len(prefix) :]
75-
return location
80+
return unquote(location[len(prefix) :])
81+
return unquote(location)
7682

7783
locations = {remove_prefix(output["location"]) for output in outputs.values()}
7884
# make sure to not move an output if it's containing directory gets moved

renku/core/management/repository.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
from renku.core.models.refs import LinkReference
4343
from renku.core.models.workflow.dependency_graph import DependencyGraph
4444
from renku.core.utils.migrate import MigrationType
45+
from renku.core.utils.scm import git_unicode_unescape
4546

4647
from .git import GitCore
4748

@@ -319,7 +320,8 @@ def process_commit(self, commit=None, path=None):
319320

320321
if not path:
321322
# search for activities a file could have been a part of
322-
activities = self.activities_for_paths(commit.stats.files.keys(), file_commit=commit, revision="HEAD")
323+
paths = [git_unicode_unescape(p) for p in commit.stats.files.keys()]
324+
activities = self.activities_for_paths(paths, file_commit=commit, revision="HEAD")
323325
if len(activities) > 1:
324326
raise errors.CommitProcessingError(
325327
"Found multiple activities that produced the same entity at commit {}".format(commit)

tests/cli/test_rerun.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,25 @@
3030
from renku.cli import cli
3131

3232

33-
def test_simple_rerun(runner, project, run, no_lfs_warning):
33+
@pytest.mark.parametrize(
34+
"source,selected",
35+
[
36+
("coffee-orders-☕-by-location test.csv", "😍works.txt"),
37+
("source.txt", "selected.txt"),
38+
("test-愛", "成功"),
39+
("그래프", "성공"),
40+
("يحاول", "نجاح.txt"),
41+
("график.txt", "успех.txt"),
42+
("𒁃.c", "𒁏.txt"),
43+
],
44+
)
45+
def test_simple_rerun(runner, project, run, no_lfs_warning, source, selected):
3446
"""Test simple file recreation."""
3547
greetings = {"hello", "hola", "ahoj"}
3648

3749
cwd = Path(project)
38-
source = cwd / "source.txt"
39-
selected = cwd / "selected.txt"
50+
source = cwd / source
51+
selected = cwd / selected
4052

4153
repo = git.Repo(project)
4254

0 commit comments

Comments
 (0)