12Script to upload local database to ConditionsDB.
14This script takes a local database file and will upload all payloads defined in
15this file to the ConditionsDB and create iovs for each payload. It assumes that
16all tags already exist.
19from basf2
import LogInfo, LogLevel, logging
20from conditions_db
import set_cdb_authentication_token
23def command_upload(args, db=None):
25 Upload a local database to the conditions database.
27 This command allows uploading a local database which was created by basf2 to
28 the central database. It assumes that the globaltag already exists so
29 please create it before if necessary using
'tag create'.
31 The command requires the tagname to upload the payloads to
and a
32 database.txt containing the payloads
and their iovs. One can supply a
33 directory where to look
for the payloads, by default they are assumed to be
34 in the same directory
as the database text file.
38 args.add_argument(
"tag", metavar=
"TAGNAME",
39 help=
"globaltag to use for iov creation")
40 args.add_argument(
"payloadsfile", metavar=
"PAYLOADSFILE",
41 help=
"Testing payload storage file containing list of iovs")
42 normalize_group = args.add_mutually_exclusive_group()
43 normalize_group.add_argument(
'--normalize', dest=
"normalize", default=
False, action=
"store_true",
44 help=
"Normalize the payload files to have reproducible checksums. "
45 "This option should only be used if the payload files were created "
46 "with an older software version (before release-04)")
47 normalize_group.add_argument(
'--normalize-name', type=str,
48 help=
"Set the file name in the root file metadata to the given value. "
49 "This implicitly enables ``--normalize`` and should only be used if "
50 "the payload files were created with an older software version (before release-04)")
51 args.add_argument(
"-j", type=int, default=1, dest=
"nprocess",
52 help=
"Number of concurrent connections to use for database "
53 "connection (default: %(default)s)")
54 args.add_argument(
"--retries", type=int, default=3,
55 help=
"Number of retries on connection problems (default: "
57 args.add_argument(
"--ignore-existing", action=
"store_true", default=
False,
58 help=
"Don't check if payloads or iovs already exist in database. "
59 "Speeds up initialization as the list of existing payloads "
60 "doesn't need to be downloaded. Can be used on first upload "
61 "but the script cannot resume an upload if this option is given")
64 set_cdb_authentication_token(db, args.auth_token)
67 for level
in LogLevel.values.values():
68 logging.set_info(level, LogInfo.LEVEL | LogInfo.MESSAGE | LogInfo.TIMESTAMP)
71 normalize = args.normalize_name
if args.normalize_name
is not None else args.normalize
72 return 0
if db.upload(args.payloadsfile, args.tag, normalize, args.ignore_existing, args.nprocess)
else 1