File size: 936 Bytes
a557d54
 
 
c00ae85
a557d54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json

import jsonschema
import streamlit as st


def get_schema():
    """This function loads the given schema available"""
    with open("schema.json", "r", encoding="utf8") as file:
        schema = json.load(file)
    return schema


def validate_json(json_data):
    execute_api_schema = get_schema()
    try:
        jsonschema.validate(instance=json_data, schema=execute_api_schema)
    except jsonschema.exceptions.ValidationError as err:
        err = "Submission does not match GEM schema!"
        return False, err

    message = "Submission matches GEM schema!"
    return True, message


def validate_submission(submission_data):
    is_valid, message = validate_json(submission_data)

    if is_valid:
        st.write("All submission files validated! ✨ πŸš€ ✨")
        st.write("Now you can make a submission πŸ€—")
    else:
        st.write(message)
        st.write("Please fix the submission files πŸ™ˆ")