camomile-project / camomile-server

Collaborative annotation of multimedia documents
http://camomile-project.github.io/
MIT License
12 stars 4 forks source link

Metadata creation MongoDB error #64

Open Nelgamix opened 8 years ago

Nelgamix commented 8 years ago

Hello, I have an issue when it comes to create new metadata. I ran all the basics step for a fresh install, and tried to create metadata with this python script:

from camomile import Camomile
import sys

print(' Connecting...')
client = Camomile('http://localhost:3000')
print(' Logging in...')
client.login('root', 'admin')

# We seek the corpus or we create it
cprs = client.getCorpora(name='poiuytreza')
if len(cprs) == 0:  # If we didn't find it, we need to create it
    cprs = client.createCorpus('test')
else:  # Otherwise, we create it here
    cprs = cprs[0]

# We try to add metadata
try:
    client.setCorpusMetadata(cprs._id, path="mymtdata", datas={'gt': 'dzq'})
except Exception as e:
    print('Erreur: ' + str(e))
    sys.exit(-1)

print(' Logging out...')
client.logout()  # Logout of the camomile server

But it seems that the server is throwing an error:

python test.py ../camomile_data/media
 Connecting...
 Logging in...
Erreur: 400 Camomile Client Error: {u'message': u'E11000 duplicate key error collection: camomile.metadatas index: path_1 dup key: { : "," }', u'code': 11000, u'ok': 0, u'name': u'MongoError', u'errmsg': u'E11000 duplicate key error collection: camomile.metadatas index: path_1 dup key: { : "," }'}

I tried with the JS client too, and the same error happens. The python client is up to date (v0.8)

When I investigated the code, I found that it's maybe because this.constructTreeSchema(metadata, upload_dir, undefined, undefined, modelName, resource); is not doing its job and the tree tries to recreate root paths that already exist...

Could you please look into that and tell me what you think about it? Maybe i'm just doing something wrong here, and if that's the case, I think the documentation is either not up to date or incomplete.

Thanks

hbredin commented 8 years ago

Documentation is not up to date. It should actually be used like that:

client.setCorpusMetadata(cprs._id, {'gt': 'dzq'}, path="mymtdata")

That being said, I think you did discover a bug in the server. Will look into it.

cc'ing @marc-j just in case you have an idea of what might happen here...

Nelgamix commented 8 years ago

After a full cleanup of the system and of docker images, it seems that it works again, that was maybe due to a bad database clean up. Sorry for that. I tried just now and it seems that the problem is gone. Thanks

hbredin commented 8 years ago

I'd rather leave this issue open until we are really sure the bug is fixed. There might actually be a problem... But I am glad your problem is gone :)

Nelgamix commented 8 years ago

There was a problem, and I don't understand why it's fixed now (with the cleanup), because when I tested with each time a new corpus (before the full cleanup), this problem occured. But again, I just tried several times, maybe it's not fixed