Commit 1f3d4082 authored by Matic Perovšek's avatar Matic Perovšek

import package more informative 'multiple models withs same uid' error log

parent 1f412e1b
......@@ -14,11 +14,6 @@ def chunks(l, n):
import time
def wordify_examples((name_to_table,connecting_tables,context,index_by_value,target_table_name,word_att_length,ex_idxs)):
cached_sentences=defaultdict(dict)
#import sys
#print "b",time.time()
#sys.stdout.flush()
#name_to_table[target_table_name]
#name_to_table[target_table_name].getitemsref(ex_idxs)
return [wordify_example(name_to_table,connecting_tables,context,cached_sentences,index_by_value,target_table_name,word_att_length,target_table_name,ex,set([])) for ex in name_to_table[target_table_name].getitemsref(ex_idxs)]
......@@ -35,9 +30,7 @@ def wordify_example(name_to_table,connecting_tables,context,cached_sentences,ind
# print "cc",cached_sentences
debug=False
data_name=str(data_name)
#ex=data[ex_idx]
#if data_name=="ring_strucs":
# print data_name
if debug:
print "======================================"
print "example:",ex
......@@ -160,15 +153,6 @@ class Wordification(object):
#class + wordification on every example of the main table
p = multiprocessing.Pool(num_of_processes)
import pickle
#test=pickle.loads(pickle.dumps(self))
# test=pickle.loads(pickle.dumps(self.connecting_tables))
# test=pickle.loads(pickle.dumps(self.context))
# test=pickle.loads(pickle.dumps(self.cached_sentences))
# test=pickle.loads(pickle.dumps(self.index_by_value))
# #test=pickle.loads(pickle.dumps(self.target_table[0]))
# print test
indices = chunks (range(len(self.target_table)),num_of_processes)#)
......@@ -246,13 +230,6 @@ class Wordification(object):
arff_string+=string.join(features,',')
arff_string+="\n"
#f=open("a.arff",'w')
#f.write(arff_string)
#f.close
#print arff_string
#print "end to_arff"
return arff_string
......
......@@ -87,10 +87,22 @@ def import_package_string(writeFunc, string, replace, verbosity=1):
#check for DB UID duplicates
objsdbDict = dict((x.uid,x) for x in objsDb if len(x.uid) != 0)
if len([x for x in objsDb if len(x.uid) != 0]) != len(objsdbDict):
raise CommandError('Input process terminated without any changes to the database. There were multiple equal '
'UIDs defined on different models in the database. The input procedure can not continue '
'from safety reasons. Please resolve manually!')
error_txt= 'Input process terminated without any changes to the database. There were multiple equal ' \
'UIDs defined on different models in the database. The input procedure can not continue ' \
'from safety reasons. Please resolve manually! UIDs with multiple models:'
#count objects per uid
from collections import defaultdict
objs_per_uid=defaultdict(list)
for x in objsDb:
if x.uid:
objs_per_uid[x.uid].append(x)
for uid,objs in objs_per_uid.items():
if len(objs)>1:
error_txt+="\n\nUID: "+str(uid)+"\nobjects: "+str(objs)
raise CommandError(error_txt)
#create new to existing id mapping and check for type match
idMappingDict = dict()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment