cwltool.provenance

Stores Research Object including provenance.

Module Contents

Classes

WritableBagFile

Writes files in research object.

ResearchObject

CWLProv Research Object.

Functions

checksum_copy(src_file, dst_file = None, hasher = Hasher, buffersize = 1024 * 1024)

Compute checksums while copying a file.

Attributes

Annotation

Aggregate

AuthoredBy

class cwltool.provenance.WritableBagFile(research_object, rel_path)

Bases: io.FileIO

Inheritance diagram of cwltool.provenance.WritableBagFile

Writes files in research object.

Parameters
write(self, b)

Write some content to the Bag.

Parameters

b (Any) –

Return type

int

close(self)

Close the file.

A closed file cannot be used for further I/O operations. close() may be called more than once without error.

Return type

None

seekable(self)

True if file supports random-access.

Return type

bool

readable(self)

True if file was opened in a read mode.

Return type

bool

truncate(self, size=None)

Truncate the file to at most size bytes and return the truncated size.

Size defaults to the current file position, as returned by tell(). The current file position is changed to the value of size.

Parameters

size (Optional[int]) –

Return type

int

cwltool.provenance.Annotation
cwltool.provenance.Aggregate
cwltool.provenance.AuthoredBy
class cwltool.provenance.ResearchObject(fsaccess, temp_prefix_ro='tmp', orcid='', full_name='')

CWLProv Research Object.

Parameters
self_check(self)

Raise ValueError if this RO is closed.

Return type

None

__str__(self)

Represent this RO as a string.

Return type

str

open_log_file_for_activity(self, uuid_uri)
Parameters

uuid_uri (str) –

Return type

Union[io.TextIOWrapper, WritableBagFile]

user_provenance(self, document)

Add the user provenance.

Parameters

document (prov.model.ProvDocument) –

Return type

None

write_bag_file(self, path, encoding=ENCODING)

Write the bag file into our research object.

Parameters
  • path (str) –

  • encoding (Optional[str]) –

Return type

Union[io.TextIOWrapper, WritableBagFile]

add_tagfile(self, path, timestamp=None)

Add tag files to our research object.

Parameters
  • path (str) –

  • timestamp (Optional[datetime.datetime]) –

Return type

None

add_uri(self, uri, timestamp=None)
Parameters
  • uri (str) –

  • timestamp (Optional[datetime.datetime]) –

Return type

Aggregate

add_annotation(self, about, content, motivated_by='oa:describing')

Cheap URI relativize for current directory and /.

Parameters
  • about (str) –

  • content (List[str]) –

  • motivated_by (str) –

Return type

str

generate_snapshot(self, prov_dep)

Copy all of the CWL files to the snapshot/ directory.

Parameters

prov_dep (cwltool.utils.CWLObjectType) –

Return type

None

packed_workflow(self, packed)

Pack CWL description to generate re-runnable CWL object in RO.

Parameters

packed (str) –

Return type

None

has_data_file(self, sha1hash)

Confirm the presence of the given file in the RO.

Parameters

sha1hash (str) –

Return type

bool

add_data_file(self, from_fp, timestamp=None, content_type=None)

Copy inputs to data/ folder.

Parameters
  • from_fp (IO[Any]) –

  • timestamp (Optional[datetime.datetime]) –

  • content_type (Optional[str]) –

Return type

str

add_to_manifest(self, rel_path, checksums)

Add files to the research object manifest.

Parameters
  • rel_path (str) –

  • checksums (Dict[str, str]) –

Return type

None

create_job(self, builder_job, is_output=False)

Generate the new job object with RO specific relative paths.

Parameters
  • builder_job (cwltool.utils.CWLObjectType) –

  • is_output (bool) –

Return type

cwltool.utils.CWLObjectType

close(self, save_to=None)

Close the Research Object, optionally saving to specified folder.

Closing will remove any temporary files used by this research object. After calling this method, this ResearchObject instance can no longer be used, except for no-op calls to .close().

The ‘saveTo’ folder should not exist - if it does, it will be deleted.

It is safe to call this function multiple times without the ‘saveTo’ argument, e.g. within a try..finally block to ensure the temporary files of this Research Object are removed.

Parameters

save_to (Optional[str]) –

Return type

None

cwltool.provenance.checksum_copy(src_file, dst_file=None, hasher=Hasher, buffersize=1024 * 1024)

Compute checksums while copying a file.

Parameters
  • src_file (IO[Any]) –

  • dst_file (Optional[IO[Any]]) –

  • hasher (Callable[[], hashlib._Hash]) –

  • buffersize (int) –

Return type

str