diff --git a/src/runcrate/convert.py b/src/runcrate/convert.py index 0d76432..6957b56 100644 --- a/src/runcrate/convert.py +++ b/src/runcrate/convert.py @@ -566,6 +566,8 @@ def add_action_params(self, crate, activity, to_wf_p, ptype="usage"): )) if len(action_p["exampleOfWork"]) == 1: action_p["exampleOfWork"] = action_p["exampleOfWork"][0] + if ptype == "generation": + action_p["dateCreated"] = rel.time.isoformat() action_params.append(action_p) return action_params @@ -606,6 +608,7 @@ def convert_param(self, prov_param, crate, convert_secondary=True, parent=None): source = self.manifest[hash_] action_p = crate.add_file(source, dest, properties={ "sha1": hash_, + "contentSize": str(Path(source).stat().st_size) }) self._set_alternate_name(prov_param, action_p, parent=parent) try: diff --git a/tests/test_cwlprov_crate_builder.py b/tests/test_cwlprov_crate_builder.py index 416351f..2ec6f9c 100644 --- a/tests/test_cwlprov_crate_builder.py +++ b/tests/test_cwlprov_crate_builder.py @@ -95,10 +95,13 @@ def test_revsort(data_dir, tmpdir): assert "File" in entity.type assert entity["alternateName"] == "whale.txt" assert entity["sha1"] == entity.id.rsplit("/")[-1] + assert entity["contentSize"] == "1111" wf_input_file = entity wf_output_file = wf_results[0] assert wf_output_file["alternateName"] == "output.txt" assert wf_output_file["sha1"] == wf_output_file.id.rsplit("/")[-1] + assert wf_output_file["dateCreated"] == "2018-10-25T15:46:38.058365" + assert wf_output_file["contentSize"] == "1111" assert "File" in wf_output_file.type steps = workflow["step"] assert len(steps) == 2 @@ -118,6 +121,8 @@ def test_revsort(data_dir, tmpdir): assert rev_input_file is wf_input_file rev_output_file = results[0] assert "File" in rev_output_file.type + assert rev_output_file["dateCreated"] == "2018-10-25T15:46:36.963254" + assert rev_output_file["contentSize"] == "1111" assert step["position"] == "0" assert set(_connected(step)) == set([ ("packed.cwl#main/input", "packed.cwl#revtool.cwl/input"), @@ -357,6 +362,7 @@ def test_dir_io(data_dir, tmpdir): assert "Dataset" in entity.type wf_input_dir = entity wf_output_dir = wf_results[0] + assert wf_output_dir["dateCreated"] == "2023-02-17T16:20:30.288242" assert wf_input_dir.type == wf_output_dir.type == "Dataset" assert wf_input_dir["alternateName"] == "grepucase_in" assert len(wf_input_dir["hasPart"]) == 2 @@ -395,6 +401,7 @@ def test_dir_io(data_dir, tmpdir): assert greptool_input_dir is wf_input_dir greptool_output_dir = greptool_results[0] assert "Dataset" in greptool_output_dir.type + assert greptool_output_dir["dateCreated"] == "2023-02-17T16:20:30.262141" ucasetool_action = action_map["packed.cwl#ucasetool.cwl"] ucasetool_objects = ucasetool_action["object"] ucasetool_results = ucasetool_action["result"]