Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
HasReqsHints,
adjustDirObjs,
normalizeFilesDirs,
path_to_loc,
processes_to_kill,
trim_listing,
versionstring,
Expand Down Expand Up @@ -482,11 +483,6 @@ def init_job_order(
job_order_object = {}
job_order_object[shortname(inp["id"])] = inp["default"]

def path_to_loc(p: CWLFileType | CWLDirectoryType) -> None:
if "location" not in p and "path" in p:
p["location"] = p["path"]
del p["path"]

ns: ContextType = {}
ns.update(cast(ContextType, job_order_object.get("$namespaces", {})))
ns.update(cast(ContextType, process.metadata.get("$namespaces", {})))
Expand Down
5 changes: 4 additions & 1 deletion cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
ensure_writable,
get_listing,
normalizeFilesDirs,
path_to_loc,
random_outdir,
visit_directories,
visit_files,
Expand Down Expand Up @@ -428,7 +429,9 @@ def fill_in_defaults(
if job.get(fieldname) is not None:
pass
elif job.get(fieldname) is None and "default" in inp:
job[fieldname] = copy.deepcopy(inp["default"])
default = copy.deepcopy(inp["default"])
visit_files_directories(default, path_to_loc)
job[fieldname] = default
elif job.get(fieldname) is None and "null" in aslist(inp["type"]):
job[fieldname] = None
else:
Expand Down
7 changes: 7 additions & 0 deletions cwltool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ def visit_files_directories(rec: Any, op: Callable[[CWLFileType | CWLDirectoryTy
visit_files_directories(d, op)


def path_to_loc(obj: CWLFileType | CWLDirectoryType) -> None:
"""Convert a path field to a location field."""
if "location" not in obj and "path" in obj:
obj["location"] = obj["path"]
del obj["path"]


def visit_field(rec: Any, field: str, op: Callable[..., Any]) -> None:
"""Apply a function to mapping with 'field'."""
if isinstance(rec, MutableMapping):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_default_path.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from cwltool.load_tool import fetch_document, resolve_and_validate_document
from cwltool.main import main

from .util import get_data

Expand All @@ -13,3 +14,8 @@ def test_default_path() -> None:
assert isinstance(processobj, dict)

assert "cwlVersion" in processobj


def test_workflow_step_file_default() -> None:
"""Run a workflow step with a default File input."""
assert main(["--no-container", get_data("tests/wf/workflow_step_file_default.cwl")]) == 0
22 changes: 22 additions & 0 deletions tests/wf/workflow_step_file_default.cwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cwlVersion: v1.2
class: Workflow

inputs: []

steps:
step_with_file_default:
run:
class: CommandLineTool
inputs:
input_with_default:
type: File
default:
class: File
path: ../../README.rst
inputBinding: {}
baseCommand: sha256sum
outputs: []
in: []
out: []

outputs: []