Skip to content
Snippets Groups Projects
Commit 820233a1 authored by Anjali Aggarwal's avatar Anjali Aggarwal
Browse files

validator and ingestor to scicat for pizza ontology

parent e8d09be1
No related branches found
No related tags found
1 merge request!14Resolve "pizza example"
Pipeline #119451 failed
No preview for this file type
......@@ -31,8 +31,8 @@ class SciCatClient:
if __name__ == "__main__":
SCICAT_API_URL = "http://scicat-rockit-p65-test1.desy.de/api/v3"
TOKEN = ""
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NTAxN2M1ODY4Yjg4NWVlMzJkYWQ4YzgiLCJ1c2VybmFtZSI6ImluZ2VzdG9yIiwiZW1haWwiOiJzY2ljYXRpbmdlc3RvckB5b3VyLnNpdGUiLCJhdXRoU3RyYXRlZ3kiOiJsb2NhbCIsIl9fdiI6MCwiaWQiOiI2NTAxN2M1ODY4Yjg4NWVlMzJkYWQ4YzgiLCJpYXQiOjE3MTgyNzc1MzMsImV4cCI6MTcxODMyMDczM30.QV7unKhciguIFsbv-f8A3FQewh93Bue2xGUjFoBckJk"
dataset_metadata = {
"principalInvestigator": "Dr. John Doe",
"owner": "Institution Name",
......
from linkml.validator import validate
from ingest_to_scicat import SciCatClient
import yaml
import requests
# instance ={'pizzas' :
# [{"id": "1",
# "title": "Margherita",
# "description": "Classic pizza with tomato sauce and mozzarella cheese.",
# "hasBase": ["ThinAndCrispyBase"],
# "hasTopping": ["MozzarellaTopping", "SlicedTomatoTopping"],
# "hasCountryOfOrigin": ["Italy"]}],
# }
with open('pizza_dataset.yaml') as yaml_data:
instance = yaml.safe_load(yaml_data)
report = validate(instance, "pizza.yaml", "PizzaCollection")
SCICAT_API_URL = "http://scicat-rockit-p65-test1.desy.de/api/v3"
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2NTAxN2M1ODY4Yjg4NWVlMzJkYWQ4YzgiLCJ1c2VybmFtZSI6ImluZ2VzdG9yIiwiZW1haWwiOiJzY2ljYXRpbmdlc3RvckB5b3VyLnNpdGUiLCJhdXRoU3RyYXRlZ3kiOiJsb2NhbCIsIl9fdiI6MCwiaWQiOiI2NTAxN2M1ODY4Yjg4NWVlMzJkYWQ4YzgiLCJpYXQiOjE3MTg2MTU4NTYsImV4cCI6MTcxODY1OTA1Nn0.Zdcq8Qy93HnVBZBFb5DhnIn0Zq71FUwCmObXJSfCdZo"
dataset_metadata = {
"principalInvestigator": "Dr. John Doe",
"owner": "Institution Name",
"contactEmail": "anjali@example.com",
"sourceFolder": "i am new",
"scientificMetadata":instance,
# "pid": "sdfsdfkjsdhfsd",
"size": 123456,
"creationLocation": "magrathea",
"creationTime": "2024-06-12T12:00:00Z",
"type": "raw",
"instrumentId": "Instrument001",
"proposalId": "Proposal001",
"dataFormat": "HDF5",
"isPublished": False,
"ownerGroup": "hasylab",
"accessGroups": ["Group001"],
"description": "Description of the dataset",
"keywords": ["example", "data", "keywords"],
"license": "CC BY 4.0"
}
client = SciCatClient(SCICAT_API_URL, TOKEN)
if not report.results:
print('The instance is valid!')
try:
response = client.upload_dataset(dataset_metadata)
print("Dataset uploaded successfully:", response)
except requests.exceptions.HTTPError as err:
print("Error uploading dataset:", err)
else:
for result in report.results:
print(result.message)
from linkml.validator import validate
instance ={'pizzas' :
[{"id": "1",
"title": "Margherita",
"description": "Classic pizza with tomato sauce and mozzarella cheese.",
"hasBase": ["ThinAndCrispyBase"],
"hasTopping": ["MozzarellaTopping", "SlicedTomatoTopping"],
"hasCountryOfOrigin": ["Italy"]}],
}
report = validate(instance, "pizza.yaml", "PizzaCollection")
if not report.results:
print('The instance is valid!')
else:
for result in report.results:
print(result.message)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment