-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDB.py
36 lines (31 loc) · 1.3 KB
/
createDB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pymongo import MongoClient, TEXT
import os
import datetime
#Start mongoDB client
client = MongoClient()
#Access database named 'test_database'
db = client.test_database
#Create runs collection
recipies = db.recipies
# Add text index (required for searching in all fields at the same time)
recipies.create_index([("$**", TEXT)], name="TextIndex", language="none")
#Create run objects to be stored in collection
authors = {"Janneke": "jvdzwaan", "Robin": "robintw", "Raquel": "raquel-ucl"}
for filename in os.listdir('.'):
for author in authors:
run = {"author": author,
"title": filename,
"filename": "path_to_image",
"inputs": ["path_to_input1", "path_to_input2", "path_to_input3"],
"outputs": ["path_to_output1"],
"script": "path_to_script",
"environment": ["python3.2", "PyMongo2.8", "MAC OS 10.10.02"],
"command": "script -f flag",
"gitrepo": ["git://otherhost.org/user/repo.git"],
"gituser": "raquel-ucl",
"gitrepo": "git://otherhost.org/user/repo.git",
"gitcommit": "c72a071351e5b48e70f2515dce309671c4103586",
"gituser": authors[author],
"date": datetime.datetime.utcnow()}
#Insert image metadata in DB
run_id = recipies.insert(run)