Skip to content

Conversation

mauzey1
Copy link
Collaborator

@mauzey1 mauzey1 commented Aug 28, 2025

NOTE: The CI tests are failing since the current nightly version of CMOR doesn't support the new headers.

This PR adds headers to CMIP6_coordinate.json and CMIP6_formula_terms.json as well as updating some of the header info in CMIP6_grids.json. It also adds checksums to headers computed from the JSON strings produced from the table JSON without the checksum attribute in the header. I used the following function to create these checksums.

import json
import hashlib

def create_md5(table_path: str) -> None:
    table: dict
    with open(table_path) as f:
        table = json.load(f)

    # Remove existing checksum if present
    prev_checksum: None|str = None
    if 'checksum' in table['Header']:
        prev_checksum = table['Header'].pop('checksum')
        print(f'{table_path} has checksum of {prev_checksum}')

    table_str = json.dumps(table, sort_keys=True)
    checksum = hashlib.md5(table_str.encode("utf8")).hexdigest()
    table['Header']['checksum'] = checksum

    if prev_checksum is not None and prev_checksum == checksum:
        print(f'{table_path} checksum unchanged')
    else:
        print(f'{table_path} has new checksum of {checksum}')
    
    with open(table_path, 'w') as f:
        json.dump(table, f, indent=4, separators=(", ", ": "))
        f.write('\n')

@mauzey1 mauzey1 requested a review from durack1 August 28, 2025 22:14
@durack1
Copy link
Contributor

durack1 commented Aug 29, 2025

@mauzey1 let's pick this up on Tuesday 2nd Sept

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants