Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# (c) Stefan Countryman, 2019
3"""
4Use ``llama dev data i3`` to fetch archival neutrino data and store it securely
5on LLAMA's AWS S3/DigitalOcean Spaces storage. You can use this script to see
6which archival neutrino releases are available from IceCube servers and to
7transfer that data to private S3 storage. The printed code can be added to the
8LLAMA codebase under ``llama.files.s3.json.ARCHIVAL_NEUTRINOS``; it will allow
9you to access the archival neutrino data stored on LLAMA servers *if* you have
10proper LLAMA S3 authentication credentials on your computer (allowing for
11proper reproducibility and faster data access). That data is only downloaded
12from LLAMA S3 when it is needed and is persisted in LLAMA's cache directory
13(see ``llama.utils.CACHEDIR``).
14"""
16from llama.cli import get_logging_cli, CliParser
17from llama.dev.data.i3 import (
18 DEFAULT_ROOT,
19 available_versions,
20 secure_transfer_to_s3,
21)
24def get_parser():
25 """Get CLI parser."""
26 parser = CliParser(description=__doc__,
27 parents=(get_logging_cli('/dev/null', 'info'),))
28 parser.add_argument("-a", "--available", action='store_true', help="""
29 Fetch available IceCube neutrino archive versions from the IceCube
30 servers, print them one-per-line, and exit.""")
31 parser.add_argument("-s", "--store-s3", metavar='ARCHIVE_VERSION', help="""
32 Fetch IceCube neutrino archives specified by the ``ARCHIVE_VERSION``,
33 upload them to LLAMA S3 storage, and print a block of code that can be
34 inserted into the ``llama.files.s3.json.ARCHIVAL_NEUTRINOS``
35 declaration to make these newly-stored archival neutrinos available to
36 pipeline users with LLAMA S3 credentials (see ``llama.com.s3``).""")
37 parser.add_argument("-r", "--archive-root", default=DEFAULT_ROOT, help="""
38 The root directory on IceCube's ``cobalt`` servers in which to search
39 for archival neutrinos (using ``--store-s3`` or ``--available``).""")
40 return parser
43def main():
44 """Run CLI."""
45 parser = get_parser()
46 args = parser.parse_args()
47 if args.available:
48 print('\n'.join(available_versions(root=args.archive_root)))
49 exit()
50 if args.store_s3 is not None:
51 print(secure_transfer_to_s3(args.store_s3, root=args.archive_root))
52 exit()
53 parser.print_help()
54 exit()