store.py 796 B

12345678910111213141516171819202122232425262728
  1. # Copyright (c) Meta Platforms, Inc. and affiliates.
  2. # All rights reserved.
  3. # This source code is licensed under the license found in the
  4. # LICENSE file in the root directory of this source tree.
  5. from typing import Dict
  6. from data.data_types import Video
  7. ALL_VIDEOS: Dict[str, Video] = []
  8. def set_videos(videos: Dict[str, Video]) -> None:
  9. """
  10. Set the videos available in the backend. The data is kept in-memory, but a future change could replace the
  11. in-memory storage with a database backend. This would also be more efficient when querying videos given a
  12. dataset name etc.
  13. """
  14. global ALL_VIDEOS
  15. ALL_VIDEOS = videos
  16. def get_videos() -> Dict[str, Video]:
  17. """
  18. Return the videos available in the backend.
  19. """
  20. global ALL_VIDEOS
  21. return ALL_VIDEOS