Skip to content

Commit 3b3d3fb

Browse files
committed
feature: enable pickling for research objects
1 parent 57baa56 commit 3b3d3fb

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

cwltool/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ def main(argsl=None, # type: List[str]
583583
if not args.compute_checksum:
584584
_logger.error("--provenance incompatible with --no-compute-checksum")
585585
return 1
586-
ro = ResearchObject(runtimeContext.make_fs_access,
586+
ro = ResearchObject(
587587
temp_prefix_ro=args.tmpdir_prefix, orcid=args.orcid,
588588
full_name=args.cwl_full_name)
589589
runtimeContext.research_obj = ro

cwltool/provenance.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,7 @@ def declare_file(self, value):
514514
if not entity and 'location' in value:
515515
location = str(value['location'])
516516
# If we made it here, we'll have to add it to the RO
517-
assert self.research_object.make_fs_access
518-
fsaccess = self.research_object.make_fs_access("")
517+
fsaccess = StdFsAccess("")
519518
with fsaccess.open(location, "rb") as fhandle:
520519
relative_path = self.research_object.add_data_file(fhandle)
521520
# FIXME: This naively relies on add_data_file setting hash as filename
@@ -605,8 +604,7 @@ def declare_directory(self, value): # type: (MutableMapping) -> ProvEntity
605604
is_empty = True
606605

607606
if not "listing" in value:
608-
assert self.research_object.make_fs_access
609-
fsaccess = self.research_object.make_fs_access("")
607+
fsaccess = StdFsAccess("")
610608
get_listing(fsaccess, value)
611609
for entry in value.get("listing", []):
612610
is_empty = False
@@ -943,10 +941,9 @@ def finalize_prov_profile(self, name):
943941
class ResearchObject():
944942
"""CWLProv Research Object."""
945943

946-
def __init__(self, make_fs_access, temp_prefix_ro="tmp", orcid='', full_name=''):
947-
# type: (Callable[[Text], StdFsAccess], str, Text, Text) -> None
944+
def __init__(self, temp_prefix_ro="tmp", orcid='', full_name=''):
945+
# type: (str, Text, Text) -> None
948946

949-
self.make_fs_access = make_fs_access
950947
self.temp_prefix = temp_prefix_ro
951948
self.orcid = '' if not orcid else _valid_orcid(orcid)
952949
self.full_name = full_name
@@ -1553,7 +1550,7 @@ def _relativise_files(self, structure):
15531550
# Register in RO; but why was this not picked
15541551
# up by used_artefacts?
15551552
_logger.info("[provenance] Adding to RO %s", structure["location"])
1556-
fsaccess = self.make_fs_access("")
1553+
fsaccess = StdFsAccess("")
15571554
with fsaccess.open(structure["location"], "rb") as fp:
15581555
relative_path = self.add_data_file(fp)
15591556
checksum = posixpath.basename(relative_path)

cwltool/workflow.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,6 @@ def job(self,
572572
builder = self._init_job(job_order, runtimeContext)
573573
#relativeJob=copy.deepcopy(builder.job)
574574
if runtimeContext.research_obj is not None:
575-
if not runtimeContext.research_obj.make_fs_access:
576-
runtimeContext.research_obj.make_fs_access = runtimeContext.make_fs_access
577575
if runtimeContext.toplevel:
578576
# Record primary-job.json
579577
runtimeContext.research_obj.create_job(builder.job, self.job)

tests/test_provenance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def test_failing_path_conversion(path, from_type, to_type):
533533

534534
@pytest.fixture
535535
def research_object():
536-
re_ob = provenance.ResearchObject(RuntimeContext().make_fs_access)
536+
re_ob = provenance.ResearchObject()
537537
yield re_ob
538538
re_ob.close()
539539

0 commit comments

Comments
 (0)