GSOC — WEEK 4

Priyanshu Nayan
3 min readJun 29, 2020

This is third blog of the series written during GSOC period. Link to first two:

It’s been four week into GSOC, and it has already been a fantastic ride. As expected, I got to learn a lot. Here’re some things that I was able to achieve in couple of weeks.

Implementation:

Partial Collection Crawler

When a collection has multiple members, in order to reduce response payload we divide the response in multiple pages. According to Hydra vocabulary, this divided response is known as Partial Collection. So, in the hydra-python-agent package, I was able to expose multiple interfaces such as crawling forward one at a time or going back once at a time. Also, in many cases, developers need to know other things the number of pages and sometimes they want to jump to last page or to a specific page. This crawler does it all. Checkout the PR:

IRI Template Expansion Strategy

Hydra Supports two types of representations, namely Basic and Explicit. Basic representation is similar to how we implement in web, form values, strings etc. Explicit Representation adds meaning to the params. It gives the ability to explicitly tag language of the string, or type of the data, of course by using JSON-LD. For more detailed information regarding these two, I suggest going through https://www.hydra-cg.com/spec/latest/core/#templated-links.

The agent now supports both representations. I also added tests to make sure everything works fine. Checkout the PR:

Minor Tweaks

Returning entire collection

Previously, only collection members were returned when invoked GET on collection endpoints. This was not obvious to most of the developers. I made it to return the whole collection in order to also get other useful information like pages, and templates. The related PR:

Pagination and templated links in GUI

To demonstrate the above works I added pagination and templated links to GUI. Now, the GUI supports pagination too. Also you can interact with the GUI here: http://34.67.128.133:3000/

Learnings

I got to learn a lot about URIs in general. I never expected there was this much to learn about URIs. The template format of URIs are :

expression = ‘{ [operator] variable-list }'

Also different operator characters like (‘+’, ‘?’, ‘&’, ‘.’ etc) have their own roles. For example:

? denotes beginning of query component and consisting of name=value pairs separated by “&”

And some operators like ‘=’ are reserved. If all these interest you should definitely checkout https://tools.ietf.org/html/rfc6570

And not to forget tests. I have always procrastinated over writing tests. But this time, I wrote to validate features, and guess what, there were indeed errors in front of me, left ignored. But thanks to tests, they are now no longer there. I think I should write tests more often as they help me figure out what are the bugs and, in the future too if unintentionally some method breaks down something, tests will be there to catch it.

This had been a really busy couple of weeks. Also, the evaluation is from tomorrow. Let’s hope for the best.

--

--