# cwltool.cwlprov.writablebagfile

Stores class definition of ResearchObject and WritableBagFile.

## Classes

`WritableBagFile` | Writes files in research object.

## Functions

`write_bag_file`(research_object, path[, encoding]) | Write the bag file into our research object.
`open_log_file_for_activity`(research_object, uuid_uri) | Begin the per-activity log.
`close_ro`(research_object[, save_to]) | Close the Research Object, optionally saving to specified folder.
`packed_workflow`(research_object, packed) | Pack CWL description to generate re-runnable CWL object in RO.
`create_job`(research_object, builder_job[, is_output]) | Generate the new job object with RO specific relative paths.

## Module Contents

class cwltool.cwlprov.writablebagfile.WritableBagFile(research_object, rel_path)

  Bases: `io.FileIO`

  Writes files in research object.

  Parameters:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - rel_path (str)

  research_object
  rel_path
  hashes
  write(b)

    Write some content to the Bag.

    Parameters:

      b (Any)

    Return type:

      int

  close()

    Flush and close this stream.

    Finalize checksums and manifests.

    Return type:

      None

  seekable()

    Return False, seeking is not supported.

    Return type:

      bool

  readable()

    Return False, reading is not supported.

    Return type:

      bool

  truncate(size=None)

    Resize the stream, only if we haven’t started writing.

    Parameters:

      size (int | None)

    Return type:

      int

cwltool.cwlprov.writablebagfile.write_bag_file(research_object, path, encoding=ENCODING)

  Write the bag file into our research object.

  Parameters:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - path (str)

    - encoding (str | None)

  Return type:

    io.TextIOWrapper | WritableBagFile

cwltool.cwlprov.writablebagfile.open_log_file_for_activity(research_object, uuid_uri)

  Begin the per-activity log.

  Parameters:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - uuid_uri (str)

  Return type:

    io.TextIOWrapper | WritableBagFile

cwltool.cwlprov.writablebagfile.close_ro(research_object, 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:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - save_to (str | None)

  Return type:

    None

cwltool.cwlprov.writablebagfile.packed_workflow(research_object, packed)

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

  Parameters:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - packed (str)

  Return type:

    None

cwltool.cwlprov.writablebagfile.create_job(research_object, builder_job, is_output=False)

  Generate the new job object with RO specific relative paths.

  Parameters:

    - research_object (cwltool.cwlprov.ro.ResearchObject)

    - builder_job (cwl_utils.types.CWLObjectType)

    - is_output (bool)

  Return type:

    cwl_utils.types.CWLObjectType