From e4e34d44e18fc5c5599c6236602454abf3cd09a6 Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Tue, 10 Jul 2018 16:51:01 +0530 Subject: [PATCH 1/2] update readme with remove hydra-py.py --- README.md | 132 +++++++++++++++++++++++++++++++++++++ README.rst | 188 ----------------------------------------------------- 2 files changed, 132 insertions(+), 188 deletions(-) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..b933aee --- /dev/null +++ b/README.md @@ -0,0 +1,132 @@ +# python-hydra-agent + +python-hydra-agent is a smart python hydra client which is working with [hydrus](https://github.com/HTTP-APIs/hydrus). + +It caches the server data from hydra server for fast data querying. + +It uses Redis to cache the data at the end of the client. + +So, Data load from the server and store in Redis memory as a graph using redisgraph. + +With the help of Redis, clients become faster and easier to query the data. + +## Installation + +**NOTE:** The client is using python3. + +To install the client, you have to run the following commands: + + python3 setup.py install + +or, + +To install only requirements: + + pip3 install -r requirements.txt + +For install Redis and start Redis server:: + + cd hydra_redis + ./redis_setup.sh + +## Quickstart + +### Demo + +To run the demo of python-hydra-agent, you have to follow the instructions: + +* Clone the repo: + + git clone https://github.com/HTTP-APIs/python-hydra-agent.git + +* Change directory and switch to the develop branch: + + cd python-hydra-agent + git checkout -b develop origin/develop + +* Now for install the requirements and setup the environment: + + you should follow the instruction of [installation](#installation). + +After setup environment and run the Redis server. You can query or run the client. + +* For run the client you should run querying_mechanism.py like: + + cd hydra_redis + python3 querying_mechanism.py + + + and provide a valid URL and then you can query in querying format. + + `>>>url` #here url should be valid link for testing you can use https://storage.googleapis.com/api3/api + `>>>help` # it will provide the querying format + +#### Code simplification + +To create graph in Redis memory use(hydra_graph.py) : +``` + import redis + from redisgraph import Graph, Node, Edge + redis_con = redis.Redis(host='localhost', port=6379) + self.redis_graph = Graph("apidoc", redis_con) +``` + +For querying, url should be provided first: + +``` + url = input("url>>>") + + return query(apidoc, url) # apidoc is vocab file provided by url. +``` + +Query input be like: + +``` + while True: + print("press exit to quit") + query = input(">>>") + if query == "exit": + break + elif query == "help": + help() # provide querying format + else: + print(facades.user_query(query))# query can be done with facades class +``` + +you can query in various querying formats: + +``` + print("for endpoint:- show endpoint") + print("for class_endpoint:- show classEndpoint") + print("for collection_endpoint:- show collectionEndpoint") + print("for members of collection_endpoint:-", + "show members") + print("for properties of any member:-", + "show object properties ") + print("for properties of objects:-show objects properties") + print("for collection properties:-", + "show properties") + print("for classes properties:- show class properties") + print("for compare properties:-show and/or ") +``` + +Query test can be done like this: + +``` + check_data = [['p.id', 'p.operations', 'p.properties', 'p.type'], + ['vocab:EntryPoint/Location', + "['POST'", "'PUT'", "'GET']", + "['Location']", 'Location']] + query = "show classEndpoints" + self.assertEqual(data,check_data) #data is data retrieve from the Redis. +``` + +For more detail take a look at [wiki file](https://github.com/HTTP-APIs/http-apis.github.io/blob/master/hydra-agent-redis-graph.md) + +References +---------- + +[Hydra-Enabled smart client](http://www.hydra-cg.com/) +[Hydra core vocabulary](http://www.hydra-cg.com/spec/latest/core/) + + diff --git a/README.rst b/README.rst deleted file mode 100644 index 07edb7c..0000000 --- a/README.rst +++ /dev/null @@ -1,188 +0,0 @@ -python-hydra-agent -================== - -A fork of hydra-py [4]_. The license of the original fork is LGPLv3. - - -The primary goal is to provide a lib for easily writing Hydra-enabled clients [1]_. - -A secondary goal is to provide a client for Triple Patterns Fragments [2]_, -and an RDFlib [3]_ Store backed on any TPF service. - -Using Redis to cache the data at the end of client. - -So, Data load from the server and store in Redis memory as a graph. - -With the help of Redis, clients becomes faster and easier to query the data. - -Installation -++++++++++++ - -To install this library, from the projet directory, type:: - - pip install . - -or - - python3 setup.py install - -NB: developers might want to add the ``-e`` option to the command line above, -so that modifications to the source are automatically taken into account. - -For install redis and start redis-server:: - - cd hydra_redis - ./redis_setup.sh - -Quick start -+++++++++++ - -For hydra.__init__.py ---------------------- - -To create a Hydra-enabled resource, use: - -.. code:: python - - from hydra import Resource, SCHEMA - res = Resource.from_iri(the_iri_of_the_resource) - -If the resource has an API documentation associated with it, -it will be available as an attribute. -The API documentation provides access to the supported class, -their supported properties and operations. - -.. code:: python - - print("Api documentation:") - for supcls in res.api_documentation.supported_classes: - print(" %s" % supcls.identifier) - for supop in supcls.supported_operations: - print(" %s" % supop.identifier) - -Alternatively, -you can query the resource directly for available operations. -For example, the following searches for a suitable operation for creating a new event, -and performs it. - -.. code:: python - - create_event = res.find_suitable_operation(SCHEMA.AddAction, SCHEMA.Event) - resp, body = create_event({ - "@context": "http://schema.org/", - "@type": "http://schema.org/Event", - "name": "Halloween", - "description": "This is halloween, this is halloween", - "startDate": "2015-10-31T00:00:00Z", - "endDate": "2015-10-31T23:59:59Z", - }) - assert resp.status == 201, "%s %s" % (resp.status, resp.reason) - new_event = Resource.from_iri(resp['location']) - -And you can go on with the new event you just created... - -Triple Pattern Fragments -++++++++++++++++++++++++ - -The ``hydra.tpf`` module implements of Triple Pattern Fragments specification [2]_. -In particular, it provides an implementation of Store, -so that TPF services can be used transparently: - -.. code:: python - - import hydra.tpf # ensures that the TPFStore plugin is registered - from rdflib import Graph - - g = Graph('TPFStore') - g.open('http://data.linkeddatafragments.org/dbpedia2014') - - results = g.query("SELECT DISTINCT ?cls { [ a ?cls ] } LIMIT 10") - -Note however that this is experimental at the moment... - - -For hydra_redis ---------------- - -For running the client you should run querying_mechanism - - cd hydra_redis - - python3 querying_mechanism.py - -and provide a valid url and then you can query in querying format. - - >>>help # it will provide the querying format - -Code simplification -^^^^^^^^^^^^^^^^^^^ -To create graph in Redis memory use: - -.. code:: python - - import redis - from redisgraph import Graph, Node, Edge - redis_con = redis.Redis(host='localhost', port=6379) - self.redis_graph = Graph("apidoc", redis_con) - - -For querying, url should be provided first: - -.. code:: python - - url = input("url>>>") - - return query(apidoc, url) # apidoc is vocab file provided by url. - -.. code:: python - - while True: - print("press exit to quit") - query = input(">>>") - if query == "exit": - break - elif query == "help": - help() # provide querying format - else: - print(facades.user_query(query))# query can be done with facades class - - -you can query in various formats: - -.. code:: python - - print("for endpoint:- show endpoint") - print("for class_endpoint:- show classEndpoint") - print("for collection_endpoint:- show collectionEndpoint") - print("for members of collection_endpoint:-", - "show members") - print("for properties of any member:-", - "show object properties ") - print("for properties of objects:-show objects properties") - print("for collection properties:-", - "show properties") - print("for classes properties:- show class properties") - print("for compare properties:-show and/or ") - - -Query can be done like this: - -.. code:: python - - check_data = [['p.id', 'p.operations', 'p.properties', 'p.type'], - ['vocab:EntryPoint/Location', - "['POST'", "'PUT'", "'GET']", - "['Location']", 'Location']] - query = "show classEndpoints" - self.assertEqual(data,check_data) #data is data retrieve from the Redis. - -For more detail take a look at [wiki file](https://github.com/HTTP-APIs/http-apis.github.io/blob/master/hydra-agent-redis-graph.md) - -References -++++++++++ - -.. [1] http://www.hydra-cg.com/ -.. [2] http://www.hydra-cg.com/spec/latest/triple-pattern-fragments/ -.. [3] https://rdflib.readthedocs.org/ -.. [4] https://github.com/pchampin/hydra-py - From 3ce8dbd13705fa4c956855e9708fd79d430a96ce Mon Sep 17 00:00:00 2001 From: sandeepsajan0 Date: Wed, 11 Jul 2018 11:54:24 +0530 Subject: [PATCH 2/2] update grammatical mistakes --- README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b933aee..c6ceca8 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ # python-hydra-agent -python-hydra-agent is a smart python hydra client which is working with [hydrus](https://github.com/HTTP-APIs/hydrus). +The python-hydra-agent is a smart python hydra client which is working with [hydrus](https://github.com/HTTP-APIs/hydrus). It caches the server data from hydra server for fast data querying. It uses Redis to cache the data at the end of the client. -So, Data load from the server and store in Redis memory as a graph using redisgraph. +So, Data is loaded from the server and store in Redis memory as a graph using redisgraph. With the help of Redis, clients become faster and easier to query the data. ## Installation -**NOTE:** The client is using python3. +**NOTE:** You'll need to use python3. -To install the client, you have to run the following commands: +To install or setup the client environment, you have to run: python3 setup.py install @@ -24,7 +24,7 @@ To install only requirements: pip3 install -r requirements.txt -For install Redis and start Redis server:: +To install Redis and start Redis server: cd hydra_redis ./redis_setup.sh @@ -33,7 +33,7 @@ For install Redis and start Redis server:: ### Demo -To run the demo of python-hydra-agent, you have to follow the instructions: +To run the demo for python-hydra-agent, you have to follow the instructions: * Clone the repo: @@ -44,13 +44,13 @@ To run the demo of python-hydra-agent, you have to follow the instructions: cd python-hydra-agent git checkout -b develop origin/develop -* Now for install the requirements and setup the environment: +* Now to install the requirements or setup the environment: - you should follow the instruction of [installation](#installation). + you should follow the instructions of [installation](#installation). -After setup environment and run the Redis server. You can query or run the client. +After setup the environment and run the Redis server. You can query or run the client. -* For run the client you should run querying_mechanism.py like: +* To run the client you should run querying_mechanism.py like: cd hydra_redis python3 querying_mechanism.py @@ -58,12 +58,12 @@ After setup environment and run the Redis server. You can query or run the clien and provide a valid URL and then you can query in querying format. - `>>>url` #here url should be valid link for testing you can use https://storage.googleapis.com/api3/api + `>>>url` #here url should be a valid link, for testing you can use https://storage.googleapis.com/api3/api `>>>help` # it will provide the querying format #### Code simplification -To create graph in Redis memory use(hydra_graph.py) : +To create the graph in Redis memory, use(hydra_graph.py) : ``` import redis from redisgraph import Graph, Node, Edge @@ -71,7 +71,7 @@ To create graph in Redis memory use(hydra_graph.py) : self.redis_graph = Graph("apidoc", redis_con) ``` -For querying, url should be provided first: +For querying, URL should be provided first: ``` url = input("url>>>") @@ -79,7 +79,7 @@ For querying, url should be provided first: return query(apidoc, url) # apidoc is vocab file provided by url. ``` -Query input be like: +The client takes the query as input, like: ``` while True: @@ -93,7 +93,7 @@ Query input be like: print(facades.user_query(query))# query can be done with facades class ``` -you can query in various querying formats: +you can query as following querying formats: ``` print("for endpoint:- show endpoint") @@ -127,6 +127,6 @@ References ---------- [Hydra-Enabled smart client](http://www.hydra-cg.com/) -[Hydra core vocabulary](http://www.hydra-cg.com/spec/latest/core/) +[Hydra core vocabulary](http://www.hydra-cg.com/spec/latest/core/)