Skip to content

Commit

Permalink
Deal with normalized paths when importing from a WDL JSON file (#5121)
Browse files Browse the repository at this point in the history
* Deal with already absolute'd paths from Toil.normalize in a JSON file import

* Run filename through unquote before running urlparse

* Update src/toil/wdl/wdltoil.py

Co-authored-by: Adam Novak <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Adam Novak <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 5beff7c commit e98eb4b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/toil/wdl/wdltoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

from functools import partial
from urllib.error import HTTPError
from urllib.parse import quote, unquote, urljoin, urlsplit
from urllib.parse import quote, unquote, urljoin, urlsplit, urlparse

import WDL.Error
import WDL.runtime.config
Expand Down Expand Up @@ -1520,7 +1520,11 @@ def _virtualize_filename(self, filename: str) -> str:
else:
# Otherwise this is a local file and we want to fake it as a Toil file store file
# Make it an absolute path
if self.execution_dir is not None:
parsed = urlparse(filename)
if parsed.scheme == "file":
# conversion was already done by normalize_uri
abs_filename = unquote(parsed.path)
elif self.execution_dir is not None:
# To support relative paths from execution directory, join the execution dir and filename
# If filename is already an abs path, join() will not do anything
abs_filename = os.path.join(self.execution_dir, filename)
Expand Down

0 comments on commit e98eb4b

Please sign in to comment.