@@ -305,9 +305,11 @@ def __init__(self,
305
305
host_provenance , # type: bool
306
306
user_provenance , # type: bool
307
307
orcid , # type: str
308
+ fsaccess , # type: StdFsAccess
308
309
run_uuid = None # type: Optional[uuid.UUID]
309
310
): # type: (...) -> None
310
311
"""Initialize the provenance profile."""
312
+ self .fsaccess = fsaccess
311
313
self .orcid = orcid
312
314
self .research_object = research_object
313
315
self .folder = self .research_object .folder
@@ -504,8 +506,7 @@ def declare_file(self, value):
504
506
if not entity and 'location' in value :
505
507
location = str (value ['location' ])
506
508
# If we made it here, we'll have to add it to the RO
507
- fsaccess = StdFsAccess ("" )
508
- with fsaccess .open (location , "rb" ) as fhandle :
509
+ with self .fsaccess .open (location , "rb" ) as fhandle :
509
510
relative_path = self .research_object .add_data_file (fhandle )
510
511
# FIXME: This naively relies on add_data_file setting hash as filename
511
512
checksum = PurePath (relative_path ).name
@@ -597,8 +598,7 @@ def declare_directory(self, value): # type: (MutableMapping[Text, Any]) -> Prov
597
598
is_empty = True
598
599
599
600
if "listing" not in value :
600
- fsaccess = StdFsAccess ("" )
601
- get_listing (fsaccess , value )
601
+ get_listing (self .fsaccess , value )
602
602
for entry in value .get ("listing" , []):
603
603
is_empty = False
604
604
# Declare child-artifacts
@@ -945,8 +945,8 @@ def finalize_prov_profile(self, name):
945
945
class ResearchObject ():
946
946
"""CWLProv Research Object."""
947
947
948
- def __init__ (self , temp_prefix_ro = "tmp" , orcid = '' , full_name = '' ):
949
- # type: (str, Text, Text) -> None
948
+ def __init__ (self , fsaccess , temp_prefix_ro = "tmp" , orcid = '' , full_name = '' ):
949
+ # type: (StdFsAccess, str, Text, Text) -> None
950
950
"""Initialize the ResearchObject."""
951
951
self .temp_prefix = temp_prefix_ro
952
952
self .orcid = '' if not orcid else _valid_orcid (orcid )
@@ -962,7 +962,7 @@ def __init__(self, temp_prefix_ro="tmp", orcid='', full_name=''):
962
962
self ._external_aggregates = [] # type: List[Dict[Text, Text]]
963
963
self .annotations = [] # type: List[Dict[Text, Any]]
964
964
self ._content_types = {} # type: Dict[Text,str]
965
-
965
+ self . fsaccess = fsaccess
966
966
# These should be replaced by generate_prov_doc when workflow/run IDs are known:
967
967
self .engine_uuid = "urn:uuid:%s" % uuid .uuid4 ()
968
968
self .ro_uuid = uuid .uuid4 ()
@@ -1561,8 +1561,7 @@ def _relativise_files(self, structure):
1561
1561
# Register in RO; but why was this not picked
1562
1562
# up by used_artefacts?
1563
1563
_logger .info ("[provenance] Adding to RO %s" , structure ["location" ])
1564
- fsaccess = StdFsAccess ("" )
1565
- with fsaccess .open (structure ["location" ], "rb" ) as fp :
1564
+ with self .fsaccess .open (structure ["location" ], "rb" ) as fp :
1566
1565
relative_path = self .add_data_file (fp )
1567
1566
checksum = PurePosixPath (relative_path ).name
1568
1567
structure ["checksum" ] = "%s$%s" % (SHA1 , checksum )
0 commit comments