Skip to content

Commit

Permalink
Merge 2431157 into eae8d00
Browse files Browse the repository at this point in the history
  • Loading branch information
teleyinex committed Dec 28, 2019
2 parents eae8d00 + 2431157 commit afabe0b
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: python
python:
- "2.7"
- "3.6"
install:
- pip install -r requirements.txt
- pip install -r requirements-testing.txt
Expand Down
11 changes: 6 additions & 5 deletions enki/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
"""
import pbclient
from task_loaders import create_tasks_loader
from task_run_loaders import create_task_runs_loader
import dataframer
from exceptions import ProjectNotFound, ProjectError, \
from .task_loaders import create_tasks_loader
from .task_run_loaders import create_task_runs_loader
from . import dataframer
from .exceptions import ProjectNotFound, ProjectError, \
ProjectWithoutTasks, ProjectWithoutTaskRuns
from functools import reduce


class Enki(object):
Expand Down Expand Up @@ -100,6 +101,6 @@ def _check_project_has_tasks(self):

def _check_project_has_taskruns(self):
count_task_runs = lambda total, task_runs: total + len(task_runs)
total_task_runs = reduce(count_task_runs, self.task_runs.values(), 0)
total_task_runs = reduce(count_task_runs, list(self.task_runs.values()), 0)
if total_task_runs == 0:
raise ProjectWithoutTaskRuns
4 changes: 2 additions & 2 deletions enki/dataframer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def create_data_frame(item):

def explode_info(item):
item_data = item.__dict__['data']
protected = item_data.keys()
protected = list(item_data.keys())
if type(item.info) == dict:
keys = item_data['info'].keys()
keys = list(item_data['info'].keys())
for k in keys:
if k in protected:
item_data["_" + k] = item_data['info'][k]
Expand Down
10 changes: 5 additions & 5 deletions enki/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, value):

def __str__(self):
"""String representation."""
print self.msg # pragma: no cover
print(self.msg) # pragma: no cover


class ProjectError(Error):
Expand All @@ -58,7 +58,7 @@ def __init__(self):

def __str__(self): # pragma: no cover
"""String representation."""
print self.msg
print(self.msg)


class ProjectWithoutTasks(Error):
Expand All @@ -71,7 +71,7 @@ def __init__(self):

def __str__(self):
"""String representation."""
print self.msg # pragma: no cover
print(self.msg) # pragma: no cover


class ProjectWithoutTaskRuns(Error):
Expand All @@ -84,7 +84,7 @@ def __init__(self):

def __str__(self):
"""String representation."""
print self.msg # pragma: no cover
print(self.msg) # pragma: no cover


class PyBossaServerNoKeysetPagination(Error):
Expand All @@ -98,4 +98,4 @@ def __init__(self):

def __str__(self):
"""String representation."""
print self.msg # pragma: no cover
print(self.msg) # pragma: no cover
4 changes: 2 additions & 2 deletions enki/task_run_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import json
import pbclient
from exceptions import Error, PyBossaServerNoKeysetPagination
from .exceptions import Error, PyBossaServerNoKeysetPagination

class ServerTaskRunsLoader(object):

Expand All @@ -30,7 +30,7 @@ def __init__(self, project_id, tasks, all=0):
def check_errors(self, data):
"""Check for errors on data payload."""

if (type(data) == dict and 'status' in data.keys()
if (type(data) == dict and 'status' in list(data.keys())
and data['status'] == 'failed'):
if data.get('exception_msg') and 'last_id' in data.get('exception_msg'):
raise PyBossaServerNoKeysetPagination
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pandas
pybossa-client>=2.0.1, <2.0.2
pybossa-client>=3.0.0, <3.0.1
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

setup(
name='enki',
version='1.1.2',
version='3.0.0',
packages=find_packages(),
install_requires=['pybossa-client>=2.0.1, <2.0.2', 'pandas'],
install_requires=['pybossa-client>=3.0.0, <3.1.0', 'pandas'],
# metadata for upload to PyPI
author='Scifabric LTD',
author_email='info@scifabric.com',
Expand Down
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ def create_error_output(self, action, status_code, target,
return error

def check_error_output(self, res, err):
for k in err.keys():
for k in list(err.keys()):
assert err[k] == res[k], err
16 changes: 8 additions & 8 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_explode_info_without_info_dict(self, Mock):
e.get_tasks()
result = e.explode_info(e.tasks[0])
err_msg = "This item should not be exploded"
assert result.keys() == self.task.keys(), err_msg
assert list(result.keys()) == list(self.task.keys()), err_msg

@patch('pbclient.requests.get')
def test_explode_info_without_info_dict_file(self, Mock):
Expand All @@ -78,7 +78,7 @@ def test_explode_info_without_info_dict_file(self, Mock):
e.get_tasks(json_file='tests/task_no_dict.json')
result = e.explode_info(e.tasks[0])
err_msg = "This item should not be exploded"
assert 'new_key' not in result.keys(), err_msg
assert 'new_key' not in list(result.keys()), err_msg

@patch('pbclient.requests.get')
def test_explode_info_with_info_dict(self, Mock):
Expand All @@ -91,9 +91,9 @@ def test_explode_info_with_info_dict(self, Mock):
e.get_tasks()
result = e.explode_info(e.tasks[0])
err_msg = "This item should be exploded"
assert 'key' in result.keys(), err_msg
assert 'key' in list(result.keys()), err_msg
err_msg = "This item should be escaped"
assert '_id' in result.keys(), err_msg
assert '_id' in list(result.keys()), err_msg

@patch('pbclient.requests.get')
def test_explode_info_with_info_dict_file(self, Mock):
Expand All @@ -104,9 +104,9 @@ def test_explode_info_with_info_dict_file(self, Mock):
e.get_tasks(json_file='tests/task.json')
result = e.explode_info(e.tasks[0])
err_msg = "This item should be exploded"
assert 'key' in result.keys(), err_msg
assert 'key' in list(result.keys()), err_msg
err_msg = "This item should be escaped"
assert '_id' in result.keys(), err_msg
assert '_id' in list(result.keys()), err_msg

@raises(ProjectError)
@patch('pbclient.requests.get')
Expand Down Expand Up @@ -319,12 +319,12 @@ def test_get_task_runs_when_some_tasks_have_no_taskruns(self, Mock):
Mock.side_effect = [self.create_fake_request([self.task, self.ongoing_task], 200),
self.create_fake_request([], 200)]
e.get_tasks()
print e.tasks
print(e.tasks)
Mock.side_effect = [self.create_fake_request([self.taskrun], 200),
self.create_fake_request([], 200),
self.create_fake_request([], 200)]
e.get_task_runs()

assert len(e.task_runs[self.task['id']]) is 1
print self.ongoing_task
print(self.ongoing_task)
assert e.task_runs[self.ongoing_task['id']] == []
2 changes: 1 addition & 1 deletion tests/test_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ def assert_all_tasks_belong_to_project(tasks, project_id):
assert task.project_id == project_id

def assert_task_runs_grouped_by_task(task_runs):
for task in task_runs.keys():
for task in list(task_runs.keys()):
for task_run in task_runs[task]:
assert task == task_run.task_id, task_runs

0 comments on commit afabe0b

Please sign in to comment.