Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Goblin constructs property keys with hypercorrective zeal #31

Open
leifurhauks opened this issue Jun 21, 2016 · 2 comments
Open

Goblin constructs property keys with hypercorrective zeal #31

leifurhauks opened this issue Jun 21, 2016 · 2 comments

Comments

@leifurhauks
Copy link
Contributor

Using the following model definition:

class Foo(models.Vertex):
    foo = properties.String(db_field='bar')

I have a 'foo' vertex in the database already with 'bar' = 'testing123'.

The following retrieves it and correctly prints 'testing123':

async def foo_property():
    foo = await Foo.get('4312')
    print(foo.bar)

If I now change foo.bar and save it:

async def set_foo_property(new_value):
    foo = await Foo.get('4312')
    foo.bar = new_value
    await foo.save()

The foo_property coroutine now prints 'different value' as expected. But now the 'bar' property appears to be mapped to a new property, 'foo_bar' in titan:

gremlin> g.V(4312).properties()
==>vp[bar->testing123]
==>vp[foo_bar->different value]
gremlin> 
@leifurhauks
Copy link
Contributor Author

I think the following is related:

import asyncio

from goblin import connection
from gremlinclient import aiohttp_client

from graph_service.models import fiber


@asyncio.coroutine
def main_coro():
    structure = yield from fiber.Structure.get('8036408')
    print(structure)
    structure.hatch_height += 1
    resp = yield from structure.save()
    print(resp)


def main():
    loop = asyncio.get_event_loop()
    connection.setup("ws://localhost:8182", pool_class=aiohttp_client.Pool, future_class=asyncio.Future)
    loop.run_until_complete(main_coro())


if __name__ == "__main__":
    main()

This results in:

Structure(label=structure, id=8036408, values={'length': 1.83, 'hatch_height': 0.9, 'identifier': 'CSEM-structure-16315', 'borough': 'Sud-Ouest', 'raw_data': '{"ASSET_ID":161150,"Type":"PA","No mod\\u00e8le":null,"No correspondance":null,"Statut":"ACT","No de poteau":null,"No \\u00e9tude":0,"X":299563.259,"Y":5037571.011,"Longueur":3.35,"Largeur":1.83,"Hauteur Libre":2.29,"Hauteur Chemin\\u00e9e 1":0.9,"Distance CC Nord":0.92,"Distance CC Est":1.67,"Date Inspection":null,"M\\u00e9mo":null,"Date de MAJ":"1994-01-24T05:00:00+0000","Secteur":"Sud","Employ\\u00e9 MAJ":null,"Plan":"31H05-010-3735","No Structure":16315,"Ann\\u00e9e de construction":1984,"Hauteur Chemin\\u00e9e 2":0.0,"Distance CC Ouest":1.68,"Distance CC Sud":0.91,"Mod\\u00e8le Modifi\\u00e9":false,"R\\u00e9serv\\u00e9 au T\\u00e9l\\u00e9com":false,"Autorisation MAJ":null,"\\u00c0 \\u00eatre abandonn\\u00e9":false,"Plan du dossier":"368-299B","Structure migr\\u00e9e":false,"Info Migration":"Contrat / RT : C467-1\\n","Emplacement":"2485 Grand Trunk","Arrondissement":"Sud-Ouest","Employ\\u00e9 inspection":null}', 'coordinates': {"coordinates": [-73.566986, 45.478054], "type": "Point"}, 'clearance_height': 2.29, 'structure_type': 'PA', 'telco_only': False, 'closest_location': '2485 Grand Trunk'}, manual_values={})
Traceback (most recent call last):
  File "lab.py", line 25, in <module>
    main()
  File "lab.py", line 21, in main
    loop.run_until_complete(main_coro())
  File "/usr/lib64/python3.5/asyncio/base_events.py", line 337, in run_until_complete
    return future.result()
  File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib64/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "lab.py", line 14, in main_coro
    resp = yield from structure.save()
  File "/usr/lib64/python3.5/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib64/python3.5/asyncio/tasks.py", line 290, in _wakeup
    future.result()
  File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/home/lasgeirsson/code/goblin/goblin/models/vertex.py", line 231, in on_read
    result = f2.result()
  File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
RuntimeError: 597 Property Key with given name does not exist: structure_structure_type

Note that the vertex label is prepended to the property key by goblin even though the property key was already in the form vertexlabel_propertyname. This is a titan instance with the automatic schema generation turned off. The property keys were defined in titan to conform to goblin's convention.

@leifurhauks leifurhauks changed the title Mapping between property keys and Goblin properties Goblin constructs property keys with hypercorrective zeal Jun 30, 2016
@davebshow
Copy link
Contributor

I'm back and just about ready to get to work. I believe this is happening due to the fact you are using save instead of update to update/change properties. This is pretty confusing and we should discuss how to remedy this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants