(self, bundle_file, bundle_description=None)
Writes a generator_pb2.GeneratorBundle file in the specified location.

    Saves the checkpoint, metagraph, and generator id in one file.

    Args:
      bundle_file: Location to write the bundle file.
      bundle_description: A short, human-readable string description of this
          bundle.

    Raises:
      SequenceGeneratorError: if there is an error creating the bundle file.
Writes a generator_pb2.GeneratorBundle file in the specified location.
Writes a generator_pb2 . GeneratorBundle file in the specified location .
def create_bundle_file(self, bundle_file, bundle_description=None):
    """Writes a generator_pb2.GeneratorBundle file in the specified location.

    Saves the checkpoint, metagraph, and generator id in one file.

    Args:
      bundle_file: Location to write the bundle file.
      bundle_description: A short, human-readable string description of this
          bundle.

    Raises:
      SequenceGeneratorError: if there is an error creating the bundle file.
    """
    if not bundle_file:
      raise SequenceGeneratorError('Bundle file location not specified.')
    if not self.details.id:
      raise SequenceGeneratorError(
          'Generator id must be included in GeneratorDetails when creating '
          'a bundle file.')

    if not self.details.description:
      tf.logging.warn('Writing bundle file with no generator description.')
    if not bundle_description:
      tf.logging.warn('Writing bundle file with no bundle description.')

    self.initialize()

    tempdir = None
    try:
      tempdir = tempfile.mkdtemp()
      checkpoint_filename = os.path.join(tempdir, 'model.ckpt')

      self._model.write_checkpoint_with_metagraph(checkpoint_filename)

      if not os.path.isfile(checkpoint_filename):
        raise SequenceGeneratorError(
            'Could not read checkpoint file: %s' % (checkpoint_filename))
      metagraph_filename = checkpoint_filename + '.meta'
      if not os.path.isfile(metagraph_filename):
        raise SequenceGeneratorError(
            'Could not read metagraph file: %s' % (metagraph_filename))

      bundle = generator_pb2.GeneratorBundle()
      bundle.generator_details.CopyFrom(self.details)
      if bundle_description:
        bundle.bundle_details.description = bundle_description
      with tf.gfile.Open(checkpoint_filename, 'rb') as f:
        bundle.checkpoint_file.append(f.read())
      with tf.gfile.Open(metagraph_filename, 'rb') as f:
        bundle.metagraph_file = f.read()

      with tf.gfile.Open(bundle_file, 'wb') as f:
        f.write(bundle.SerializeToString())
    finally:
      if tempdir is not None:
        tf.gfile.DeleteRecursively(tempdir)
def create_bundle_file ( self , bundle_file , bundle_description = None ) : if not bundle_file : raise SequenceGeneratorError ( 'Bundle file location not specified.' ) if not self . details . id : raise SequenceGeneratorError ( 'Generator id must be included in GeneratorDetails when creating ' 'a bundle file.' ) if not self . details . description : tf . logging . warn ( 'Writing bundle file with no generator description.' ) if not bundle_description : tf . logging . warn ( 'Writing bundle file with no bundle description.' ) self . initialize ( ) tempdir = None try : tempdir = tempfile . mkdtemp ( ) checkpoint_filename = os . path . join ( tempdir , 'model.ckpt' ) self . _model . write_checkpoint_with_metagraph ( checkpoint_filename ) if not os . path . isfile ( checkpoint_filename ) : raise SequenceGeneratorError ( 'Could not read checkpoint file: %s' % ( checkpoint_filename ) ) metagraph_filename = checkpoint_filename + '.meta' if not os . path . isfile ( metagraph_filename ) : raise SequenceGeneratorError ( 'Could not read metagraph file: %s' % ( metagraph_filename ) ) bundle = generator_pb2 . GeneratorBundle ( ) bundle . generator_details . CopyFrom ( self . details ) if bundle_description : bundle . bundle_details . description = bundle_description with tf . gfile . Open ( checkpoint_filename , 'rb' ) as f : bundle . checkpoint_file . append ( f . read ( ) ) with tf . gfile . Open ( metagraph_filename , 'rb' ) as f : bundle . metagraph_file = f . read ( ) with tf . gfile . Open ( bundle_file , 'wb' ) as f : f . write ( bundle . SerializeToString ( ) ) finally : if tempdir is not None : tf . gfile . DeleteRecursively ( tempdir )