def delete_net(net_id): if net_id[:2] == 'nn': return {'success': 0, 'messag': 'nn cannot be deleted'} count=0 for key in redis.keys(): if key[:key.rfind('-')] == net_id: count += redis.delete(key) sccs = 1 if count > 0 else 0 return {'success': sccs, 'message': '%d records from net %s deleted' % (count, net_id)}
def list_nets(): """Returns a list of all trained nets and the parameters they were created with. """ nets = filter(lambda x: x.split('-')[-1] == 'data', redis.keys()) if nets.__len__() > 0: net_ids = (x[:x.rfind('-')] for x in nets) nets = dict((key, json.loads(redis.get(redis_key('params', key)))) for key in net_ids) return nets