Skip to content

Instantly share code, notes, and snippets.

@priyanshunayan
Created June 29, 2020 16:55
Show Gist options
  • Save priyanshunayan/3dd527d6e38f8ffc7c5d00c9baae137f to your computer and use it in GitHub Desktop.
Save priyanshunayan/3dd527d6e38f8ffc7c5d00c9baae137f to your computer and use it in GitHub Desktop.

GSOC-WEEK 4

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

  1. https://medium.com/@impns/community-bonding-google-summer-of-code-2020-hydra-ecosystem-e98984994299
  2. https://medium.com/@impns/gsoc-week-2-3e981e241616

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.

Implementations

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:

Add partial collection crawler by priyanshunayan · Pull Request #147 · HTTP-APIs/hydra-python-agent

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:

Templated IRI Support by priyanshunayan · Pull Request #146 · HTTP-APIs/hydra-python-agent

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:

Return Full Collection instead of just members by priyanshunayan · Pull Request #149 · HTTP-APIs/hydra-python-agent

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/

Improve UI by priyanshunayan · Pull Request #62 · HTTP-APIs/hydra-python-agent-gui

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 :

https://gist.github.com/6ac8308836d00ca3c860344cd3af7c91

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 ignored. But thanks to tests, they are now no longer there. I think I should write tests more often as they help you 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment