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.

uuidsetcreator.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import sys
  2. import time
  3. from typing import Dict, List, Optional, Tuple
  4. from uuid import UUID
  5. from dataladmetadatamodel.metadatarootrecord import MetadataRootRecord
  6. from dataladmetadatamodel.uuidset import UUIDSet
  7. from dataladmetadatamodel.versionlist import VersionList
  8. from tools.metadata_creator.mrrcreator import create_metadata_root_record
  9. from tools.metadata_creator.utils import get_dataset_id, get_dataset_version, read_datasets
  10. def create_uuid_set(mapper_family: str,
  11. realm: str,
  12. path: str,
  13. parameter_set_count: int
  14. ) -> Optional[UUIDSet]:
  15. uuid_set = UUIDSet(mapper_family, realm)
  16. for path, dir_entry in read_datasets(path):
  17. dataset_id = get_dataset_id(dir_entry.path)
  18. if dataset_id is None:
  19. print(f"cannot determine id of dataset at {dir_entry.path}", file=sys.stderr)
  20. continue
  21. version = get_dataset_version(dir_entry.path)
  22. if version is None:
  23. print(f"cannot determine version of dataset at {dir_entry.path}", file=sys.stderr)
  24. continue
  25. version_list = VersionList()
  26. version_list.set_versioned_element(
  27. version,
  28. str(time.time()),
  29. path,
  30. create_metadata_root_record(
  31. mapper_family,
  32. realm,
  33. dataset_id,
  34. version,
  35. dir_entry.path,
  36. path,
  37. parameter_set_count
  38. )
  39. )
  40. uuid_set.set_version_list(
  41. dataset_id,
  42. version_list
  43. )
  44. return uuid_set
  45. def create_uuid_set_for_mrrs(mapper_family: str,
  46. realm: str,
  47. metadata_root_records: Dict[Tuple[UUID, str, str], MetadataRootRecord]
  48. ) -> UUIDSet:
  49. uuid_version_list = dict()
  50. uuid_set = UUIDSet(mapper_family, realm)
  51. for id_version_path, metadata_root_record in metadata_root_records.items():
  52. uuid, dataset_version, relative_path = id_version_path
  53. version_list = uuid_version_list.get(
  54. uuid,
  55. VersionList())
  56. version_list.set_versioned_element(
  57. dataset_version,
  58. str(time.time()),
  59. relative_path,
  60. metadata_root_record
  61. )
  62. uuid_version_list[uuid] = version_list
  63. for uuid, version_list in uuid_version_list.items():
  64. uuid_set.set_version_list(uuid, version_list)
  65. return uuid_set