cli.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import logging
  2. import argparse
  3. from . import S3Concat
  4. logging.basicConfig(
  5. level=logging.INFO,
  6. format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
  7. )
  8. def cli():
  9. parser = argparse.ArgumentParser(description='Convert data files')
  10. parser.add_argument("--bucket",
  11. help="base bucket to use",
  12. required=True,
  13. )
  14. parser.add_argument("--folder",
  15. help="folder whose contents should be combined",
  16. required=True,
  17. )
  18. parser.add_argument("--output",
  19. help=("output location for resulting merged files,"
  20. " relative to the specified base bucket"),
  21. required=True,
  22. )
  23. parser.add_argument("--filesize",
  24. help=("Use to create multiple files if needed."
  25. " Min filesize of the concatenated files"
  26. " in [B,KB,MB,GB,TB]. e.x. 5.2GB"),
  27. default=None,
  28. )
  29. parser.add_argument("--small-parts-threads",
  30. type=int,
  31. help=("[Advanced Usage] Number of threads to"
  32. " download small parts with. (Default: 1)"),
  33. default=1)
  34. args = parser.parse_args()
  35. job = S3Concat(args.bucket, args.output, args.filesize)
  36. job.add_files(args.folder)
  37. job.concat(small_parts_threads=args.small_parts_threads)