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.

main.py 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import logging
  2. import click
  3. import dataclasses
  4. from tools.metadata_creator.mimic import create_metadata_from_dataset
  5. mdc_logger = logging.getLogger("metadata_creator")
  6. @dataclasses.dataclass
  7. class MDCContext:
  8. mapper_family: str
  9. @click.group()
  10. @click.pass_context
  11. @click.option("--verbose", is_flag=True, default=False, help="Increase progress output")
  12. @click.option("--quiet", is_flag=True, default=False, help="Do not write progress output")
  13. @click.option("--mapper-family", type=click.Choice(["git", "memory"]), default="git")
  14. def mdc(ctx, verbose, quiet, mapper_family):
  15. """
  16. MetaData Creator
  17. This tool uses the datalad metadata model API and creates
  18. algorithmically generated metadata structures. This is
  19. mainly to demonstrate and debug the datalad metadata model
  20. implementations.
  21. All metadata is algorithmically created or taken from the
  22. command arguments. No extractors are executed.
  23. By default the git-backend is used to persist models, but any
  24. implemented back can be used. The currently supported backends
  25. are: `git´ and `memory´.
  26. """
  27. if quiet:
  28. mdc_logger.setLevel(logging.FATAL)
  29. logging.basicConfig(level=logging.FATAL, format="mdc: %(message)s")
  30. if verbose:
  31. mdc_logger.setLevel(logging.DEBUG)
  32. logging.basicConfig(level=logging.DEBUG, format="mdc: %(message)s")
  33. ctx.obj = MDCContext(mapper_family=mapper_family)
  34. mdc_logger.debug(f"context object: {ctx.obj}")
  35. @mdc.command()
  36. @click.pass_context
  37. @click.argument("dataset_path", nargs=1)
  38. @click.argument("realm", nargs=1)
  39. @click.option("-p", "--parameter-set-count", type=int, default=1)
  40. def from_template(ctx, dataset_path, realm, parameter_set_count):
  41. """
  42. Create test metadata that mimics the structure of a dataset
  43. This command will create test metadata the reflects the structure
  44. of the given dataset. That is, the dataset tree represent the
  45. dataset containment hierarchy, the UUID set represents the UUIDs
  46. of the contained datasets and the file trees are modelled after
  47. the files in the datasets.
  48. \b
  49. Usage:
  50. from-template [DATASET_PATH] [REALM]
  51. DATASET_PATH: path of the datalad dataset the should be mimicked
  52. REALM: realm in which the metadata should be stored
  53. """
  54. create_metadata_from_dataset(
  55. ctx.obj.mapper_family,
  56. realm,
  57. dataset_path,
  58. parameter_set_count)
  59. def main():
  60. mdc(auto_envvar_prefix="METADATA_CREATOR")
  61. if __name__ == "__main__":
  62. main()