HTTP-APIs / hydrus

REST server - Flask Hydra-powered for Semantic Web
https://pypi.org/project/hydrus/
MIT License
195 stars 130 forks source link

Issue with retrieving nested objects #374

Closed xadahiya closed 5 years ago

xadahiya commented 5 years ago

I'm submitting a

Current Behaviour:

Retrieving nested objects like

{"@type": "Command", "DroneID": "1223", 
"State": {"@type": "State", "DroneID": "-1000", "Battery": "50", 
"Direction": "North", "Position": "1,1", "Status": "Active", "Speed": "100"}
} 

causes the server to crash. I guess this happened after the internal mechanism change that was done (Seggrigating nested objects at a different url location). When trying to retrieve any nested object, the server throws this error [2019-03-24 21:33:05,891] ERROR in app: Exception on /api/CommandCollection/ba49e203-7d00-42d5-92dd-c630873559d0 [GET] Traceback (most recent call last): File "/home/xadahiya/miniconda3/lib/python3.7/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/home/xadahiya/miniconda3/lib/python3.7/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/home/xadahiya/miniconda3/lib/python3.7/site-packages/flask_restful/__init__.py", line 480, in wrapper resp = resource(*args, **kwargs) File "/home/xadahiya/miniconda3/lib/python3.7/site-packages/flask/views.py", line 88, in view return self.dispatch_request(*args, **kwargs) File "/home/xadahiya/miniconda3/lib/python3.7/site-packages/flask_restful/__init__.py", line 595, in dispatch_request resp = meth(*args, **kwargs) File "/mnt/d/workspace/hydra/hydra-flock-demo/src/hydrus/hydrus/resources.py", line 106, in get session=get_session()) File "/mnt/d/workspace/hydra/hydra-flock-demo/src/hydrus/hydrus/data/crud.py", line 114, in get for collection in doc.collections: AttributeError: 'str' object has no attribute 'collections'

Expected Behaviour:

Nested objects should be returned properly.

Steps to reproduce:

Mec-iS commented 5 years ago

@xadahiya please provide a proper link to the changes you are talking about

I suppose you are talking about #295 by @vddesai1871

In place of the State object there should be an hypermedia link.

xadahiya commented 5 years ago

Yes, but that is when we retrieve the object. This is the object I used to store the object in CommandCollection. The server crashes when trying to retrieve this item.

vddesai1871 commented 5 years ago

hydrus is working fine, I can not reproduce that same error in this repo. This issue should be migrated to flock-controller repo. I have tried running the controller by following instructions provided there. But I am getting an installation error, I will further investigate it tommorow, meanwhile looking at that repository, it has api_docs directory and it has an old doc_gen script which defines State as not-collection class, changing collection=True for State in line 230 of doc_gen.py might help.

in hydrus

Retrieving command object. (you can see link to the nested state object)

command

Now retrieving the state object by dereferencing the link

cm_state

xadahiya commented 5 years ago

I tried that but it didn't work. Could you please try to find out what's wrong with the demo?

Mec-iS commented 5 years ago

@xadahiya

it has api_docs directory and it has an old doc_gen script which defines State as not-collection class, changing collection=True for State in line 230 of doc_gen.py might help.

chrizandr commented 5 years ago

To add to this, we might have to make tests for nested objects. We don't have any right now, that is why it was missed out before merging.

vddesai1871 commented 5 years ago

To add to this, we might have to make tests for nested objects. We don't have any right now, that is why it was missed out before merging.

There isn't any bug related to nested objects in hydrus. I added tests related to this (in test_app.py) when I added these changes. And I have tested it manually before and now, and it is working fine. You can see the screenshots I posted above or try reproducing that bug in this repo by adding an item to command collection and retrieve it. If we are clear on this then we can migrate this issue to flock-demo repository and investigate it there.

xadahiya commented 5 years ago

Cool! @vddesai1871 please create an issue in the flock-demo repo