From 21bd4996c13ba735dd23521086757b9944d7ac73 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Tue, 3 Jan 2017 14:21:53 +0100 Subject: [PATCH 01/17] create dev branch --- package.json | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f2e53dd..8320fa8 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "name": "phovea_data_mongo", "description": "Data provider plugin for loading graph data stored in a MongoDB.", "homepage": "https://phovea.caleydo.org", - "version": "0.0.5", + "version": "0.1.0-SNAPSHOT", "author": { "name": "The Caleydo Team", "email": "contact@caleydo.org", diff --git a/requirements.txt b/requirements.txt index 5d51859..cdccb89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ --e git+https://github.com/phovea/phovea_server.git@v0.0.5#egg=phovea_server +-e git+https://github.com/phovea/phovea_server.git@develop#egg=phovea_server pymongo==3.0.3 \ No newline at end of file From 6956e615c7a2bcef669e3f4e96fa81e6a2a7d5ef Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Wed, 4 Jan 2017 18:00:07 +0100 Subject: [PATCH 02/17] reorder fields --- package.json | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 8320fa8..a7e1edc 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,21 @@ { + "name": "phovea_data_mongo", + "description": "Data provider plugin for loading graph data stored in a MongoDB.", + "homepage": "https://phovea.caleydo.org", + "version": "0.1.0-SNAPSHOT", + "author": { + "name": "The Caleydo Team", + "email": "contact@caleydo.org", + "url": "https://caleydo.org" + }, + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/phovea/phovea_data_mongo/issues" + }, + "repository": { + "type": "git", + "url": "https://github.com/phovea/phovea_data_mongo.git" + }, "files": [ "phovea_data_mongo", "__init__.py", @@ -18,22 +35,5 @@ "docs": "echo todo creating docs...", "prebuild": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test", "build": "python -c \"from distutils.dir_util import mkpath ; mkpath('./build/source')\" && (tar -c ./phovea_data_mongo --exclude '*.pyc' | tar -xC build/source)" - }, - "name": "phovea_data_mongo", - "description": "Data provider plugin for loading graph data stored in a MongoDB.", - "homepage": "https://phovea.caleydo.org", - "version": "0.1.0-SNAPSHOT", - "author": { - "name": "The Caleydo Team", - "email": "contact@caleydo.org", - "url": "https://caleydo.org" - }, - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/phovea/phovea_data_mongo/issues" - }, - "repository": { - "type": "git", - "url": "https://github.com/phovea/phovea_data_mongo.git" } } From b8fbd139fe6ff11461cbc969e4def47959538229 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Fri, 6 Jan 2017 16:40:00 +0100 Subject: [PATCH 03/17] add data container --- deploy/docker-compose.partial.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deploy/docker-compose.partial.yml b/deploy/docker-compose.partial.yml index 8f67d75..60734ed 100644 --- a/deploy/docker-compose.partial.yml +++ b/deploy/docker-compose.partial.yml @@ -6,4 +6,9 @@ services: links: - db_mongo:mongo db_mongo: - image: mongo:3.2 \ No newline at end of file + image: mongo:3.2 + volumes_from: + - db_mongo_data + db_mongo_data: + image: mongo:3.2 + entrypoint: echo data only \ No newline at end of file From 3234010d05c4123b4de73df26ea6c70668a65d83 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Sun, 8 Jan 2017 21:39:36 +0100 Subject: [PATCH 04/17] switch to named data volumes --- deploy/docker-compose.partial.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/deploy/docker-compose.partial.yml b/deploy/docker-compose.partial.yml index 60734ed..1d9c07b 100644 --- a/deploy/docker-compose.partial.yml +++ b/deploy/docker-compose.partial.yml @@ -7,8 +7,7 @@ services: - db_mongo:mongo db_mongo: image: mongo:3.2 - volumes_from: - - db_mongo_data - db_mongo_data: - image: mongo:3.2 - entrypoint: echo data only \ No newline at end of file + volumes: + - db_mongo_data:/data/db +volumes: + db_mongo_data: \ No newline at end of file From af7a163c452dbc07ea4955ea3f26684f06d91b11 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Wed, 25 Jan 2017 12:44:11 +0100 Subject: [PATCH 05/17] yo phovea:update --- .gitattributes | 3 ++- README.md | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitattributes b/.gitattributes index 833eaab..544c336 100644 --- a/.gitattributes +++ b/.gitattributes @@ -67,6 +67,7 @@ # build config *.npmignore text *.bowerrc text +Dockerfile text eof=LF # Heroku Procfile text @@ -123,4 +124,4 @@ AUTHORS text # Note: .db, .p, and .pkl files are associated # with the python modules ``pickle``, ``dbm.*``, # ``shelve``, ``marshal``, ``anydbm``, & ``bsddb`` -# (among others). \ No newline at end of file +# (among others). diff --git a/README.md b/README.md index cb99462..c4ddc0a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ npm run build *** -This repository is part of **[Phovea](http://phovea.caleydo.org/)**, a platform for developing web-based visualization applications. For tutorials, API docs, and more information about the build and deployment process, see the [documentation page](http://caleydo.org/documentation/). +This repository is part of **[Phovea](http://phovea.caleydo.org/)**, a platform for developing web-based visualization applications. For tutorials, API docs, and more information about the build and deployment process, see the [documentation page](http://phovea.caleydo.org). [phovea-image]: https://img.shields.io/badge/Phovea-Server%20Plugin-10ACDF.svg @@ -40,5 +40,5 @@ This repository is part of **[Phovea](http://phovea.caleydo.org/)**, a platform [npm-url]: https://npmjs.org/package/phovea_data_mongo [travis-image]: https://travis-ci.org/phovea/phovea_data_mongo.svg?branch=master [travis-url]: https://travis-ci.org/phovea/phovea_data_mongo -[daviddm-image]: https://david-dm.org/phovea/phovea_data_mongo.svg?theme=shields.io +[daviddm-image]: https://david-dm.org/phovea/phovea_data_mongo/status.svg [daviddm-url]: https://david-dm.org/phovea/phovea_data_mongo From d8fa0d560af9fbdda55690e21237f31ff372e678 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 9 Feb 2017 15:52:26 +0100 Subject: [PATCH 06/17] yo phovea:update --- build.py | 51 +++++++++++++++ docs/.gitignore | 3 + docs/_static/touch.txt | 0 docs/_templates/touch.txt | 0 docs/conf.py | 126 ++++++++++++++++++++++++++++++++++++++ package.json | 4 +- setup.py | 10 ++- 7 files changed, 190 insertions(+), 4 deletions(-) create mode 100644 build.py create mode 100644 docs/.gitignore create mode 100644 docs/_static/touch.txt create mode 100644 docs/_templates/touch.txt create mode 100644 docs/conf.py diff --git a/build.py b/build.py new file mode 100644 index 0000000..c259414 --- /dev/null +++ b/build.py @@ -0,0 +1,51 @@ +import shutil +from codecs import open +import json + +__author__ = 'Samuel Gratzl' + + +def _git_head(cwd): + import subprocess + try: + output = subprocess.check_output(['git', 'rev-parse', '--verify', 'HEAD'], cwd=cwd) + return output.strip() + except subprocess.CalledProcessError: + return 'error' + + +def _resolve_plugin(repo, version): + import os.path + if os.path.isdir('.git') and repo: + if repo.endswith('.git'): + repo = repo[0:-4] + return repo + '/commit/' + _git_head('.') + # not a git repo + return version + + +def to_version(v): + import datetime + now = datetime.datetime.utcnow() + return v.replace('SNAPSHOT', now.strftime('%Y%m%d-%H%M%S')) + + +with open('package.json', 'r', encoding='utf-8') as f: + pkg = json.load(f) + +name = pkg['name'] +version = to_version(pkg['version']) +resolved = _resolve_plugin(pkg.get('repository', {}).get('url'), version) + +# copy source code +shutil.rmtree('build/source', ignore_errors=True) +shutil.copytree(name, 'build/source', symlinks=False, ignore=shutil.ignore_patterns('*.pyc')) + +# create buildInfo.json +build_info = dict(name=name, version=version, resolved=resolved, description=pkg['description'], + homepage=pkg.get('homepage'), repository=pkg.get('repository', {}).get('url')) + +# TODO create build Info + +with open('build/source/buildInfo.json', 'w', encoding='utf-8') as f: + json.dump(build_info, f, indent=2) diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..0af02c8 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,3 @@ +/modules.rst +/phovea_server.rst + diff --git a/docs/_static/touch.txt b/docs/_static/touch.txt new file mode 100644 index 0000000..e69de29 diff --git a/docs/_templates/touch.txt b/docs/_templates/touch.txt new file mode 100644 index 0000000..e69de29 diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..cf81bf7 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import sys +import os +import json +from codecs import open + +sys.path.insert(0, os.path.abspath('..')) + +with open('../package.json', encoding='utf-8') as json_data: + import json + + pkg = json.load(json_data) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +source_parsers = { + '.md': 'recommonmark.parser.CommonMarkParser', +} +source_suffix = ['.rst', '.md'] + +# The master toctree document. +master_doc = 'index' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This patterns also effect to html_static_path and html_extra_path +exclude_patterns = ['build', 'tests'] + +# General information about the project. +project = pkg['name'] +copyright = pkg['license'] +author = pkg['author']['name'] + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = pkg['version'] +# The full version, including alpha/beta/rc tags. +release = pkg['version'] + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# -- Options for HTMLHelp output ------------------------------------------ + +# Output file base name for HTML help builder. +htmlhelp_basename = pkg['name'] + 'doc' + +# Sort members by type +autodoc_member_order = 'groupwise' + + +# Ensure that the __init__ method gets documented. +def skip(app, what, name, obj, skip, options): + if name == '__init__': + return False + return skip + + +def setup(app): + app.connect('autodoc-skip-member', skip) + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/package.json b/package.json index a7e1edc..2b045e1 100644 --- a/package.json +++ b/package.json @@ -32,8 +32,8 @@ "test": "test ! -d tests || python setup.py test", "predist": "npm run build && npm run docs", "dist": "python setup.py bdist_egg", - "docs": "echo todo creating docs...", + "docs": "sphinx-apidoc -o docs -f ./phovea_data_mongo && sphinx-build ./docs build/docs", "prebuild": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test", - "build": "python -c \"from distutils.dir_util import mkpath ; mkpath('./build/source')\" && (tar -c ./phovea_data_mongo --exclude '*.pyc' | tar -xC build/source)" + "build": "python build.py" } } diff --git a/setup.py b/setup.py index 2f7a0a1..84fb9e0 100644 --- a/setup.py +++ b/setup.py @@ -30,9 +30,15 @@ def packaged(*files): return r +def to_version(v): + import datetime + now = datetime.datetime.utcnow() + return v.replace('SNAPSHOT', now.strftime('%Y%m%d-%H%M%S')) + + setup( name=pkg['name'], - version=pkg['version'], + version=to_version(pkg['version']), description=pkg['description'], long_description=read_it('README.md'), keywords=pkg.get('keywords', ''), @@ -71,7 +77,7 @@ def packaged(*files): # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these # have to be included in MANIFEST.in as well. - package_data=packaged('config.json'), + package_data=packaged('config.json', 'buildInfo.json'), # Although 'package_data' is the preferred approach, in some case you may # need to place data files outside of your packages. See: From 7fe12a57c6ca525a7fc2d565d3e46591d86f28a2 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 9 Feb 2017 16:15:04 +0100 Subject: [PATCH 07/17] add missing dev dependency --- requirements_dev.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements_dev.txt b/requirements_dev.txt index 0e2902f..7ca3f68 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -2,3 +2,5 @@ flake8==3.0.4 pep8-naming==0.4.1 pytest==3.0.3 pytest-runner==2.9 +Sphinx==1.5.2 +recommonmark==0.4.0 From b074c776dd719e1ac8cb925bd024202bbd2945c5 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 9 Feb 2017 16:19:46 +0100 Subject: [PATCH 08/17] add missing index file --- docs/index.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docs/index.rst diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..e5a329d --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,20 @@ +.. phovea_data_mongo documentation master file, created by + sphinx-quickstart on Tue Feb 7 19:42:32 2017. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to phovea_data_mongo's documentation! +========================================= + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + modules + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From 8ba81103244a78067acd3109a340110fd0602b5e Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 9 Feb 2017 17:51:09 +0100 Subject: [PATCH 09/17] fix missing copy of python code --- build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.py b/build.py index c259414..c93604c 100644 --- a/build.py +++ b/build.py @@ -38,8 +38,8 @@ def to_version(v): resolved = _resolve_plugin(pkg.get('repository', {}).get('url'), version) # copy source code -shutil.rmtree('build/source', ignore_errors=True) -shutil.copytree(name, 'build/source', symlinks=False, ignore=shutil.ignore_patterns('*.pyc')) +shutil.rmtree('build/source/' + name, ignore_errors=True) +shutil.copytree(name, 'build/source/' + name, symlinks=False, ignore=shutil.ignore_patterns('*.pyc')) # create buildInfo.json build_info = dict(name=name, version=version, resolved=resolved, description=pkg['description'], @@ -47,5 +47,5 @@ def to_version(v): # TODO create build Info -with open('build/source/buildInfo.json', 'w', encoding='utf-8') as f: +with open('build/source/'+ name +'/buildInfo.json', 'w', encoding='utf-8') as f: json.dump(build_info, f, indent=2) From ee87c78c79b7bfbf7ef885ab96c934f40dc7573f Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 9 Feb 2017 18:10:36 +0100 Subject: [PATCH 10/17] fix flake8 --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index c93604c..2a12e00 100644 --- a/build.py +++ b/build.py @@ -47,5 +47,5 @@ def to_version(v): # TODO create build Info -with open('build/source/'+ name +'/buildInfo.json', 'w', encoding='utf-8') as f: +with open('build/source/' + name + '/buildInfo.json', 'w', encoding='utf-8') as f: json.dump(build_info, f, indent=2) From ed4cb1e7af7303ee501418ae77cd362734fcca57 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Mon, 27 Feb 2017 15:44:45 +0100 Subject: [PATCH 11/17] secure datasets --- phovea_data_mongo/graph.py | 46 ++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/phovea_data_mongo/graph.py b/phovea_data_mongo/graph.py index dcd9878..6d71224 100644 --- a/phovea_data_mongo/graph.py +++ b/phovea_data_mongo/graph.py @@ -31,20 +31,25 @@ def create(data, user, id, db): import datetime entry = dict( - name=data['name'], - description=data.get('description', ''), - creator='unknown' if user.is_anonymous else user.name, - nnodes=len(data['nodes']), - nedges=len(data['edges']), - attrs=data.get('attrs', {}), - ts=datetime.datetime.utcnow()) + name=data['name'], + description=data.get('description', ''), + creator=user.name, + nnodes=len(data['nodes']), + nedges=len(data['edges']), + attrs=data.get('attrs', {}), + ts=datetime.datetime.utcnow()) + + if 'group' in data: + entry['group'] = data['group'] + if 'permissions' in data: + entry['permissions'] = data['permissions'] if id is not None: entry['id'] = id data_entry = dict( - nodes=data['nodes'], - edges=data['edges'] + nodes=data['nodes'], + edges=data['edges'] ) data_id = db.graph_data.insert_one(data_entry).inserted_id @@ -86,6 +91,10 @@ def to_description(self): if self._entry is not None: r['description'] = self._entry['description'] r['creator'] = self._entry['creator'] + if 'group' in self._entry: + r['group'] = self._entry['group'] + if 'permissions' in self._entry: + r['permissions'] = self._entry['permissions'] r['ts'] = self._entry['ts'] return r @@ -120,7 +129,8 @@ def remove_node(self, id): # remove node and all associated edges self._db.graph_data.update(self._find_data, {'$pull': dict(nodes=dict(id=id))}, multi=False) - self._db.graph_data.update(self._find_data, {'$pull': dict(edges={'$or': [dict(source=id), dict(target=id)]})}, multi=True) + self._db.graph_data.update(self._find_data, {'$pull': dict(edges={'$or': [dict(source=id), dict(target=id)]})}, + multi=True) if self._edges: self._edges = [e for e in self._edges if e.source != id and e.target != id] @@ -209,27 +219,19 @@ def __init__(self): self.client = MongoClient(c.host, c.port) self.db = self.client.graph - @property - def entries(self): - return MongoGraph.list(self.db) - - def __len__(self): - return len(self.entries) - def __iter__(self): - return iter(self.entries) + return iter((f for f in MongoGraph.list(self.db) if f.can_read())) def remove(self, entry): - if isinstance(entry, MongoGraph) and entry.remove(): + if isinstance(entry, MongoGraph) and entry.can_write() and entry.remove(): return True return False def upload(self, data, files, id=None): if not data.get('type', 'unknown') == 'graph': return None # can't handle - from phovea_server.security import manager - m = manager() - user = m.current_user + from phovea_server.security import current_user + user = current_user() parsed = phovea_server.graph.parse(data, files) From 71b0026e026d12d8e36e981eb6c2eb8ae6d65f8a Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Mon, 27 Feb 2017 15:53:33 +0100 Subject: [PATCH 12/17] rename Graph to AGraph --- phovea_data_mongo/graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phovea_data_mongo/graph.py b/phovea_data_mongo/graph.py index 6d71224..fa7f496 100644 --- a/phovea_data_mongo/graph.py +++ b/phovea_data_mongo/graph.py @@ -2,7 +2,7 @@ import phovea_server.graph -class MongoGraph(phovea_server.graph.Graph): +class MongoGraph(phovea_server.graph.AGraph): def __init__(self, entry, db): super(MongoGraph, self).__init__(entry['name'], 'mongodb', entry.get('id', None), entry.get('attrs', None)) self._entry = entry From d962ceb0d1cf4415e2dfa990d8a67b66b2592d5a Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Mon, 27 Feb 2017 16:32:05 +0100 Subject: [PATCH 13/17] fix flake8 --- phovea_data_mongo/graph.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/phovea_data_mongo/graph.py b/phovea_data_mongo/graph.py index fa7f496..a9b3096 100644 --- a/phovea_data_mongo/graph.py +++ b/phovea_data_mongo/graph.py @@ -30,14 +30,13 @@ def create(data, user, id, db): # other_data = dict() import datetime - entry = dict( - name=data['name'], - description=data.get('description', ''), - creator=user.name, - nnodes=len(data['nodes']), - nedges=len(data['edges']), - attrs=data.get('attrs', {}), - ts=datetime.datetime.utcnow()) + entry = dict(name=data['name'], + description=data.get('description', ''), + creator=user.name, + nnodes=len(data['nodes']), + nedges=len(data['edges']), + attrs=data.get('attrs', {}), + ts=datetime.datetime.utcnow()) if 'group' in data: entry['group'] = data['group'] @@ -47,10 +46,9 @@ def create(data, user, id, db): if id is not None: entry['id'] = id - data_entry = dict( - nodes=data['nodes'], - edges=data['edges'] - ) + data_entry = dict(nodes=data['nodes'], + edges=data['edges'] + ) data_id = db.graph_data.insert_one(data_entry).inserted_id entry['refid'] = str(data_id) From de42adb09e88a489d6ac0bb9879c122664dd2316 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Thu, 2 Mar 2017 09:47:13 +0100 Subject: [PATCH 14/17] fix #2 configurable database --- phovea_data_mongo/config.json | 3 ++- phovea_data_mongo/graph.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/phovea_data_mongo/config.json b/phovea_data_mongo/config.json index 6821929..d397e47 100644 --- a/phovea_data_mongo/config.json +++ b/phovea_data_mongo/config.json @@ -1,4 +1,5 @@ { "host": "mongo", - "port": 27017 + "port": 27017, + "db": "graph" } diff --git a/phovea_data_mongo/graph.py b/phovea_data_mongo/graph.py index dcd9878..34e9a82 100644 --- a/phovea_data_mongo/graph.py +++ b/phovea_data_mongo/graph.py @@ -207,7 +207,7 @@ def __init__(self): from pymongo import MongoClient self.client = MongoClient(c.host, c.port) - self.db = self.client.graph + self.db = self.client[c.db] @property def entries(self): From b11da0f29d4cd31c36a8160710fc545bb0f10bba Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Wed, 5 Apr 2017 09:59:24 +0200 Subject: [PATCH 15/17] travis enable slack,pypi,npm,releases --- .travis.yml | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8093049..c7980d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,33 @@ language: python sudo: required env: - - TOXENV=py27 - - TOXENV=py34 - +- TOXENV=py27 +- TOXENV=py34 install: - - (!(test -f docker_packages.txt) || (cat docker_packages.txt | xargs sudo apt-get install -y)) - - pip install -r requirements_dev.txt - - pip install -r requirements.txt - +- "(!(test -f docker_packages.txt) || (cat docker_packages.txt | xargs sudo apt-get + install -y))" +- pip install -r requirements_dev.txt +- pip install -r requirements.txt script: npm run dist - +notifications: + slack: + secure: nDASe9U/8foQRcCed3gqmR4N5sKnZWvuogBWfF3rfxNdmkWhIlGgI1r+zzLHb9xJxPPX6hoq805t7NMkCPzb1Q46rZOSGxFTyiQnA/PCGe2ZUmV44f3ukIuy7ousqiylxvsbcTFzdaT64GjvrkThj/0VVGx4hldor6ggQIWngfZct5+JQB3L1Sn7g3JBMD3v2PGO77ziK/ps7uCJtvSlpaQMpxOiSC42O3oFU/giGYjXiggC10ztfSDGVNH0zm73FoQtVimzn6FkzqHzhOyTcMa9ehXm4FcO0TfYvnOJ3Ir/G80pHtc1KxoAh2c0daBpnNGqVPf12lqJ+9c7KwVx0csPPUvzeIG2G6Dn4lP891CDY03SOY/XtlzTQDvCTBDxgKSDbh9rxXM05eCdNk90h0Fi2lV0QnuJCBFjFDdVHKN3HIoUMHKCgYav5pOAiMA+WMIqk3BnkHsqVK1KHxDDxK4qK0xl6p75aiPvrBne/q67eLPfHC13mbDlexGy0sokOtN7S0HhW2oaTZ01t8ESUPGahknn0arBSiM88rPntgNTcWom2nfeqrbA0/cj7A9RXlh7NjDW4iUpLKDdlDnqNXtsUDPdyFqS0v1TfykOy/ladh2ktBvDZ2KfdLN7wktgE+P1Ebduja7Kv/dc54e8wc4t+vdXGbzb+cCXUjzbUwM= + on_success: change + on_failure: always deploy: - provider: releases +- provider: releases api_key: - secure: TK9/P34Bi3WuppiDrBCwVcn41yCBwmILaU8hXTBzUPbT7TbeFIwsC6/4CtH85Z+ZrUve4S5pTmWRNf2dQDxWw3uYu7+bJuemV2J1LHG76mognj+TNEiYxfLQUt3Gql4W7C7FcI4Rlx5/uMN9wY1wro8TWUBMwT6jjSrUWIvK3GXoojd5bHvJx07XpjWl9wCon4D0ruZiFoM2mdeP23lbc2GckETi32oEKswnQXxkMACmxbPzoWbvkxH4aK8Bt2Rj2sl2TbPhVkN6DAkHGkGAvLI+2/aRfG27+oo3OKsaDjbuGABct8TfZccJ970CbQ8kbnCjYxstvqkg1JWjF0W67sX/flBZZOEUA5l0OLWo6HqMGMxm7/lEQhIdPMsRmvXL+HVOxkMrB2dda58QzxVwiZp+rRqUaeabPZp8Kl5xodGrVxsBvxe6zAbJ5jCtCSumG6+kLyKI00/kYlghqQNrgUw0ZsYJlQ34h3lo/24QpaeyDpQoCkGWQgtgqiXGpeKSu7bCnOqIqAy3nbT9Utwj7K8gIasTG5idosEAz/THMampNbGDuyxxc340sYGNMg9Bhm1g2ILWRdtV470p5hwBtIDTKi3/PAizEO26+Wh0zI47Sg3ao57avcbCsTmzbZUeA5J4bojmchhJCHX8su9cSCGh/2fJA/1eBIgEvOQ8LNE= + secure: w39XcbAP1N2Y8QVlv4NL24Az73A1wA2cHEdknoAR8ox7962OhgTY62qQKmF+VUcq4NK5wCcvbIvyAOGs4KplZZAU3+DWprI5/f49hO+7Cw9b/Y0LXMkfKlK1VW2tz+dIzcJUJ2B9CaVrJzCIuLuQVzoWvBBOIhkt2tQQHDP82bbfodiweEPjibAO64my+kzENRWiqQNCTSwbA20wwZGHVf4Jij7MhRbj29hU9OPcWEn7rEsaqI3BU5NVm3WEqt4DHo5ErXoY0Xzz0DwTy6JCbZG8ue+59QLrekg2XmNBw2VkIMUuDlpYfIyCe6POAqRJhBwcG84kzwp6/znXTKcc1sOZaeC4PwfAYqo/ZwSu8JlRPXIYicw0jhygrcXiHYQgyqobi7sETImB84y7l+IkxqA7welYbGCOjR0QOZf6MMU0d+tBGwDUnyUimye1WyOKSy2r7nQxr7ETsj+w27A88qEvbTez3+Bs7i+IOnNQ24MuSRPBpFoNTskeGPxQ5gFzbMymdjnNt9NzgZK+gpJlR/ESvZYKHMLAWz+br62Sxh5do3LIG/Y0HKaUMACcYmZ9hOQbSVNbBEwWOL8gp7BogDqEDWqQ0X6yckb+BDo7ZrBOOlq5r9F+nGoMl5j/e6SAOjtvCIKlzz9bdNqwutrWjXHdoWmT0lwyNQLhsB4G+V8= file_glob: true file: dist/phovea_data_mongo*.egg on: tags: true - -notifications: - slack: - secure: E8/1UIdHSczUbN+6i6gd1d5LM4vmLdwLQ30tpyjvnM0wvfDce76oPxLJAy240WJ5ybXRZUtNrttpVpt4tEXCy8aLFCmxD7s77rVloH+q1J8R/ptTFWZGhFGEujk1awEmVbzcWxJkV9/JENQaeGBKxwv8/EQwWwEkAb7p/+AJb9owmH88b3wUZUGHBWtbMiyyaF4Rm1Wg1stJB8Z1Ga7PRF4cqufTgcDdsCPVv9gAY+VxOIGqX/Vfuc9UWpUH8vq8lHUE7Inn5QS78kuFfSgLWga3H6Mu/Gko1XNlWk0QWWQBUvEZ6ZC6Wuo68KzvUjJHDTnx8WyfHue2JNHIslcX+eJq2WHLeEgM24VeNkILCGo/H/60NGHiSjrIv/Y9h6bQ9FDjo6TUyE4nbdPYN1RN9FQ5UbI9Y4Gi753H9mqnHWlEywBOzHxdZCAuz9Wh03CCF/blsvJ+Obbyo6Jrfe+g44jyi9kQdBNQ78qG6v4EXws8FiYao6x3PpgIwFix42Cpr+soAh5FpA3C1zHSAyZZpXF65/lrDl5yPNofK7Wy0B9bw+0I6Z/u7ZKFNVZXvYPGYvtUVcsALGBdmYc61+LCta36Po0KZseWVAlJj6QnOJDYzv0wvV/zsuf9A5KpYFGiqV9Q7zmtiO5FYF5sBy+lE7O9tHVO4O18IRndhRQgxhs= - on_success: change - on_failure: always + repo: phovea/phovea_data_mongo +- provider: pypi + user: caleydo-bot + password: + secure: e4v7ObSMoIejma3OSmJWvSKq74ejA2tnXgi4/3+rGwmVSe0S6LRkOT5bT/p4ZMYbnJFH4i83Y7RVtt61OA3EFxUiWxXg7MQ7FgvD4eHVbQeIiYbSbvkRImjz+kvlTT9+Jp6nq3/H5YoUKZ3uP+8Pk2XSX/vB7Aak60FNdi36TJRK4vfkeb3fVQ89OsJfMnHVJgHaphnAAMvodSBwOP+Y641QQTnVMcKxJwkIZUqXWHv7fl99ib0rDQ5AEJbvs+T1gLUaBANYe7OKkybkB496a4rnwUCKnZLVxAxhMSkf0lhGaA5F5iXXnnrHXFTTjMU/5NNdjiMfZKvT9IVJWw6cxA5euBY6OLedJiZUOhUSz0pK99hpsuiYrE2L+1gn6VIEUUEcJpkpYuDtfGqqbO2veOFrp6v/AxMKMpxGs5mXZl4dmOMmG4iGJnYu3CSX3iH/heAS3NgFCnI9CxfrhSXnXTdyUv1Gx5klhs7eysdcnE2tguZ+3/acrB9uVXQfs1iMNFc4130/Apkomk/TmlXQiYGWmMUqFnmGFzFA67XPx3G84SgelV/+5GeLQKln8+5SSNeLxDF9ya1JnfDnmRo7cTD1e4c60TeCI0Itv2+nrMtG9Cq4J1emeM8CsGG/TteydwHtQUEyBug+8mvFFuq0AFenY4OJiba8RAwgF3ik2Ok= + on: + tags: true + distributions: sdist bdist_wheel + repo: phovea/phovea_data_mongo From e536e937f5da532ca4bff6652dbb0024075108f9 Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Wed, 5 Apr 2017 14:32:07 +0200 Subject: [PATCH 16/17] yo phovea:update --- package.json | 2 +- setup.cfg | 3 +++ setup.py | 16 ++++++++++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 2b045e1..68064e8 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "pretest": "npm run check", "test": "test ! -d tests || python setup.py test", "predist": "npm run build && npm run docs", - "dist": "python setup.py bdist_egg", + "dist": "python setup.py bdist_egg && cd build && tar cvzf ../dist/phovea_data_mongo.tar.gz *", "docs": "sphinx-apidoc -o docs -f ./phovea_data_mongo && sphinx-build ./docs build/docs", "prebuild": "node -e \"process.exit(process.env.PHOVEA_SKIP_TESTS === undefined?1:0)\" || npm run test", "build": "python build.py" diff --git a/setup.cfg b/setup.cfg index 5519f85..119a4a3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -12,3 +12,6 @@ universal=1 [aliases] test=pytest + +[metadata] +description-file = README.md diff --git a/setup.py b/setup.py index 84fb9e0..18e10f0 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ # Licensed under the new BSD license, available at http://caleydo.org/license ############################################################################### from __future__ import with_statement, print_function -from setuptools import setup +from setuptools import setup, find_packages from codecs import open from os import path @@ -30,15 +30,19 @@ def packaged(*files): return r +def requirements(file): + return [r.strip().encode('ascii') for r in read_it(file).strip().split('\n') if not r.startswith('-e git+https://')] + + def to_version(v): import datetime now = datetime.datetime.utcnow() return v.replace('SNAPSHOT', now.strftime('%Y%m%d-%H%M%S')) - setup( name=pkg['name'], version=to_version(pkg['version']), + url=pkg['homepage'], description=pkg['description'], long_description=read_it('README.md'), keywords=pkg.get('keywords', ''), @@ -57,7 +61,7 @@ def to_version(v): 'Intended Audience :: Developers', 'Operating System :: OS Independent', # Pick your license as you wish (should match "license" above) - 'License :: OSI Approved :: ' + pkg['license'], + 'License :: OSI Approved :: ' + ('BSD License' if pkg['license'] == 'BSD-3-Clause' else pkg['license']), 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4' @@ -65,14 +69,14 @@ def to_version(v): # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=[pkg['name']], + packages=find_packages(exclude=['docs', 'tests*']), # List run-time dependencies here. These will be installed by pip when # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=[r for r in read_it('requirements.txt').split('\n') if not r.startswith('-e git+https://')], - tests_require=read_it('requirements_dev.txt').split('\n'), + install_requires=requirements('requirements.txt'), + tests_require=requirements('requirements_dev.txt'), # If there are data files included in your packages that need to be # installed, specify them here. If using Python 2.6 or less, then these From d665097808ec7685950a9ebaa338e31a38cf969d Mon Sep 17 00:00:00 2001 From: Samuel Gratzl Date: Wed, 5 Apr 2017 14:51:49 +0200 Subject: [PATCH 17/17] prepare release_0.1.0 --- package.json | 2 +- requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 68064e8..ebcae80 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "phovea_data_mongo", "description": "Data provider plugin for loading graph data stored in a MongoDB.", "homepage": "https://phovea.caleydo.org", - "version": "0.1.0-SNAPSHOT", + "version": "0.1.0", "author": { "name": "The Caleydo Team", "email": "contact@caleydo.org", diff --git a/requirements.txt b/requirements.txt index cdccb89..9ff8778 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ --e git+https://github.com/phovea/phovea_server.git@develop#egg=phovea_server -pymongo==3.0.3 \ No newline at end of file +pymongo==3.0.3 +phovea_server==0.1.0 \ No newline at end of file