Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

prepare_data_set.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!usr/bin/env python
  2. # -*- coding: utf8 -*-
  3. # -----------------------------------------------------------------------------
  4. # File: prepare_data_set.py (as part of project URUMETRICS)
  5. # Created: 20/05/2022 15:48
  6. # Last Modified: 20/05/2022 15:48
  7. # -----------------------------------------------------------------------------
  8. # Author: William N. Havard
  9. # Postdoctoral Researcher
  10. #
  11. # Mail : william.havard@ens.fr / william.havard@gmail.com
  12. #
  13. # Institution: ENS / Laboratoire de Sciences Cognitives et Psycholinguistique
  14. #
  15. # ------------------------------------------------------------------------------
  16. # Description:
  17. # • This script creates all the necessary directories to drop and
  18. # process the annotation files.
  19. # -----------------------------------------------------------------------------
  20. import logging
  21. import os
  22. from consts import ANNOTATION_TYPES
  23. logger = logging.getLogger(__name__)
  24. def create_child_project_directories(data_path):
  25. """
  26. Creates all the directories required by ChildProject
  27. :param data_path: path where the directories should be created
  28. :type data_path: str
  29. :return: None
  30. :rtype: None
  31. """
  32. child_project_dirs = [os.path.join(data_path, 'extra'),
  33. os.path.join(data_path, 'metadata'),
  34. os.path.join(data_path, 'annotations'),
  35. os.path.join(data_path, 'recordings', 'raw')]
  36. annotations_dir = [os.path.join(data_path, 'annotations', ann_type.value[0], 'raw')
  37. for ann_type in ANNOTATION_TYPES]
  38. all_dirs = child_project_dirs + annotations_dir
  39. for p in all_dirs:
  40. git_keep = os.path.join(p, '.gitkeep')
  41. if not os.path.exists(p):
  42. os.makedirs(p)
  43. open(git_keep, 'a').close()
  44. else:
  45. logging.info('{} already exists.'.format(p))
  46. def main(project_path):
  47. create_child_project_directories(project_path)
  48. def _parse_args(argv):
  49. import argparse
  50. parser = argparse.ArgumentParser(description='Create a ChildProject data set.')
  51. parser.add_argument('--project-path', required=False, type=str, default='',
  52. help="Path to a ChildProject/datalad project (useful for debugging purposes).")
  53. args = parser.parse_args(argv)
  54. return vars(args)
  55. if __name__ == '__main__':
  56. import sys
  57. pgrm_name, argv = sys.argv[0], sys.argv[1:]
  58. args = _parse_args(argv)
  59. logging.basicConfig(level=logging.INFO)
  60. try:
  61. main(**args)
  62. sys.exit(0)
  63. except Exception as e:
  64. print(e)
  65. sys.exit(1)