Skip to content

Commit

Permalink
provenance: add empty manifest when there are no data files
Browse files Browse the repository at this point in the history
  • Loading branch information
simleo authored and mr-c committed Aug 30, 2022
1 parent 49b44e5 commit 2a2216b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cwltool/provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def __init__(
self.cwltool_version = "cwltool %s" % versionstring().split()[-1]
##
self.relativised_input_object = {} # type: CWLObjectType
self.has_manifest = False

self._initialize()
_logger.debug("[provenance] Temporary research object: %s", self.folder)
Expand Down Expand Up @@ -355,6 +356,8 @@ def open_log_file_for_activity(
def _finalize(self) -> None:
self._write_ro_manifest()
self._write_bag_info()
if not self.has_manifest:
(Path(self.folder) / "manifest-sha1.txt").touch()

def user_provenance(self, document: ProvDocument) -> None:
"""Add the user provenance."""
Expand Down Expand Up @@ -853,6 +856,7 @@ def add_to_manifest(self, rel_path: str, checksums: Dict[str, str]) -> None:
if os.path.commonprefix(["data/", rel_path]) == "data/":
# payload file, go to manifest
manifest = "manifest"
self.has_manifest = True
else:
# metadata file, go to tag manifest
manifest = "tagmanifest"
Expand Down
9 changes: 9 additions & 0 deletions tests/test_provenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ def test_directory_workflow(tmp_path: Path) -> None:
assert p.is_file(), f"Could not find {l} as {p}"


@needs_docker
def test_no_data_files(tmp_path: Path) -> None:
folder = cwltool(
tmp_path,
get_data("tests/wf/conditional_step_no_inputs.cwl"),
)
check_bagit(folder)


def check_output_object(base_path: Path) -> None:
output_obj = base_path / "workflow" / "primary-output.json"
compare_checksum = "sha1$b9214658cc453331b62c2282b772a5c063dbd284"
Expand Down

0 comments on commit 2a2216b

Please sign in to comment.