Skip to content

Commit bd54ff0

Browse files
committed
Fix path with spaces
1 parent fad03b8 commit bd54ff0

File tree

4 files changed

+13
-16
lines changed

4 files changed

+13
-16
lines changed

dapi/files.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def _parse_tapis_uri(tapis_uri: str) -> (str, str):
1919
tapis_uri (str): URI in the format 'tapis://system_id/path'.
2020
2121
Returns:
22-
tuple: A tuple containing (system_id, path) where path is URL-decoded.
22+
tuple: A tuple containing (system_id, path).
2323
2424
Raises:
2525
ValueError: If the URI format is invalid or missing required components.
@@ -36,7 +36,7 @@ def _parse_tapis_uri(tapis_uri: str) -> (str, str):
3636
try:
3737
parsed = urllib.parse.urlparse(tapis_uri)
3838
system_id = parsed.netloc
39-
path = urllib.parse.unquote(parsed.path.lstrip("/")) if parsed.path else ""
39+
path = parsed.path.lstrip("/") if parsed.path else ""
4040
if not system_id:
4141
raise ValueError(f"Invalid Tapis URI: '{tapis_uri}'. Missing system ID.")
4242
return system_id, path
@@ -190,8 +190,7 @@ def get_ds_path_uri(t: Tapis, path: str, verify_exists: bool = False) -> str:
190190
)
191191
else:
192192
tapis_path = path_remainder
193-
encoded_path = urllib.parse.quote(tapis_path)
194-
input_uri = f"tapis://{storage_system_id}/{encoded_path}"
193+
input_uri = f"tapis://{storage_system_id}/{tapis_path}"
195194
print(f"Translated '{path}' to '{input_uri}' using t.username")
196195
break # Found match, exit loop
197196

@@ -206,8 +205,7 @@ def get_ds_path_uri(t: Tapis, path: str, verify_exists: bool = False) -> str:
206205
if pattern in path:
207206
path_remainder = path.split(pattern, 1)[1].lstrip("/")
208207
tapis_path = path_remainder
209-
encoded_path = urllib.parse.quote(tapis_path)
210-
input_uri = f"tapis://{storage_system_id}/{encoded_path}"
208+
input_uri = f"tapis://{storage_system_id}/{tapis_path}"
211209
print(f"Translated '{path}' to '{input_uri}'")
212210
break # Found match, exit loop
213211

@@ -295,8 +293,7 @@ def get_ds_path_uri(t: Tapis, path: str, verify_exists: bool = False) -> str:
295293
f"Could not resolve project ID '{project_id_part}' to a Tapis system ID."
296294
)
297295

298-
encoded_path_within_project = urllib.parse.quote(path_within_project)
299-
input_uri = f"tapis://{found_system_id}/{encoded_path_within_project}"
296+
input_uri = f"tapis://{found_system_id}/{path_within_project}"
300297
print(f"Translated '{path}' to '{input_uri}' using Tapis v3 lookup")
301298
break # Found match, exit loop
302299

dapi/jobs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ def archive_uri(self) -> Optional[str]:
10081008
if details.archiveSystemId and details.archiveSystemDir:
10091009
archive_path = details.archiveSystemDir.lstrip("/")
10101010
return (
1011-
f"tapis://{details.archiveSystemId}/{urllib.parse.quote(archive_path)}"
1011+
f"tapis://{details.archiveSystemId}/{archive_path}"
10121012
)
10131013
return None
10141014

@@ -1048,7 +1048,7 @@ def list_outputs(
10481048
full_archive_path = os.path.join(details.archiveSystemDir, path.lstrip("/"))
10491049
full_archive_path = os.path.normpath(full_archive_path).lstrip("/")
10501050
try:
1051-
archive_base_uri = f"tapis://{details.archiveSystemId}/{urllib.parse.quote(full_archive_path)}"
1051+
archive_base_uri = f"tapis://{details.archiveSystemId}/{full_archive_path}"
10521052
from .files import list_files
10531053

10541054
return list_files(self._tapis, archive_base_uri, limit=limit, offset=offset)
@@ -1085,7 +1085,7 @@ def download_output(self, remote_path: str, local_target: str):
10851085
)
10861086
full_archive_path = os.path.normpath(full_archive_path).lstrip("/")
10871087
remote_uri = (
1088-
f"tapis://{details.archiveSystemId}/{urllib.parse.quote(full_archive_path)}"
1088+
f"tapis://{details.archiveSystemId}/{full_archive_path}"
10891089
)
10901090
try:
10911091
from .files import download_file

tests/files/test_uri_translation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,22 @@ def test_empty_path(self):
6262
self.assertEqual(result, expected)
6363

6464
def test_path_with_spaces(self):
65-
"""Test handling of paths with spaces (URL encoded)"""
66-
input_uri = "tapis://designsafe.storage.default/kks32/DS%20input/file.txt"
65+
"""Test handling of paths with spaces"""
66+
input_uri = "tapis://designsafe.storage.default/kks32/DS input/file.txt"
6767
expected = "/home/jupyter/MyData/DS input/file.txt"
6868
result = tapis_uri_to_local_path(input_uri)
6969
self.assertEqual(result, expected)
7070

7171
def test_community_path_with_spaces(self):
7272
"""Test handling of community paths with spaces"""
73-
input_uri = "tapis://designsafe.storage.community/My%20Dataset/data.csv"
73+
input_uri = "tapis://designsafe.storage.community/My Dataset/data.csv"
7474
expected = "/home/jupyter/CommunityData/My Dataset/data.csv"
7575
result = tapis_uri_to_local_path(input_uri)
7676
self.assertEqual(result, expected)
7777

7878
def test_project_path_with_spaces(self):
7979
"""Test handling of project paths with spaces"""
80-
input_uri = "tapis://project-1234-abcd/simulation%20results/output.txt"
80+
input_uri = "tapis://project-1234-abcd/simulation results/output.txt"
8181
expected = "/home/jupyter/MyProjects/simulation results/output.txt"
8282
result = tapis_uri_to_local_path(input_uri)
8383
self.assertEqual(result, expected)

tests/jobs/test_dir_uri.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def test_no_matching_pattern(self):
5252

5353
def test_space_in_path(self):
5454
path = "jupyter/MyData/path with spaces"
55-
expected = "tapis://designsafe.storage.default/testuser/path%20with%20spaces"
55+
expected = "tapis://designsafe.storage.default/testuser/path with spaces"
5656
self.assertEqual(get_ds_path_uri(self.t, path), expected)
5757

5858

0 commit comments

Comments
 (0)