Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New implementation of parser WIP #199

Merged
merged 26 commits into from
Jun 10, 2018

Conversation

vaibhavchellani
Copy link
Contributor

@vaibhavchellani vaibhavchellani commented Jun 4, 2018

Fixes #193

Checklist

  • My branch is up-to-date with upstream/develop branch.
  • Everything works and tested for Python 3.5.2 and above.

Description

We are now able to parse the objects defined at variable locations , able to identify collections and present a more accurate conversion of open api spec to hydra spec

Test Logs

@xadahiya @Shekharrajak @kkoci @pcalcina @chrizandr

@vaibhavchellani
Copy link
Contributor Author

there is excessive logging in this presently for debugging purposes , will remove once approved .

@vaibhavchellani
Copy link
Contributor Author

@xadahiya @chrizandr i am stuck with test_app.py on this , unable to get through that ,please review and let me know if you found any solution or recommend changes

@xadahiya
Copy link
Member

xadahiya commented Jun 6, 2018

@vaibhavchellani Tests are working for me(test_app, test_auth) only one test if failing. See this
selection_035
selection_036

@vaibhavchellani
Copy link
Contributor Author

you tried with the doc that was created by the parser ? @xadahiya

@xadahiya
Copy link
Member

xadahiya commented Jun 6, 2018

Yeah, I'm using hydrus.samples.hydra_doc_sample. Only CRUD tests are failing. Rest everything works fine.
selection_038
selection_039
selection_040

@vaibhavchellani
Copy link
Contributor Author

hey @xadahiya thanks , however these are my test results , and i am unable to debug these .
screen shot 2018-06-07 at 10 57 50 am
screen shot 2018-06-07 at 10 58 03 am
screen shot 2018-06-07 at 10 58 16 am

@xadahiya
Copy link
Member

xadahiya commented Jun 7, 2018

Show me your test_app file

@vaibhavchellani
Copy link
Contributor Author

@xadahiya
Copy link
Member

xadahiya commented Jun 7, 2018

I'm doing the exact same thing see https://www.diffchecker.com/yvyAJW9p . Probably your hydrus installation is outdated. Do one thing cd to main hydrus directory and run pip install -e .. This should fix the problem.

@vaibhavchellani
Copy link
Contributor Author

okay yes , that did it , now ill try to debug and will let you know

@xadahiya
Copy link
Member

xadahiya commented Jun 7, 2018

See test_crud you'll probably get errors in that. Also, please try to finish this in a day. I'll review your code then. Good luck :)

@vaibhavchellani
Copy link
Contributor Author

screen shot 2018-06-09 at 12 56 14 pm

@xadahiya
Copy link
Member

xadahiya commented Jun 9, 2018

@vaibhavchellani Can you update the code to follow mypy format like the rest of Hydrus code.
https://mypy.readthedocs.io/en/latest/

@xadahiya
Copy link
Member

xadahiya commented Jun 9, 2018

Add pyyaml to requirements.txt

@xadahiya
Copy link
Member

xadahiya commented Jun 9, 2018

Also, remove redundant print statements rest everything looks fine for now.

@xadahiya
Copy link
Member

@vaibhavchellani You haven't added any documentation to the wiki yet like we discussed in the call. Add a page expaining the parser structure to https://github.com/HTTP-APIs/hydra-ecosystem-wiki/.

Also, finish the things I've mentioned above as soon as you can. We need to merge soon!

@xadahiya
Copy link
Member

@vaibhavchellani How are you tests passing? Mine are still failing.
These are the files I'm using https://gist.github.com/xadahiya/fad7037ca85975c85a23b2431d911024
Logs from test_app.py

(hydra) xadahiya@xa-Inspiron-7560:~/hydra/hydrus/hydrus/tests$ python -m unittest -v test_app
Creating a temporary database...
going for create doc
Classes and properties added successfully.
Setting up Hydrus utilities... 
Creating utilities context... 
Setup done, running tests...
test_Collections_GET (test_app.ViewsTestCase)
Test GET on collection endpoints. ... ok
test_Collections_PUT (test_app.ViewsTestCase)
Test insert data to the collection. ... ok
test_Endpoints_Contexts (test_app.ViewsTestCase)
Test all endpoints contexts are generated properly. ... ok
test_EntryPoint_context (test_app.ViewsTestCase)
Test for the EntryPoint context. ... ok
test_Index (test_app.ViewsTestCase)
Test for the index. ... ok
test_Vocab (test_app.ViewsTestCase)
Test the vocab. ... ok
test_bad_objects (test_app.ViewsTestCase)
Checks if bad objects are added or not. ... ok
test_bad_requests (test_app.ViewsTestCase)
Checks if bad requests are handled or not. ... ok
test_endpointClass_DELETE (test_app.ViewsTestCase)
Check non collection Class DELETE. ... ok
test_endpointClass_GET (test_app.ViewsTestCase)
Check non collection Class GET. ... [2018-06-10 12:29:12,875] ERROR in app: Exception on /demoapi/Pet [GET]
Traceback (most recent call last):
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 480, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 595, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/xadahiya/hydra/hydrus/hydrus/app.py", line 353, in get
    abort(endpoint_['status'])
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 707, in abort
    return _aborter(status, *args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 686, in __call__
    raise LookupError('no exception for %r' % code)
LookupError: no exception for 200
FAIL
test_endpointClass_POST (test_app.ViewsTestCase)
Check non collection Class POST. ... [2018-06-10 12:29:12,881] ERROR in app: Exception on /demoapi/Pet [POST]
Traceback (most recent call last):
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 480, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 595, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/xadahiya/hydra/hydrus/hydrus/app.py", line 449, in post
    abort(endpoint_['status'])
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 707, in abort
    return _aborter(status, *args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 686, in __call__
    raise LookupError('no exception for %r' % code)
LookupError: no exception for 200
FAIL
test_endpointClass_PUT (test_app.ViewsTestCase)
Check non collection Class PUT. ... [2018-06-10 12:29:12,887] ERROR in app: Exception on /demoapi/Pet [PUT]
Traceback (most recent call last):
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 480, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/flask_restful/__init__.py", line 595, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/xadahiya/hydra/hydrus/hydrus/app.py", line 416, in put
    abort(endpoint_['status'])
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 707, in abort
    return _aborter(status, *args, **kwargs)
  File "/home/xadahiya/miniconda3/envs/hydra/lib/python3.6/site-packages/werkzeug/exceptions.py", line 686, in __call__
    raise LookupError('no exception for %r' % code)
LookupError: no exception for 200
FAIL
test_object_DELETE (test_app.ViewsTestCase)
Test DELETE of a given object using ID. ... ok
test_object_POST (test_app.ViewsTestCase)
Test replace of a given object using ID. ... ok
test_object_PUT_at_id (test_app.ViewsTestCase)
Create object in collection using PUT at specific ID. ... ok

======================================================================
FAIL: test_endpointClass_GET (test_app.ViewsTestCase)
Check non collection Class GET.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_app.py", line 271, in test_endpointClass_GET
    assert response_get.status_code in [200, 404]
AssertionError

======================================================================
FAIL: test_endpointClass_POST (test_app.ViewsTestCase)
Check non collection Class POST.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_app.py", line 245, in test_endpointClass_POST
    assert put_response.status_code == 201
AssertionError

======================================================================
FAIL: test_endpointClass_PUT (test_app.ViewsTestCase)
Check non collection Class PUT.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_app.py", line 231, in test_endpointClass_PUT
    assert put_response.status_code == 201
AssertionError

----------------------------------------------------------------------
Ran 15 tests in 0.463s

FAILED (failures=3)

Logs from test_crud.py

(hydra) xadahiya@xa-Inspiron-7560:~/hydra/hydrus/hydrus/tests$ python -m unittest -v test_crud
Creating a temporary datatbsse...
Classes and properties added successfully.
Setup done, running tests...
test_delete (test_crud.TestCRUD)
Test CRUD delete. ... ERROR
test_delete_id (test_crud.TestCRUD)
Test CRUD delete when wrong/undefined ID is given. ... ERROR
test_delete_type (test_crud.TestCRUD)
Test CRUD delete when wrong/undefined class is given. ... ERROR
test_get (test_crud.TestCRUD)
Test CRUD get. ... ERROR
test_get_id (test_crud.TestCRUD)
Test CRUD get when wrong/undefined ID is given. ... FAIL
test_get_type (test_crud.TestCRUD)
Test CRUD get when wrong/undefined class is given. ... ok
test_insert (test_crud.TestCRUD)
Test CRUD insert. ... ERROR
test_insert_id (test_crud.TestCRUD)
Test CRUD insert when used ID is given. ... ERROR
test_insert_type (test_crud.TestCRUD)
Test CRUD insert when wrong/undefined class is given. ... ERROR
test_update (test_crud.TestCRUD)
Test CRUD update. ... ERROR

======================================================================
ERROR: test_delete (test_crud.TestCRUD)
Test CRUD delete.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 86, in test_delete
    insert_response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_delete_id (test_crud.TestCRUD)
Test CRUD delete when wrong/undefined ID is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 136, in test_delete_id
    insert_response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_delete_type (test_crud.TestCRUD)
Test CRUD delete when wrong/undefined class is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 122, in test_delete_type
    insert_response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_get (test_crud.TestCRUD)
Test CRUD get.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 64, in test_get
    response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_insert (test_crud.TestCRUD)
Test CRUD insert.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 57, in test_insert
    response = crud.insert(object_=object_, id_=1, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
ERROR: test_insert_id (test_crud.TestCRUD)
Test CRUD insert when used ID is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 164, in test_insert_id
    insert_response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 166, in test_insert_id
    response_code, message = e.get_HTTP()
AttributeError: 'TypeError' object has no attribute 'get_HTTP'

======================================================================
ERROR: test_insert_type (test_crud.TestCRUD)
Test CRUD insert when wrong/undefined class is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 150, in test_insert_type
    object_["@type"] = "otherClass"
TypeError: 'NoneType' object does not support item assignment

======================================================================
ERROR: test_update (test_crud.TestCRUD)
Test CRUD update.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 74, in test_update
    insert_response = crud.insert(object_=object_, id_=id_, session=self.session)
  File "/home/xadahiya/hydra/hydrus/hydrus/data/crud.py", line 111, in insert
    RDFClass.name == object_["@type"]).one()
TypeError: 'NoneType' object is not subscriptable

======================================================================
FAIL: test_get_id (test_crud.TestCRUD)
Test CRUD get when wrong/undefined ID is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/xadahiya/hydra/hydrus/hydrus/tests/test_crud.py", line 105, in test_get_id
    assert 404 == response_code
AssertionError

----------------------------------------------------------------------
Ran 10 tests in 0.059s

FAILED (failures=1, errors=8)

@vaibhavchellani
Copy link
Contributor Author

hey @xadahiya , yes i was unable to resolve this , i was able to take it to the one failure , the flock doc also had the same failure so i left it at that point as you suggested .

@xadahiya
Copy link
Member

That's fine. Please finish the rest

@vaibhavchellani
Copy link
Contributor Author

@xadahiya done ! let me know if any more changes are to be made .

@xadahiya
Copy link
Member

@vaibhavchellani You need to add anything before merging?

@vaibhavchellani
Copy link
Contributor Author

I dont think so @xadahiya

@xadahiya xadahiya merged commit 9d1bef6 into HTTP-APIs:develop Jun 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants