Obtaining Existing Reference Nodes #390
Replies: 5 comments 3 replies
-
Hi @c-heat16, there are a few questions here, let me see if I can unpack it and address them. If I miss anything please feel free to let me know.
import jsonschema
import requests
def get_db_schema():
json_schema = requests.get(
url="https://lb-stage.mycriptapp.org/api/v1/schema/"
).json()["data"]
return json_schema
def validate_giant_json():
db_schema = get_db_schema()
# this field needs to be overwritten with whatever is needed
node_type: str = "citation"
http_method: str = "Post"
db_schema["$ref"] = f"#/$defs/{node_type.title()}{http_method.title()}"
node = {
"node": [
"Citation"
],
"uid": "_:33d273ac-f63f-4d07-a77d-8ba17e2e3c01",
"uuid": "33d273ac-f63f-4d07-a77d-8ba17e2e3c01",
"type": "extracted_by_human",
"reference": {
"uid": "_:bd4da2ca-f9d5-493c-9f29-7e194ce88698",
"uuid": "uuid()",
"model_version": "1.0.0",
"updated_at": "now()",
"created_at": "now()",
"public": True
},
"model_version": "1.0.0",
"updated_at": "now()",
"created_at": "now()"
}
jsonschema.validate(instance=node, schema=db_schema)
if __name__ == "__main__":
validate_giant_json() I got Failed validating 'anyOf' in schema['properties']['reference']:
{'anyOf': [{'$ref': 'EdgeUUID'},
{'$ref': 'ReferencePost'},
{'$ref': 'Edge'}]}
On instance['reference']:
{'created_at': 'now()',
'model_version': '1.0.0',
'public': True,
'uid': '_:bd4da2ca-f9d5-493c-9f29-7e194ce88698',
'updated_at': 'now()',
'uuid': 'uuid()'} I think the issue is that the reference node is coming out incorrectly in JSON format. The reference node is supposed to look like the JSON given in the documentation. How are you creating the reference node? Is it being created incorrectly after being made in Python or are you getting the reference node from the API and it is being deserialized into a node incorrectly? |
Beta Was this translation helpful? Give feedback.
-
@c-heat16 yeah that makes sense. I reported that issue to the API and asked if we can have an endpoint to grab reference nodes by DOI. |
Beta Was this translation helpful? Give feedback.
-
@c-heat16, regarding the ISSN conditionality, I believe it might depend on the reference type. However, with the recent updates to the vocabulary, I'm not seeing that specification clearly mentioned. I also checked the DB schema and it appears to treat ISSN more as an optional attribute rather than conditional. I've noted this and will work on converting all |
Beta Was this translation helpful? Give feedback.
-
@c-heat16, I've looked into the issue you've described where the API returns an error when two experiments use the same reference node. If only one experiment uses the reference, there's no error. I suspect this might be an API-related issue. I've reported this to the API team and am awaiting their feedback. If they confirm there's no error on their end, I'll further investigate by examining the JSON requests and responses through tools like postman to get a deeper understanding and pinpoint the root cause. Regarding using same process names in different experiments, this is a known issue from the API that if the user inputs the same process name into 2 different experiments the API gives an error, I have already reported this in the past and am waiting for it to be fixed. However, CRIPT does want scientists to use different descriptive names for their nodes that helps readers easily understand each step, so for that reason CRIPT tries to stop users from entering the same name for the same node within another node, for example CRIPT does not want users to input the same process name for many processes within an experiment. I hope that makes sense, let me know if you have any questions. |
Beta Was this translation helpful? Give feedback.
-
Thank you for providing you script in each issue, that makes it very transparent and easier to track down issues |
Beta Was this translation helpful? Give feedback.
-
Is there a correct way to fetch existing reference nodes? I've looked around but don't see any examples, and trying to fetch a reference as if it were a material is unsuccessful. For example, there is a reference I previously created with the title 'Mechanistic Modeling of Polymer Pyrolysis: Polypropylene'
Trying to retrieve the existing reference as described below, either by name or DOI, yields errors.
Complete CLI output:
We are constructing a repository of previously published results, so having references to the original source is imperative. Creating new reference nodes with the same attributes as existing reference nodes yields a very long, nondescript error message (below). If no references are added to the project being saved, the error goes away.
Beta Was this translation helpful? Give feedback.
All reactions