in retail/recommendation-system/bqml-scann/tfx_pipeline/scann_indexer.py [0:0]
def save_index(index, tokens, output_dir):
logging.info('Saving index as a SavedModel...')
module = index.serialize_to_module()
tf.saved_model.save(
module, output_dir, signatures=None, options=None
)
logging.info(f'Index is saved to {output_dir}')
logging.info(f'Saving tokens file...')
tokens_file_path = os.path.join(output_dir, TOKENS_FILE_NAME)
with tf.io.gfile.GFile(tokens_file_path, 'wb') as handle:
pickle.dump(tokens, handle, protocol=pickle.HIGHEST_PROTOCOL)
logging.info(f'Item file is saved to {tokens_file_path}.')