@@ -305,9 +305,11 @@ def __init__(self,
305305 host_provenance , # type: bool
306306 user_provenance , # type: bool
307307 orcid , # type: str
308+ fsaccess , # type: StdFsAccess
308309 run_uuid = None # type: Optional[uuid.UUID]
309310 ): # type: (...) -> None
310311 """Initialize the provenance profile."""
312+ self .fsaccess = fsaccess
311313 self .orcid = orcid
312314 self .research_object = research_object
313315 self .folder = self .research_object .folder
@@ -504,8 +506,7 @@ def declare_file(self, value):
504506 if not entity and 'location' in value :
505507 location = str (value ['location' ])
506508 # 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 :
509510 relative_path = self .research_object .add_data_file (fhandle )
510511 # FIXME: This naively relies on add_data_file setting hash as filename
511512 checksum = PurePath (relative_path ).name
@@ -597,8 +598,7 @@ def declare_directory(self, value): # type: (MutableMapping[Text, Any]) -> Prov
597598 is_empty = True
598599
599600 if "listing" not in value :
600- fsaccess = StdFsAccess ("" )
601- get_listing (fsaccess , value )
601+ get_listing (self .fsaccess , value )
602602 for entry in value .get ("listing" , []):
603603 is_empty = False
604604 # Declare child-artifacts
@@ -945,8 +945,8 @@ def finalize_prov_profile(self, name):
945945class ResearchObject ():
946946 """CWLProv Research Object."""
947947
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
950950 """Initialize the ResearchObject."""
951951 self .temp_prefix = temp_prefix_ro
952952 self .orcid = '' if not orcid else _valid_orcid (orcid )
@@ -962,7 +962,7 @@ def __init__(self, temp_prefix_ro="tmp", orcid='', full_name=''):
962962 self ._external_aggregates = [] # type: List[Dict[Text, Text]]
963963 self .annotations = [] # type: List[Dict[Text, Any]]
964964 self ._content_types = {} # type: Dict[Text,str]
965-
965+ self . fsaccess = fsaccess
966966 # These should be replaced by generate_prov_doc when workflow/run IDs are known:
967967 self .engine_uuid = "urn:uuid:%s" % uuid .uuid4 ()
968968 self .ro_uuid = uuid .uuid4 ()
@@ -1561,8 +1561,7 @@ def _relativise_files(self, structure):
15611561 # Register in RO; but why was this not picked
15621562 # up by used_artefacts?
15631563 _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 :
15661565 relative_path = self .add_data_file (fp )
15671566 checksum = PurePosixPath (relative_path ).name
15681567 structure ["checksum" ] = "%s$%s" % (SHA1 , checksum )
0 commit comments