Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gridfs #26

Open
wants to merge 58 commits into
base: deploy_on_server
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ac9968f
Before branching
stur86 Feb 2, 2018
653946f
Merge branch 'use_gridfs' of gitlab.com:stur86/ccpnc-database into us…
stur86 Feb 2, 2018
db66074
Fixed bug when loading config.json
stur86 Feb 2, 2018
2b9cdbc
Encapsulated config variables
stur86 Feb 2, 2018
31e9399
Added edit button to record template
stur86 Feb 2, 2018
ab55825
Changed ignore path for config.json
Mar 5, 2018
edc79eb
Added editForm directive skeleton
Mar 5, 2018
3f0a42a
Renamed record.js everywhere
Mar 5, 2018
a74f077
Directives for edit form start working
Mar 5, 2018
57f2493
Developed a link between databaseRecord and editForm directives
Mar 6, 2018
9bf92fa
Separated record and edit form directives in two different files
Mar 6, 2018
13ea25a
Added a link_config script to make it easier to change global configu…
stur86 Mar 7, 2018
9a8e0c7
Fixed bug in link_config file due to lack of absolute paths when linking
stur86 Mar 7, 2018
e550891
Fixed other bug in link_config
stur86 Mar 7, 2018
41c1ada
Developing Edit function for Upload
stur86 Mar 7, 2018
bdcde98
Completed new upload form
stur86 Mar 7, 2018
5352f1c
Split popup and form for editing
stur86 Mar 7, 2018
2366b26
Reused a bit of code loading DB collections
stur86 Mar 7, 2018
6bf7bf6
Added uploading files to edit popup
stur86 Mar 7, 2018
88bafdb
Added editMagresFile method to db_interface
stur86 Mar 7, 2018
7ffc1a0
Implemented method to push for edit client-side
Mar 8, 2018
6b008c8
Added edit interface server-side
Mar 8, 2018
0afd4d7
Added check for user when editing
Mar 8, 2018
13219d1
Added error message box to editPopup
Mar 8, 2018
efb295a
Fixed bug checking obligatory info when uploading
Mar 19, 2018
d3062ef
Fixed a problem with download link for files
Mar 19, 2018
217939c
More meaningful content in the front page
Apr 16, 2018
33af9a9
Fixed issue where Edit button showed also for non-owned files
stur86 May 4, 2018
5a0c206
Meaningful names for downloaded magres files
stur86 May 4, 2018
a07fb81
Fixed lack of refresh after Edit
stur86 May 4, 2018
dd5b1d6
Fixed an issue with edit tables not working properly with multiple pr…
stur86 Aug 21, 2018
24b072f
Removed hackish solution to reading magres strings
stur86 Aug 21, 2018
92e6d73
Updated Bulma to 0.7.1
stur86 Aug 22, 2018
59c61ca
archive upload function added
albapa Aug 22, 2018
a293b64
Edited Upload tab to accommodate archive upload
stur86 Aug 22, 2018
1506de9
Moving optionals definition serverside
stur86 Aug 22, 2018
1155fd8
Completed transition to server-side schema for edit form, added info.…
stur86 Aug 22, 2018
f945392
Added chemname and form to CSV file generation
stur86 Aug 23, 2018
3158154
Client side support for archive uploading
stur86 Aug 23, 2018
15e0b16
Restructuring test directory
stur86 Aug 23, 2018
b06183e
Added Python testing
stur86 Aug 23, 2018
741abee
Added FakeOrcidConnection for testing
stur86 Aug 23, 2018
7f55a6f
Added some testing for tokens
stur86 Aug 23, 2018
b7838c1
Added support for mongodb in testing
stur86 Aug 23, 2018
bbd88d6
Added testing for uploading and searching
stur86 Aug 23, 2018
8fb765f
Standardized interface for adding Magres and Archive
stur86 Aug 24, 2018
80aeb6f
Completed testing of addMagresArchive
stur86 Aug 24, 2018
9394fe5
Completed archive uploading server-side
stur86 Aug 24, 2018
7601d97
Made Python test path-independent
stur86 Aug 24, 2018
d23aab8
Moving to a form-based upload; client side
Sep 3, 2018
e8e0016
Fixed some style issues, added spinner to upload
Sep 3, 2018
5a65fd6
Moving to a form file posting - server side (addMagres methods)
Sep 3, 2018
248591e
Added type flexibility to addMagresFile - works now with both files a…
stur86 Sep 4, 2018
d7edd6e
Adapted tests for file upload
stur86 Sep 4, 2018
7971209
Adapted editMagres (serverside)
stur86 Sep 4, 2018
6c0729a
Adapted edit too to work with forms (client-side)
stur86 Sep 4, 2018
78834bd
converts * and ? to regex, ignores case
albapa Sep 5, 2018
99cd2cb
Added Cookie Policy page; updated FontAwesome
Oct 10, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ secret/secret.key
secret/orcid_details.json
*.pyc
.ipynb_checkpoints
config.json
config/config.json
static/js/config.js
128 changes: 98 additions & 30 deletions CheckDatabase.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -20,39 +20,61 @@
"\n",
"import json\n",
"import re\n",
"from bson import json_util\n",
"from datetime import datetime\n",
"from gridfs import GridFS, NoFile\n",
"from flask import Flask\n",
"from flask_cors import CORS, cross_origin\n",
"from pymongo import MongoClient\n",
"from bson.objectid import ObjectId\n",
"from db_interface import addMagresFile, databaseSearch, removeMagresFiles"
"from db_interface import addMagresFile, databaseSearch, removeMagresFiles, editMagresFile\n",
"from db_schema import magresVersionSchema"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['notes', 'doi', 'csd-ref']"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"opt_re = re.compile('Optional\\(\\'([a-zA-Z\\-]+)\\'\\)')\n",
"[opt_re.match(str(k)).groups()[0] for k in magresVersionSchema._schema.keys() if opt_re.match(str(k)) != None]"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [],
"source": [
"# MAGRES database\n",
"client = MongoClient(host='wigner.esc.rl.ac.uk')\n",
"host = 'wigner.esc.rl.ac.uk'\n",
"#host = 'www.ccpnc.ac.uk'\n",
"\n",
"client = MongoClient(host=host, port=27017)\n",
"ccpnc = client.ccpnc"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'\"2018-01-31 15:02:43.662361\"'"
"'\"2018-04-24 11:35:16.527528\"'"
]
},
"execution_count": 22,
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -63,57 +85,101 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
"for f in ccpnc.test.find({'x': 5}):\n",
" print f"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"magresMdata = ccpnc.magresMetadata"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"execution_count": 42,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
"source": [
"magresIndex = ccpnc.magresIndex"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "'NoneType' object has no attribute '__getitem__'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-43-e6d2291f596f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mmagresIndex\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfind_one\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m'chemname'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m'TestDOI'\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'_id'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m: 'NoneType' object has no attribute '__getitem__'"
]
}
],
"source": [
"magresIndex.find_one({'chemname': 'TestDOI'})['_id']"
]
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{u'chemname': u'TestOne', u'metadataID': u'5a71e1290c81be3fcf3ac176', u'latest_version': {u'date': datetime.datetime(2018, 1, 31, 15, 30, 49, 989000), u'doi': u'10.0001', u'magresFilesID': u'5a71e12a0c81be3fcf3ac177'}, u'values': [{u'iso': [29.559937639131203, 30.22618664854139, 30.072254456072027, 26.953990818833876, 27.373946759128433, 31.888119371185127], u'species': u'H'}, {u'iso': [156.1229153499832, 109.35753044488325], u'species': u'C'}, {u'iso': [267.0122765992025], u'species': u'O'}], u'orcid': {u'path': u'0000-0003-4851-1144', u'host': u'orcid.org', u'uri': u'http://orcid.org/0000-0003-4851-1144'}, u'formula': [{u'species': u'C', u'n': 2}, {u'species': u'H', u'n': 6}, {u'species': u'O', u'n': 1}], u'_id': ObjectId('5a71e12a0c81be3fcf3ac179')}\n"
"5a71e12a0c81be3fcf3ac179\n",
"TestOne\n",
"5a71e1530c81be3fcf3ac17f\n",
"TestTwo\n",
"5a746e080c81be236bff2994\n",
"TestThree\n",
"5aa13de33207861d13ab2ac4\n",
"TestFour\n"
]
}
],
"source": [
"reg = re.compile('estOne')\n",
"for f in ccpnc.magresIndex.find({'chemname': {'$regex': reg}}):\n",
" print f"
"for f in magresIndex.find({}):\n",
" print f['_id']\n",
" print magresMdata.find({'_id': ObjectId(f['metadataID'])}).next()['chemname']"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<pymongo.results.InsertOneResult at 0x7f3e7d3920a0>"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"TestOne\n",
"TestDOI\n"
]
}
],
"source": [
"magresMdata.insert_one({'thing': 'date', 'date': datetime.now()})"
"reg = re.compile('Test')\n",
"for f in ccpnc.magresIndex.find({'$and': [{'chemname': {'$regex': reg}}]}):\n",
" print f['chemname']"
]
},
{
Expand All @@ -138,7 +204,9 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"magresFilesFS = GridFS(ccpnc, 'magresFilesFS')"
Expand Down
1 change: 1 addition & 0 deletions config/config.ultron.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pythonpath": [], "db_url": "localhost", "db_port": 27017}
Loading