bootstrap during start
This commit is contained in:
parent
e593c3c38c
commit
15e1c5223b
@ -12,11 +12,3 @@ cd binder
|
||||
yes | m $(cat VERSION)
|
||||
|
||||
m
|
||||
|
||||
./init
|
||||
|
||||
python ./bootstrap.py
|
||||
|
||||
mlaunch kill
|
||||
|
||||
rm -rf ./data
|
||||
17
binder/start
17
binder/start
@ -4,9 +4,11 @@ import shutil
|
||||
import os
|
||||
import shlex
|
||||
import subprocess
|
||||
from pymongo import MongoClient
|
||||
|
||||
HERE = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
# Get config variables
|
||||
with open(os.path.join(HERE, 'VERSION')) as fid:
|
||||
VERSION = fid.read().strip()
|
||||
|
||||
@ -23,6 +25,21 @@ MONGODB_BIN, '--port', PORT, '--hostname', 'localhost', '--setParameter',
|
||||
print(cmd)
|
||||
subprocess.check_call(cmd, cwd=HERE)
|
||||
|
||||
# Bootstrap some data
|
||||
client = MongoClient(directConnection=True))
|
||||
|
||||
for path in glob.glob(os.path.join(HERE, 'sample_data', '*.json')):
|
||||
with open(path) as fid:
|
||||
entries = [json.loads(line) for line in fid]
|
||||
for entry in entries:
|
||||
del entry['_id']
|
||||
|
||||
name, _ = os.path.splitext(os.path.basename(path))
|
||||
print(name, len(entries))
|
||||
|
||||
collection = client.sample_mflix[name]
|
||||
collection.insert_many(entries)
|
||||
|
||||
# Launch Jupyter
|
||||
argv = sys.argv[1:]
|
||||
print(argv)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user