espeed / bulbs

A Python persistence framework for graph databases like Neo4j, OrientDB and Titan.
http://bulbflow.org
Other
623 stars 82 forks source link

save_graphml #16

Closed cswank closed 13 years ago

cswank commented 13 years ago

Hello, I'm not sure if it is just my setup, but when I run save_graphml I get:

f = g.save_graphml() Traceback (most recent call last): File "", line 1, in File "/home/craig/pion/src/bulbs/bulbs/graph.py", line 183, in save_graphml resp = self.resource.get(self.base_target,params) AttributeError: 'Graph' object has no attribute 'base_target'

This is on ubuntu with python 2.7.1

Craig

espeed commented 13 years ago

Hi Craig -

I updated Github with a fix -- save_graphml() should now return a text string containing the GraphML file. I tested it for tinkergraph, and it works.

cswank commented 13 years ago

Thanks a lot, James.

Is there anything I could help out with in the bulbs project?

Craig

On Sep 24, 2011, at 2:40 PM, James Thorntonreply@reply.github.com wrote:

Hi Craig -

I updated Github with a fix -- save_graphml() should now return a text string containing the GraphML file. I tested it for tinkergraph, and it works.

  • James

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2188094

cswank commented 13 years ago

I tried pulling the latest version of bulbs and rexster, and now nothing works in my web app I'm building. This has happened the last few times I've tried the git version of bulbs. I always have to go back the the pypi version. Do you know of some API change that would cause problems? When you are developing bulbs, which version of rexster are you connecting to?

Craig

On Sep 24, 2011, at 2:40 PM, James Thorntonreply@reply.github.com wrote:

Hi Craig -

I updated Github with a fix -- save_graphml() should now return a text string containing the GraphML file. I tested it for tinkergraph, and it works.

  • James

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2188094

espeed commented 13 years ago

Yes, Rexster updated its path structure so you have to use /graphs/ in your URL path:

http://localhost:8182/graphs/tinkergraph

I had updated rest.py by hardcoding /graphs/ into the path, but yesterday someone sent me a pull request because they were using Rexster behind a proxy and wanted to dynamically set the path via the URL. I accepted their pull request (see https://github.com/espeed/bulbs/pull/15 )

Let me know if it broke something, but I suspect the issue has more to do with needing to have /graphs/ in the path.

espeed commented 13 years ago

The Bulbs version on Github follows the Rexster snapshot on Github (i.e. the git pull version).

cswank commented 13 years ago

Hello James,

I updated my url in the bulbs_config to include graphs, but the rexster server says:

[INFO] AbstractSubResource - Request for a non-configured graph [tinkergraph]

But:

from bulbs.graph import Graph g = Graph() g.resource.db_url 'http://localhost:8182/graphs/pion'

So I don't get it. The rexster error message seems like it thinks I'm connecting to a graph called tinkergraph and my web app is completely broken. Do you have any other ideas that I might try?

Thanks,

Craig

On Sep 24, 2011, at 5:13 PM, James Thornton wrote:

Yes, Rexster updated it's path structure so you have to use /graphs/ in your URL path:

http://localhost:8182/graphs/tinkergraph

I had updated rest.py by hardcoding /graph/ into the path, but yesterday someone sent me a pull request because they were using bulbs behind a forwarding server or something and wanted to dynamically set the path via the URL. I accepted their pull request (see https://github.com/espeed/bulbs/pull/15 )

Let me know if that pull request broke something, but I suspect the issue has more to do with needing to have /graphs/ in the path.

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2188662

espeed commented 13 years ago

Check your rexster.xml file or paste it into a Github gist and I'll check it.

Also, you can set DEBUG=True into your bulbs_config.py file to see the actual URL Bulbs is requesting.

espeed commented 13 years ago

BTW I just ran the Bulbs tests after doing a git pull on the latest Rexster, and all tests passed so I'd check your rexster.xml.

cswank commented 13 years ago

Hello James, I think I'm getting somewhere. I have a script that initializes the database I use for my web app. When I ran it I set a pdb trace in bulbs.config and also put a print statement in bulbs.model:Model to see when the resource = Resource(config.DATABASE_URL) gets called and it turns out that that line is called before my set_trace in bulbs.config. I then tried moving the bulbs imports to the end of my initdb.py file and then the DATABASE_URL gets set correctly and my initdb.py works. My web app doesn't still, and I'm still trying to figure out how to get the config set correctly. That is why I see

[INFO] AbstractSubResource - Request for a non-configured graph [tinkergraph]

being printed when I load my web app url.

Do you have any ideas for me to get the config to be set correctly?

Craig

On Sep 25, 2011, at 12:30 AM, James Thornton wrote:

BTW I just ran the Bulbs tests after doing a git pull on the latest Rexster, and all tests passed so I'd check your rexster.xml.

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2189765

espeed commented 13 years ago

This sounds like your custom bulbs_config.py isn't being set.

Have you set DATABASE_URL in a custom bulbs_config.py, and do you get the standard tinkergraph output when you do this?

>>> from bulbs.graph import Graph
>>> g = Graph()
>>> g.V

If so then your bulbs_config.py isn't being sourced (but if that's the case, it should give you a warning about using the default config when you first import bulbs).

Fixing your bulbs_config.py will prob resolve the issue, or here's how you tell your models to use a DB other than the default configured in your bulbs_config.py (i.e. set Model.resource before you subcass Node and Relationship):

from bulbs.model import Model, Node, Relationship

Model.resource = Resource('http://localhost:8182/graphs/pion')

class Idea(Node):
   pass 
cswank commented 13 years ago

Yes, I think my bulbs_config does not get called right away. I know it does get called because I don't get that warning message. When I run this:

g = Graph()
g.clear()
print g.resource.db_url
p = Person(name='craig')
print p.resource.db_url

I get as output:

http://localhost:8182/pion-dev http://localhost:8182/graphs/tinkergraph

You can see that the graph object correctly has the DATABASE_URL I set in my bulbs_config.py. The custom model object has the default DATABASE_URL.

Craig

On Sep 25, 2011, at 1:58 PM, James Thornton wrote:

This sounds like your custom bulbs_config.py isn't being set.

Have you set DATABASE_URL in a custom bulbs_config.py, and do you get the standard tinkergraph output when you do this?

>>> from bulbs.graph import Graph
>>> g = Graph()
>>> g.V

If so then your bulbs_config.py isn't being sourced (but if that's the case, it should give you a warning about using the default config when you first import bulbs).

Fixing your bulbs_config.py will prob resolve the issue, or here's how you tell your models to use a DB other than the default configured in your bulbs_config.py (i.e. set Model.resource before you subcass Node and Relationship):

from bulbs.model import Model, Node, Relationship

Model.resource = Resource('http://localhost:8182/graphs/pion')

class Idea(Node):
  pass 

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2192669

espeed commented 13 years ago

Model uses the default DATABASE_URL unless you override it like I showed i the previous comment

See https://github.com/espeed/bulbs/blob/master/bulbs/model.py#L33

So for some reason it looks like your Person model is getting its DATABASE_URL from a different source than Graph -- did you by chance manually edit config.py or hardcode DATABASE_URL in graph.py or rest.py?

cswank commented 13 years ago

No, I have not hardcoded DATABASE_URL anywhere besides in my bulbs_config.py. I think I mentioned this in an earlier email, but if I change the order of my imports around I can get it to set the DATABASE_URL on the model correctly. I don't think it seems correct, though, to have to figure out the order stuff is imported.

On Sep 26, 2011, at 3:43 PM, James Thornton wrote:

Model uses the default DATABASE_URL unless you override it like I showed i the previous comment

See https://github.com/espeed/bulbs/blob/master/bulbs/model.py#L33

So for some reason it looks like your Person model is getting its DATABASE_URL from a different source that Graph -- did you by chance manually edit config.py or hardcode DATABASE_URL in graph.py or rest.py?

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2204334

espeed commented 13 years ago

No, you're right, you shouldn't have mess with the order of imports. Try grepping your files to see where the tinkergraph URL is coming from. There should be one in config.py, but if you've created a custom bulbs_config.py that should be the one being used because it overrides the values in config.py.

cswank commented 13 years ago

I've been looking around my package and can't find anything that could possibly set the db_url to tinkergraph. I'm scratching my head. I'm going to end up setting Model.resource, I think.

Craig

On Sep 26, 2011, at 4:22 PM, James Thornton wrote:

No, you're right, you shouldn't have mess with the order of imports. Try grepping your files to see where the tinkergraph URL is coming from. There should be one in config.py, but if you've created a custom bulbs_config.py that should be the one being used because it overrides the values in config.py.

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2204774

espeed commented 13 years ago

Or, just import bulbs.config and check the value of DATABASE_URL

cswank commented 13 years ago

I already tried modifying model.py and graph.py to print the config.DATABASE_URL and it shows the two different urls. Very confusing.

Craig

On Sep 26, 2011, at 5:39 PM, James Thorntonreply@reply.github.com wrote:

Or, just import bulbs.config and check the value of DATABASE_URL

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2205428

espeed commented 13 years ago

Here's how to set up bulbs_config.py...

https://groups.google.com/d/msg/gremlin-users/TKzaeaUtkBo/mkHbOte1TqsJ

I checked it on my dev system, and Model shows the right URL without importing Graph.

espeed commented 13 years ago

One other thing, did you uninstall all the old PyPI versions from both pip and/or easy_install?

cswank commented 13 years ago

I think I have the bulbs_config set up correctly. That is why in the example i emailed to you Graph has a correct resource.db_url.

Craig

On Sep 26, 2011, at 6:19 PM, James Thorntonreply@reply.github.com wrote:

Here's how to set up bulbs_config.py...

https://groups.google.com/d/msg/gremlin-users/TKzaeaUtkBo/mkHbOte1TqsJ

I checked it on my dev system, and Model shows the right URL without importing Graph.

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2205730

cswank commented 13 years ago

My site packages dir of the virtualenv has no reference to bulbs other than the egg link from running python setup.py develop:

(pion-dev)craig@nausori:~/pion-dev/src/pion$ ll ../../lib/python2.7/site-packages/ total 1884 drwxr-xr-x 54 craig craig 4096 2011-09-26 16:59 ./ drwxr-xr-x 4 craig craig 4096 2011-09-05 16:44 ../ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 Beaker-1.5.4-py2.7.egg/ drwxr-xr-x 6 craig craig 4096 2011-09-05 16:55 bpython-0.10.1-py2.7.egg/ -rw-r--r-- 1 craig craig 32 2011-09-26 16:59 bulbs.egg-link drwxr-xr-x 4 craig craig 4096 2011-09-20 19:24 chameleon/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 Chameleon-2.4.4-py2.7.egg-info/ -rw-r--r-- 1 craig craig 390041 2011-09-05 12:49 chardet-1.0.1-py2.7.egg drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 Deliverance-0.5.0-py2.7.egg/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 DevAuth-0.1.2-py2.7.egg/ drwxr-xr-x 2 craig craig 4096 2011-09-21 06:04 distribute-0.6.21-py2.7.egg-info/ -rw-r--r-- 1 craig craig 943 2011-09-26 16:25 easy-install.pth -rw-r--r-- 1 craig craig 126 2011-09-21 06:04 easy_install.py -rw-r--r-- 1 craig craig 331 2011-09-21 06:04 easy_install.pyc drwxr-xr-x 4 craig craig 4096 2011-09-05 12:50 HTTPEncode-0.1-py2.7.egg/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:50 httplib2-0.7.1-py2.7.egg/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 Importing-1.10-py2.7.egg/ -rw-r--r-- 1 craig craig 5863 2011-09-05 16:48 ipdb-0.6-py2.7.egg drwxr-xr-x 5 craig craig 4096 2011-09-05 16:49 ipython-0.11-py2.7.egg/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 lxml-2.3-py2.7-linux-x86_64.egg/ drwxr-xr-x 3 craig craig 4096 2011-09-20 19:24 mako/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 Mako-0.4.2-py2.7.egg-info/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 markupsafe/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 MarkupSafe-0.15-py2.7.egg-info/ drwxr-xr-x 5 craig craig 4096 2011-09-05 16:43 nose-1.1.2-py2.7.egg/ drwxr-xr-x 10 craig craig 4096 2011-09-20 19:24 paste/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 Paste-1.7.5.1-py2.7.egg-info/ -rw-r--r-- 1 craig craig 296 2011-09-20 19:24 Paste-1.7.5.1-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 PasteDeploy-1.5.0-py2.7.egg-info/ -rw-r--r-- 1 craig craig 296 2011-09-20 19:24 PasteDeploy-1.5.0-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 PasteScript-1.7.4.2-py2.7.egg-info/ -rw-r--r-- 1 craig craig 296 2011-09-20 19:24 PasteScript-1.7.4.2-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 12288 2011-09-07 09:11 PIL/ -rw-r--r-- 1 craig craig 4 2011-09-07 09:11 PIL.pth -rw-r--r-- 1 craig craig 31 2011-09-26 16:25 pion.egg-link drwxr-xr-x 4 craig craig 4096 2011-09-05 12:46 pip-1.0.2-py2.7.egg/ -rw-r--r-- 1 craig craig 89939 2011-09-21 06:04 pkg_resources.py -rw-r--r-- 1 craig craig 98653 2011-09-21 06:04 pkg_resources.pyc -rw-r--r-- 1 craig craig 85435 2011-09-20 19:24 pkg_resources.py.OLD.1316606692.41 -rw-r--r-- 1 craig craig 18551 2011-09-06 16:48 progressbar-2.3-py2.7.egg -rw-r--r-- 1 craig craig 24595 2011-09-05 12:49 py_bcrypt-0.2-py2.7-linux-x86_64.egg -rw-r--r-- 1 craig craig 564208 2011-09-05 12:47 pycrypto-2.3-py2.7-linux-x86_64.egg drwxr-xr-x 4 craig craig 4096 2011-09-05 12:50 Pygments-1.4-py2.7.egg/ -rw-r--r-- 1 craig craig 287662 2011-09-05 12:47 pymongo-2.0.1-py2.7-linux-x86_64.egg drwxr-xr-x 6 craig craig 4096 2011-09-20 19:24 pyramid/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 pyramid-1.2-py2.7.egg-info/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:47 pyramid_beaker-0.5-py2.7.egg/ drwxr-xr-x 3 craig craig 4096 2011-09-20 19:24 pyramid_who/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 pyramid_who-0.2-py2.7.egg-info/ drwxr-xr-x 4 craig craig 4096 2011-09-20 19:24 repoze/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 repoze.lru-0.4-py2.7.egg-info/ -rw-r--r-- 1 craig craig 299 2011-09-20 19:24 repoze.lru-0.4-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 repoze.who-2.0b1-py2.7.egg-info/ -rw-r--r-- 1 craig craig 1056 2011-09-20 19:24 repoze.who-2.0b1-py2.7-nspkg.pth drwxr-xr-x 4 craig craig 4096 2011-09-21 06:04 setuptools/ -rw-r--r-- 1 craig craig 144 2011-09-21 06:04 setuptools-0.6c11-py2.7.egg-info drwxr-xr-x 3 craig craig 4096 2011-09-21 06:04 setuptools-0.6c12dev_r88846-py2.7.egg-info/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 setuptools-0.6c12dev_r88846-py2.7.egg-info.OLD.1316606692.41/ drwxr-xr-x 4 craig craig 4096 2011-09-20 19:24 setuptools.OLD.1316606692.41/ -rw-r--r-- 1 craig craig 49 2011-09-26 16:25 setuptools.pth drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 simplejson-2.2.0-py2.7-linux-x86_64.egg/ -rw-r--r-- 1 craig craig 2362 2011-09-21 06:04 site.py -rw-r--r-- 1 craig craig 1757 2011-09-21 06:04 site.pyc -rw-r--r-- 1 craig craig 2362 2011-09-20 19:24 site.py.OLD.1316606692.41 -rw-r--r-- 1 craig craig 29652 2011-09-05 12:50 Tempita-0.5.1-py2.7.egg drwxr-xr-x 3 craig craig 4096 2011-09-20 19:24 tests/ drwxr-xr-x 3 craig craig 4096 2011-09-20 19:25 translationstring/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 translationstring-0.3-py2.7.egg-info/ drwxr-xr-x 4 craig craig 4096 2011-09-20 19:25 venusian/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 venusian-1.0a1-py2.7.egg-info/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 WebError-0.10.3-py2.7.egg/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 webob/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 WebOb-1.1.1-py2.7.egg-info/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:49 WSGIFilter-0.2-py2.7.egg/ drwxr-xr-x 4 craig craig 4096 2011-09-05 12:50 WSGIProxy-0.2.2-py2.7.egg/ drwxr-xr-x 6 craig craig 4096 2011-09-20 19:25 zope/ drwxr-xr-x 2 craig craig 4096 2011-09-20 19:24 zope.component-3.10.0-py2.7.egg-info/ -rw-r--r-- 1 craig craig 293 2011-09-20 19:24 zope.component-3.10.0-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 zope.deprecation-3.5.0-py2.7.egg-info/ -rw-r--r-- 1 craig craig 293 2011-09-20 19:25 zope.deprecation-3.5.0-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 zope.event-3.5.1-py2.7.egg-info/ -rw-r--r-- 1 craig craig 293 2011-09-20 19:25 zope.event-3.5.1-py2.7-nspkg.pth drwxr-xr-x 2 craig craig 4096 2011-09-20 19:25 zope.interface-3.7.0-py2.7.egg-info/ -rw-r--r-- 1 craig craig 293 2011-09-20 19:25 zope.interface-3.7.0-py2.7-nspkg.pth On Sep 26, 2011, at 6:30 PM, James Thornton wrote:

One other thing, did you uninstall all the old PyPI versions from both pip and/or easy_install?

Reply to this email directly or view it on GitHub: https://github.com/espeed/bulbs/issues/16#issuecomment-2205798

espeed commented 13 years ago

As an experiment, try installing Bulbs in a fresh, temporary virtualenv to see if that changes anything. It should still use your bulbs_config.py that you already set.