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

JSON import bugfix & speedup #155

Merged
merged 1 commit into from
Jan 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ tqdm==4.40.2
urllib3==1.25.7
wasabi==0.4.2
Werkzeug==0.16.0
orjson==2.1.3
6 changes: 5 additions & 1 deletion backend/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io
import os
import json
import orjson
import urllib
import logging
import random
Expand Down Expand Up @@ -81,15 +82,18 @@ def push_task(root):
task_id = len(tasks) + 1
if 'data' in root:
data = root['data']
else:
data = root
tasks[task_id] = {'id': task_id, 'task_path': path, 'data': data}
if 'predictions' in data:
tasks[task_id]['predictions'] = data['predictions']
tasks[task_id]['data'].pop('predictions', None)
if 'predictions' in root:
tasks[task_id]['predictions'] = root['predictions']

logger.debug(f'Reading tasks from JSON file {path}')
with open(path) as f:
json_body = json.load(f)
json_body = orjson.loads(f.read())

# multiple tasks in file
if isinstance(json_body, list):
Expand Down
5 changes: 5 additions & 0 deletions backend/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ def generator():
help='output directory for completions')
parser.add_argument('-p', '--port', dest='port', default=8200, type=int,
help='backend port')
parser.add_argument('-v', '--verbose', action='store_true',
help='increase output verbosity')

args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG)

print('Working dir', os.getcwd())
config_path = args.config_path
Expand Down