|
35 | 35 | logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') |
36 | 36 |
|
37 | 37 | def check_records(path, check_dir="working"): |
38 | | - rec_path = '/'.join([args.base_path, path, check_dir]) + '/' |
39 | | - recs = get_recs(spec_path="../records/" + path, path_to_recs=rec_path) |
40 | | - stat = True |
41 | | - if len(recs) == 0: |
42 | | - print("No records to check in: " + rec_path) |
43 | | - else: |
44 | | - print("Testing syntax of %s curation records." % len(recs)) |
45 | | - if False in recs: |
46 | | - stat = False |
47 | | - return stat |
| 38 | + """ |
| 39 | + Checks the records in the specified directory. |
| 40 | + |
| 41 | + Parameters: |
| 42 | + path (str): The base path to check records in. |
| 43 | + check_dir (str): The directory within the base path to check records in. |
| 44 | + |
| 45 | + Returns: |
| 46 | + bool: True if records pass the check, False otherwise. |
| 47 | + """ |
| 48 | + try: |
| 49 | + logging.debug("Starting check_records with path: %s and check_dir: %s", path, check_dir) |
| 50 | + rec_path = '/'.join([args.base_path, path, check_dir]) + '/' |
| 51 | + logging.debug("Constructed rec_path: %s", rec_path) |
| 52 | + |
| 53 | + recs = get_recs(spec_path="../records/" + path, path_to_recs=rec_path) |
| 54 | + logging.debug("Retrieved records: %s", recs) |
| 55 | + |
| 56 | + stat = True |
| 57 | + if len(recs) == 0: |
| 58 | + logging.info("No records to check in: %s", rec_path) |
| 59 | + else: |
| 60 | + logging.info("Testing syntax of %s curation records.", len(recs)) |
| 61 | + |
| 62 | + if False in recs: |
| 63 | + logging.warning("Some records failed the check.") |
| 64 | + stat = False |
| 65 | + |
| 66 | + return stat |
| 67 | + |
| 68 | + except Exception as e: |
| 69 | + logging.error("An error occurred in check_records: %s", e, exc_info=True) |
| 70 | + return False |
48 | 71 |
|
49 | 72 | def load_records(path, load_dir="to_submit"): |
50 | | - rec_path = os.path.abspath(os.path.join(args.base_path, path, load_dir)) |
51 | | - current_dir = os.path.dirname(os.path.realpath(__file__)) |
52 | | - records_path = os.path.abspath(os.path.join(current_dir, "../records", path)) |
53 | | - stat = load_recs(records_path + '/', rec_path + '/', |
54 | | - args.endpoint, args.usr, args.pwd, import_filepath=args.import_filepath, |
55 | | - commit=args.commit, verbose=args.verbose, allow_duplicates=args.allow_duplicates) |
56 | | - return stat |
| 73 | + """ |
| 74 | + Loads the records from the specified directory. |
| 75 | + |
| 76 | + Parameters: |
| 77 | + path (str): The base path to load records from. |
| 78 | + load_dir (str): The directory within the base path to load records from. |
| 79 | + |
| 80 | + Returns: |
| 81 | + bool: True if records are successfully loaded, False otherwise. |
| 82 | + """ |
| 83 | + try: |
| 84 | + logging.debug("Starting load_records with path: %s and load_dir: %s", path, load_dir) |
| 85 | + rec_path = os.path.abspath(os.path.join(args.base_path, path, load_dir)) |
| 86 | + logging.debug("Constructed rec_path: %s", rec_path) |
| 87 | + |
| 88 | + current_dir = os.path.dirname(os.path.realpath(__file__)) |
| 89 | + records_path = os.path.abspath(os.path.join(current_dir, "../records", path)) |
| 90 | + logging.debug("Constructed records_path: %s", records_path) |
| 91 | + |
| 92 | + stat = load_recs(records_path + '/', rec_path + '/', |
| 93 | + args.endpoint, args.usr, args.pwd, import_filepath=args.import_filepath, |
| 94 | + commit=args.commit, verbose=args.verbose, allow_duplicates=args.allow_duplicates) |
| 95 | + |
| 96 | + logging.debug("load_recs returned status: %s", stat) |
| 97 | + return stat |
| 98 | + |
| 99 | + except Exception as e: |
| 100 | + logging.error("An error occurred in load_records: %s", e, exc_info=True) |
| 101 | + return False |
57 | 102 |
|
58 | 103 | stat = True |
59 | 104 |
|
|
0 commit comments