def save(df, path, write_frequency=5000):
        """
        Args:
            df (DataFlow): the DataFlow to serialize.
            path (str): output path. Either a directory or an lmdb file.
        """
        assert isinstance(df, DataFlow), type(df)
        assert not os.path.isfile(path), "DiskCache path {} must be a directory!".format(path)
        db = diskcache.Index(path)
        size = _reset_df_and_get_size(df)

        with get_tqdm(total=size) as pbar:
            idx = -1

            for idx, dp in enumerate(df):
                db[idx] = dumps(dp)
                pbar.update()

        Args:
            df (DataFlow): the DataFlow to serialize.
            path (str): output path. Either a directory or an lmdb file.
        
tensorpack/dataflow/serialize.py