From 459cfc2310db7c427bcb86871db167a1fb4ea17a Mon Sep 17 00:00:00 2001 From: Samesh Lakhotia Date: Sun, 9 Feb 2020 16:21:13 +0530 Subject: [PATCH 1/2] FIX: Automate the process of discovering the apiDocumentation Made the agent use the `vocab` in the context of the apiDoc instead of just appending `vocab` at the end of the api url. fixes https://github.com/HTTP-APIs/hydra-python-agent/issues/102 fixes https://github.com/HTTP-APIs/hydrus/issues/428 --- hydra_agent/redis_core/graphutils_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hydra_agent/redis_core/graphutils_operations.py b/hydra_agent/redis_core/graphutils_operations.py index 1782fe1..1a99787 100644 --- a/hydra_agent/redis_core/graphutils_operations.py +++ b/hydra_agent/redis_core/graphutils_operations.py @@ -26,7 +26,7 @@ def __init__(self, entrypoint_url: str, api_doc: dict, self.api_doc = api_doc self.redis_proxy = redis_proxy self.redis_connection = redis_proxy.get_connection() - self.vocabulary = 'vocab' + self.vocabulary = self.api_doc['context']['context']['vocab'] self.graph_utils = GraphUtils(redis_proxy) self.redis_graph = Graph("apigraph", self.redis_connection) self.session = Session() From 29d07a41524f9f88201ccad366eee8c197c7e360 Mon Sep 17 00:00:00 2001 From: Samesh Lakhotia Date: Sun, 9 Feb 2020 18:05:36 +0530 Subject: [PATCH 2/2] correctly get `vocab` from `api_doc` --- hydra_agent/redis_core/graphutils_operations.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hydra_agent/redis_core/graphutils_operations.py b/hydra_agent/redis_core/graphutils_operations.py index 1a99787..8b3eaed 100644 --- a/hydra_agent/redis_core/graphutils_operations.py +++ b/hydra_agent/redis_core/graphutils_operations.py @@ -26,7 +26,9 @@ def __init__(self, entrypoint_url: str, api_doc: dict, self.api_doc = api_doc self.redis_proxy = redis_proxy self.redis_connection = redis_proxy.get_connection() - self.vocabulary = self.api_doc['context']['context']['vocab'] + self.complete_vocabulary_url = self.api_doc.generate()['@context']['vocab'] + # extract 'vocab' from 'localhost/api/vocab#' + self.vocabulary = self.complete_vocabulary_url.split('/')[-1].split('#')[0] self.graph_utils = GraphUtils(redis_proxy) self.redis_graph = Graph("apigraph", self.redis_connection) self.session = Session()