Ejemplo n.º 1
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('animals', 'root', 'root',
                                           initial_drop=True))


        g.create_all(AnimalsNode.registry)
        g.create_all(AnimalsRelationship.registry)
Ejemplo n.º 2
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('custom_field', 'root', 'root'
                                           , initial_drop=True))

        g.create_all(ClassFieldNode.registry)
        g.create_all(ClassFieldRelationship.registry)
        g.client.command('ALTER CLASS classfieldvertex CUSTOM test_field_1=test_string_one')
        g.client.command('ALTER CLASS classfieldvertex CUSTOM test_field_2="test string two"')
        g.client.command('ALTER CLASS classfieldedge CUSTOM test_field_1="test string two"')
Ejemplo n.º 3
0
    def testConfigs(self):
        configs = [
            'localhost:2424/test_config1',
            'localhost/test_config2',
            'plocal://localhost/test_config3',
            'plocal://localhost:2424/test_config4',
            'memory://localhost/test_config5',
            'memory://localhost:2424/test_config6',
        ]

        for conf in configs:
            # the following line should not raise errors
            Graph(Config.from_url(conf, 'root', 'root', initial_drop=True))
Ejemplo n.º 4
0
def get_test_graph(graph_name):
    """Generate the test database and return the pyorient client."""
    url = get_orientdb_url(graph_name)
    config = Config.from_url(url, ORIENTDB_USER, ORIENTDB_PASSWORD, initial_drop=True)
    Graph(config, strict=True)

    client = OrientDB('localhost', ORIENTDB_PORT)
    client.connect(ORIENTDB_USER, ORIENTDB_PASSWORD)
    client.db_open(graph_name, ORIENTDB_USER, ORIENTDB_PASSWORD, db_type=DB_TYPE_GRAPH)

    load_schema(client)
    generate_data(client)

    return client
Ejemplo n.º 5
0
    def testStrictness(self):
        g = self.g

        # Unknown properties get silently dropped by default
        pentium = g.cpu.create(name='Pentium', version=6)
        loaded_pentium = g.get_vertex(pentium._id)
        # Version is not defined in cpu
        assert not hasattr(pentium, 'version')

        # But in strict mode they generate errors
        g = self.g = Graph(Config.from_url('hardware', 'root', 'root'
                                           , initial_drop=False), strict=True)
        g.include(g.build_mapping(
            declarative_node(), declarative_relationship(), auto_plural=True))
        with self.assertRaises(AttributeError):
            pentium = g.cpu.create(name='Pentium', version=6)

        pentium = g.x86cpu.create(name='Pentium', version=6)
        self.assertEquals('Pentium', pentium.name)
        self.assertEquals(6, pentium.version)
Ejemplo n.º 6
0
def connect_database(host, user, password, is_initial_drop=False):
    global graph
    graph = Graph(Config.from_url(host, user, password, is_initial_drop))
Ejemplo n.º 7
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('test_datetime', 'root', 'root',
                                           initial_drop=True))

        g.create_all(DateTimeNode.registry)
Ejemplo n.º 8
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('test_unicode', 'root', 'root', initial_drop=True))

        g.create_all(UnicodeNode.registry)
Ejemplo n.º 9
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('test_embedded', 'root', 'root',
                            initial_drop=True))

        g.create_all(EmbeddedNode.registry)
Ejemplo n.º 10
0
"""

import itertools
import logging
import sys

import numpy as np
from pyorient.ogm import Graph, Config

import neuroarch.models as models
import neuroarch.query as query
import neuroarch.nxtools as nxtools

from cx_config import cx_db

graph = Graph(Config.from_url(cx_db, 'admin', 'admin', initial_drop=False))
graph.include(models.Node.registry)
graph.include(models.Relationship.registry)

logging.basicConfig(level=logging.DEBUG,
                    stream=sys.stdout,
                    format='%(asctime)s %(name)s %(levelname)s %(message)s')
logger = logging.getLogger('cx')

# Clear all executable circuit nodes:
for class_name in [
        'LPU', 'Pattern', 'Interface', 'Port', 'CircuitModel', 'LeakyIAF',
        'AlphaSynapse'
]:
    r = graph.client.command('delete vertex %s' % class_name)
    logger.info('deleted %s %s nodes' % (r[0], class_name))
Ejemplo n.º 11
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('test_datetime', 'root', 'root',
                            initial_drop=True))

        g.create_all(DateTimeNode.registry)
Ejemplo n.º 12
0
"""
util for drop specific classe
"""
import os

import django
from django.conf import settings
from pyorient import PyOrientSQLParsingException

from ngpyorient.graph import NgGraph
from ngpyorient.utils import write_error

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite_orientdb.settings")
django.setup()
from pyorient.ogm import Config

config = Config.from_url(
    settings.DATABASES_NG["default"]["URL"],
    settings.DATABASES_NG["default"]["USER"],
    settings.DATABASES_NG["default"]["PASSWORD"],
)
graph = NgGraph(config)

try:
    graph.drop_class_simple_by_class_name(sys.argv[1], sys.argv[2])
except PyOrientSQLParsingException as e:
    write_error(e)
except IndexError as e:
    write_error("you should specify classname and type(vertex or edge)")
graph.client.close()
Ejemplo n.º 13
0
from django.db import models
# Create your models here.
from pyorient.ogm import Config, declarative
# Initialize Registries
from pyorient.ogm.property import String, Integer

from ngpyorient.graph import NgGraph

# Create your models here.

config = Config.from_url(
    'plocal://10.60.49.214:2424/test1',
    'root',
    'rootpwd'
)

Node = declarative.declarative_node()
Relationship = declarative.declarative_relationship()
# graph = NgGraph(config)


class SmartPhone(Node):
    element_plural = "smartPhone"
    brand = String(unique=True)
    price = Integer()
Ejemplo n.º 14
0
 def setUp(self):
     g = self.g = Graph(Config.from_url('abstract_classes', 'root', 'root'
                                        , initial_drop=True))
     g.client.command('CREATE CLASS AbstractClass EXTENDS V ABSTRACT')
     g.client.command('CREATE CLASS ConcreteClass EXTENDS V')
Ejemplo n.º 15
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('money', 'root', 'root'
                                           , initial_drop=True))

        g.create_all(MoneyNode.registry)
        g.create_all(MoneyRelationship.registry)
Ejemplo n.º 16
0
 def setUp(self):
     g = self.g = Graph(
         Config.from_url('test_embedded_defaults',
                         'root',
                         'root',
                         initial_drop=True))
Ejemplo n.º 17
0
 def setUp(self):
     g = self.g = Graph(Config.from_url('classes', 'root', 'root'
                                        , initial_drop=True))
Ejemplo n.º 18
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('animals', 'root', 'root', initial_drop=True))

        g.create_all(AnimalsNode.registry)
        g.create_all(AnimalsRelationship.registry)
Ejemplo n.º 19
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('test_unicode', 'root', 'root',
                                           initial_drop=True))

        g.create_all(UnicodeNode.registry)
Ejemplo n.º 20
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('hardware', 'root', 'root', initial_drop=True))

        g.create_all(HardwareNode.registry)
        g.create_all(HardwareRelationship.registry)
Ejemplo n.º 21
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('test_embedded', 'root', 'root',
                                           initial_drop=True))

        g.create_all(EmbeddedNode.registry)
Ejemplo n.º 22
0
 def get_new_connection(self, conn_params):
     config = Config.from_url(*conn_params)
     conn = NgGraph(config)
     return conn
Ejemplo n.º 23
0
 def setUp(self):
     g = self.g = Graph(Config.from_url('test_embedded_defaults', 'root', 'root',
                                        initial_drop=True))
Ejemplo n.º 24
0
    def setUp(self):
        g = self.g = Graph(
            Config.from_url('money', 'root', 'root', initial_drop=True))

        g.create_all(MoneyNode.registry)
        g.create_all(MoneyRelationship.registry)
Ejemplo n.º 25
0
    def setUp(self):
        g = self.g = Graph(Config.from_url('hardware', 'root', 'root'
                                           , initial_drop=True))

        g.create_all(HardwareNode.registry)
        g.create_all(HardwareRelationship.registry)
Ejemplo n.º 26
0
 def setUp(self):
     g = self.g = Graph(
         Config.from_url('classes', 'root', 'root', initial_drop=True))
Ejemplo n.º 27
0
 def setUp(self):
     g = self.g = Graph(Config.from_url('abstract_classes', 'root', 'root'
                                        , initial_drop=True))
     g.client.command('CREATE CLASS AbstractClass EXTENDS V ABSTRACT')
     g.client.command('CREATE CLASS ConcreteClass EXTENDS V')
Ejemplo n.º 28
0
def main():

	logging.basicConfig(level=logging.DEBUG, stream=sys.stdout,
	                    format='%(asctime)s %(name)s %(levelname)s %(message)s')
	logger = logging.getLogger('cx')



	sys.setrecursionlimit(10000)
	### Graph ###
	graph = Graph(Config.from_url(cx_db, 'admin', 'admin',
	                              initial_drop=False))
	graph.include(models.Node.registry)
	graph.include(models.Relationship.registry)


	### Retina ###
	config=retlam_demo.ConfigReader('retlam_default.cfg','../template_spec.cfg').conf

	retina = get_retina(config)
	

	##### Configuration  ######
	logger = setup_logger(screen=True)
	lpu_selectors, to_list = get_cx_selectors_name()
	lpu_name_to_comp_dict, lpu_name_to_conn_list, pat_name_list, pat_name_to_pat = cx_component(graph)
	

	man = core.Manager()

	dt = 1e-4
	dur = 0.2
	steps = int(dur/dt)
	debug = True

	lpu_name_list = ['BU', 'bu', 'EB', 'FB', 'PB']
	for name in lpu_name_list:
		input_processor = []
		output_processor = [FileOutputProcessor([('spike_state', None), ('V',None), ('g',None), ('I', None)], '{}_output.h5'.format(name), sample_interval = 1)]

		man.add(LPU, name, dt, lpu_name_to_comp_dict[name],
	            lpu_name_to_conn_list[name],
	            input_processors = input_processor,
	            output_processors = output_processor,
	            device=0,
	            debug=debug, time_sync=False)


	retlam_demo.add_retina_LPU(config, 0, retina, man)
	logger.info('add retina lpu')

	for name in pat_name_list:
	    id_0, id_1 = name.split('-')
	    man.connect(id_0, id_1, pat_name_to_pat[name][0], pat_name_to_pat[name][1].index('0'), pat_name_to_pat[name][1].index('1'))

	logger.info('link lpus among cx lpus')    

	link_retina_pat_cx(retina, lpu_selectors, to_list, man)
	logger.info('link retina and cx lpu')
	
	man.spawn()
	man.start(steps)
	man.wait()