Google Summer of Code 2021 | End of Phase-1 | Hydra Ecosystem

Hasan Faraz Khan
4 min readJul 10, 2021

Phase one of GSoC’ 21 is finally coming to an end. It’s time to wrap-up things for phase-1 and also first evaluation window will open from July 12. In this blog, I’ll be writing about tasks that were completed in Week 3–4 and new changes that we have made in hydrus ( flagship server ) and hydra-python-core library.

Issues that I worked on in Week 3–4 developed my interest and made me appreciate Linked Data and RDF even more. I got a chance to get a better insight into Hydra specifications while working on these issues. I also spent some time on JSON-ld playground.

The first issue I tackled in Week-3 was about creating a foreign-key relationship between a hydra:Class and hydra:Collection. The reason behind this was a bug. Previously, if an object was being deleted from a Class it would still be there in the collection table in database( if it was previously inserted in a Collection that directly manages that Class). In such a case, a GET response from Collection endpoint will show the member available in the database but will throw an InstanceNotFound error when a GET request will be made to view details of the object because it has already been deleted from the Class.

To fix this, I usedmanages keyword to check if a hydra:Collection actually manages that Class.

In this example, DroneCollection manages the Drone Class. Now hydrus will also check if that object is also present in the database table of a Collection that directly manages the class and then delete the object from both concurrently.

Here’s the issue and PR for the same :

Another important change that we wanted in hydrus was about creating Columns with multiple data types in database table. Previously, all database columns were set to String as there was no way of specifying the type of variable for a hydra:supportedProperty. I discussed the implementation in a weekly meeting with mentors and came up with the final approach which was using range keyword to specify the type of a supported property.

range keyword can be used to specify the datatype of a property according to Hydra specifications. I first decided to use rdfs:range but after a suggestion from Chris Andrew, I realised that we already have hydra:range (which is also inherited from rdfs:range) in our API documentation’s context. This is basically a concept of JSON-ld — If we have defined rdfs in our API_DOC’s context then it’ll be interpreted as http://w3.org/2000/01/rdf-schema#range when we’ll expand the doc.

"range": {
"@id": "rdfs:range",
"@type": "@id"
}

To understand the concept behind RDF ( Resource Descriptive Framework) and JSON-ld, I tried playing with docs on JSON-ld Playground. Finally I made the changes in hydra-python-core library. The next step was to make required changes in hydrus. The idea was that a user can add range as an keyword argument in HydraClassProp while creating an apidoc like range="xsd:float" which will be expanded by doc_maker and then interpreted as https://www.w3.org/TR/xmlschema-2/#float. Now, hydrus will look into apidoc and then create attributes in database table according to their respective column types.

Related Issues and Pull Requests:

I also made changes necessary changes in test cases and other functions in test module. This feature was important for this year’s credit-risk project as we’ll be using OWL ontology to generate JSON-LD vocabulary and then use it to generate API docs using python scripts. Purvanshsingh will be taking care of that part.

Also, I made a final release of hydrus==0.4.4 and hydra-python-core library. My mentor Lorenzo M. guided me throughout the process and even helped me to make my first release on PyPi. I read some blogs on continuous deployment and package publishing using Github Actions. I also setup a workflow to make release on PyPi through Github.

Phase-1 for GSoC’ 21 is finally completed and the next step is to wrap up everything and prepare for first evaluation. The first evaluation window will open on July 12th and after that I’ll prepare a schedule for Phase-2. This was an exciting journey so far and all the mentors were really helpful. I am planning to contribute even more to open-source after my GSoC project ends and also to expand my stack as I dive deeper into JavaScript based frameworks and DevOps. Let’s see how it goes :-)

--

--