Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix changed measure URNs #386

Open
anneschuth opened this issue Nov 21, 2024 · 0 comments
Open

Fix changed measure URNs #386

anneschuth opened this issue Nov 21, 2024 · 0 comments

Comments

@anneschuth
Copy link
Member

Description

The URN's are changed/merged/squashed from the measures from AK.

Option to
(1) Remove existing projecten verwijderen and make them again

OR

(2)

#!/usr/bin/env python3
import os

import psycopg2
import requests


def find_urns(data):
    urns = []
    if isinstance(data, dict):
        for key, value in data.items():
            if key.lower() == 'urn':
                urns.append(value)
            else:
                urns.extend(find_urns(value))
    elif isinstance(data, list):
        for item in data:
            urns.extend(find_urns(item))
    return urns

if __name__ == '__main__':


    conn = psycopg2.connect(database = "amt",
                        user = "postgres",
                        host= 'localhost',
                        password = os.environ.get('POSTGRES_PASSWORD'),
                        port = 5432)

    cur = conn.cursor()
    cur.execute("SELECT name, system_card_json FROM algorithm")
    rows = cur.fetchall()
    cur.close()

    for row in rows:
        print(f"Analying algor:{row[0]}")
        data = row[1]
        urns = find_urns(data)

        for urn in urns:
            html_encoded_urn = urn.replace(":", "%3A")
            resulta = requests.get(f"https://task-registry.apps.digilab.network/requirements/urn/{html_encoded_urn}?version=latest")
            resultb = requests.get(f"https://task-registry.apps.digilab.network/measures/urn/{html_encoded_urn}?version=latest")
            resultc = requests.get(f"https://task-registry.apps.digilab.network/instruments/urn/{html_encoded_urn}?version=latest")

            result = [results.status_code for results in [resulta, resultb, resultc]]

            if not 200 in result:
                print(f"URN {urn} is invalid")
        print("  ")

@anneschuth anneschuth converted this from a draft issue Nov 21, 2024
@ravimeijerrig ravimeijerrig changed the title Fix changed measures Fix changed measure URNs Nov 21, 2024
@renateburema renateburema moved this from ♻ To Do to ✅ Done in 👾 AI Validation Team Planning Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

No branches or pull requests

1 participant