X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/fab8c884b8aec06d2eefa4d2fd935deacd7290ec..ae92d144610446849eb568247a44f02ae985c281:/tools/vocabulary-migrate/vocabulary-migrate.py diff --git a/tools/vocabulary-migrate/vocabulary-migrate.py b/tools/vocabulary-migrate/vocabulary-migrate.py index e729838858..89a4f030e8 100644 --- a/tools/vocabulary-migrate/vocabulary-migrate.py +++ b/tools/vocabulary-migrate/vocabulary-migrate.py @@ -1,9 +1,8 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (C) The Arvados Authors. All rights reserved. # -# SPDX-License-Identifier: AGPL-3.0 -# +# SPDX-License-Identifier: CC-BY-SA-3.0 import argparse import copy @@ -22,7 +21,7 @@ class VocabularyError(Exception): pass opts = argparse.ArgumentParser(add_help=False) -opts.add_argument('--vocabulary-file', type=str, metavar='PATH', default=None, +opts.add_argument('--vocabulary-file', type=str, metavar='PATH', required=True, help=""" Use vocabulary definition file at PATH for migration decisions. """) @@ -43,9 +42,7 @@ def parse_arguments(arguments): args = arg_parser.parse_args(arguments) if args.debug: logger.setLevel(logging.DEBUG) - if args.vocabulary_file is None: - arg_parser.error('Please specify the vocabulary file with --vocabulary-file') - elif not os.path.isfile(args.vocabulary_file): + if not os.path.isfile(args.vocabulary_file): arg_parser.error("{} doesn't exist or isn't a file.".format(args.vocabulary_file)) return args @@ -96,6 +93,7 @@ def main(arguments=None): for resource in [arv.collections(), arv.groups()]: objs = arvados.util.list_all( resource.list, + order=['created_at'], select=['uuid', 'properties'], filters=[['properties', 'exists', key_label]] ) @@ -113,8 +111,10 @@ def main(arguments=None): if not args.dry_run and migrated_counter % 100 == 0: logger.info('Migrating {} objects...'.format(migrated_counter)) - if not args.dry_run: - logger.info('Done, total object migrated: {}.'.format(migrated_counter)) + if args.dry_run and migrated_counter == 0: + logger.info('Nothing to do.') + elif not args.dry_run: + logger.info('Done, total objects migrated: {}.'.format(migrated_counter)) return 0 if __name__ == "__main__":