ramses-tech / ramses

RAML + Elasticsearch / Postgres / Mongodb / Your Data Store™ + Pyramid = RESTful API
http://ramses.tech
Apache License 2.0
303 stars 29 forks source link

Field [_version] is defined twice in [Item] #104

Closed timini closed 8 years ago

timini commented 8 years ago

Hi I was hoping to get ramses example up and running quickly; but had some problems following the how to. Help greatly appreciated.

   python --version
Python 3.5.1

(venv) #( 02/11/16@12:48am )( tim@Tims-MacBook-Pro-2 ):~/Workspace/projects/hansard/api/testapi@master✗✗✗
   pserve local.ini
2016-02-11 00:48:20,358 INFO  [nefertari_sqla.signals][MainThread] signals.setup_es_signals_for: setup_sqla_es_signals_for: <class 'nefertari_sqla.documents.ESBaseDocument'>
2016-02-11 00:48:20,363 INFO  [nefertari][MainThread] __init__.includeme: nefertari 0.6.1
2016-02-11 00:48:20,366 INFO  [nefertari.json_httpexceptions][MainThread] json_httpexceptions.includeme: Include json_httpexceptions
2016-02-11 00:48:20,367 INFO  [ramses][MainThread] __init__.includeme: Parsing RAML
2016-02-11 00:48:20,375 INFO  [ramses][MainThread] __init__.includeme: Starting models generation
2016-02-11 00:48:20,376 INFO  [ramses.generators][MainThread] generators.generate_models: Configuring model for route `items`
2016-02-11 00:48:20,380 INFO  [ramses.utils][MainThread] utils.resource_schema: Searching for model schema
2016-02-11 00:48:20,380 INFO  [ramses.models][MainThread] models.setup_data_model: Generating model class `Item`
2016-02-11 00:48:20,383 INFO  [nefertari_sqla.signals][MainThread] signals.setup_es_signals_for: setup_sqla_es_signals_for: <class 'ramses.models.Item'>
2016-02-11 00:48:20,387 INFO  [nefertari.elasticsearch][MainThread] elasticsearch.setup: Including Elasticsearch. {'enable_aggregations': 'false', 'chunk_size': 500, 'index_name': 'testapi', 'sniff': 'false', 'enable_polymorphic_query': 'false', 'index.disable': 'false', 'enable_refresh_query': 'false', 'hosts': 'localhost:9200'}
2016-02-11 00:48:20,387 INFO  [urllib3.connectionpool][MainThread] connectionpool._new_conn: Starting new HTTP connection (1): localhost
2016-02-11 00:48:20,393 WARNI [elasticsearch][MainThread] base.log_request_fail: HEAD /testapi [status:404 request:0.006s]
2016-02-11 00:48:20,393 ERROR [nefertari.elasticsearch][MainThread] elasticsearch.perform_request: 
2016-02-11 00:48:20,435 INFO  [elasticsearch][MainThread] base.log_request_success: PUT http://localhost:9200/testapi [status:200 request:0.041s]
2016-02-11 00:48:20,435 INFO  [ramses][MainThread] __init__.includeme: Starting server generation
2016-02-11 00:48:20,435 INFO  [ramses.generators][MainThread] generators.generate_server: Server generation started
2016-02-11 00:48:20,436 INFO  [ramses.generators][MainThread] generators.generate_resource: Configuring resource: `items`. Parent: `root`
2016-02-11 00:48:20,436 INFO  [ramses.generators][MainThread] generators.generate_resource: Generating ACL for `items`
2016-02-11 00:48:20,437 INFO  [ramses.generators][MainThread] generators.generate_resource: Generating view for `items`
2016-02-11 00:48:20,437 INFO  [ramses.generators][MainThread] generators.generate_resource: Creating new resource for `items`
2016-02-11 00:48:20,465 INFO  [ramses][MainThread] __init__.includeme: Running nefertari.engine.setup_database
2016-02-11 00:48:20,478 INFO  [nefertari_sqla][MainThread] __init__.setup_database: Database does not exist. Creating database at postgresql://localhost:5432/testapi
2016-02-11 00:48:20,852 INFO  [nefertari.elasticsearch][MainThread] elasticsearch.setup_mappings: Setting up ES mappings for all existing models
2016-02-11 00:48:20,858 WARNI [elasticsearch][MainThread] base.log_request_fail: PUT /testapi/_mapping/Item [status:400 request:0.006s]
2016-02-11 00:48:20,858 ERROR [nefertari.elasticsearch][MainThread] elasticsearch.perform_request: illegal_argument_exception
2016-02-11 00:48:20,861 ERROR [nefertari.json_httpexceptions][MainThread] json_httpexceptions.create_json_response: 400 BAD REQUEST: b'{"status_code": 400, "message": null, "title": "Bad Request", "explanation": "b\'illegal_argument_exception\'", "extra": {"data": "TransportError(400, \'illegal_argument_exception\', \'Field [_version] is defined twice in [Item]\')"}, "timestamp": "2016-02-11T00:48:20Z"}'
STACK BEGIN>>
  File "/Users/tim/Workspace/projects/hansard/api/venv/bin/pserve", line 11, in <module>
    sys.exit(main())
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 58, in main
    return command.run()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 328, in run
    global_conf=vars)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 363, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/testapi/testapi/__init__.py", line 6, in main
    config.include('ramses')
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 755, in include
    c(configurator)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/ramses/__init__.py", line 66, in includeme
    ES.setup_mappings()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 239, in setup_mappings
    es.put_mapping(body=model_cls.get_es_mapping())
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 255, in put_mapping
    **kwargs)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/client/indices.py", line 291, in put_mapping
    '_mapping', doc_type), params=params, body=body)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 60, in perform_request
    extra=dict(data=e))
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/json_httpexceptions.py", line 67, in exception_response
    return STATUS_MAP[status_code](**kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/json_httpexceptions.py", line 78, in __init__
    create_json_response(self, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/json_httpexceptions.py", line 58, in create_json_response
    msg += '\nSTACK BEGIN>>\n%s\nSTACK END<<' % add_stack()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/json_httpexceptions.py", line 26, in add_stack
    return ''.join(traceback.format_stack())

STACK END<<
Traceback (most recent call last):
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 49, in perform_request
    resp = super(ESHttpConnection, self).perform_request(*args, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/connection/http_urllib3.py", line 106, in perform_request
    self._raise_error(response.status, raw_data)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/connection/base.py", line 105, in _raise_error
    raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'illegal_argument_exception', 'Field [_version] is defined twice in [Item]')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 239, in setup_mappings
    es.put_mapping(body=model_cls.get_es_mapping())
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 255, in put_mapping
    **kwargs)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
    return func(*args, params=params, **kwargs)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/client/indices.py", line 291, in put_mapping
    '_mapping', doc_type), params=params, body=body)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/elasticsearch/transport.py", line 329, in perform_request
    status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 60, in perform_request
    extra=dict(data=e))
nefertari.json_httpexceptions.JHTTPBadRequest
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/tim/Workspace/projects/hansard/api/venv/bin/pserve", line 11, in <module>
    sys.exit(main())
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 58, in main
    return command.run()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 328, in run
    global_conf=vars)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/scripts/pserve.py", line 363, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/Users/tim/Workspace/projects/hansard/api/testapi/testapi/__init__.py", line 6, in main
    config.include('ramses')
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/pyramid/config/__init__.py", line 755, in include
    c(configurator)
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/ramses/__init__.py", line 66, in includeme
    ES.setup_mappings()
  File "/Users/tim/Workspace/projects/hansard/api/venv/lib/python3.5/site-packages/nefertari/elasticsearch.py", line 241, in setup_mappings
    raise Exception(ex.json['extra']['data'])
Exception: TransportError(400, 'illegal_argument_exception', 'Field [_version] is defined twice in [Item]')
postatum commented 8 years ago

Hi @timini. Are you using Elasticsearch 2.0.0+? If so downgrading to 1.7.5 should help. ES2 support for Ramses is not released yet.

timini commented 8 years ago

:+1:

thanks!

postatum commented 8 years ago

You're welcome, @timini :)