Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Fix python lint under plugins/ #1198

Merged
merged 1 commit into from
Oct 21, 2016
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
5 changes: 4 additions & 1 deletion digits-lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.

set -e
set -x

echo "Checking for lint ..."

if which flake8 >/dev/null 2>&1; then
python2 `which flake8` .
else
python2 -m flake8 .
fi

echo "No lint found."
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .data import DataIngestion

__all__ = [DataIngestion]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
TEMPLATE = "templates/template.html"
INFERENCE_TEMPLATE = "templates/inference_template.html"


@subclass
class DataIngestion(DataIngestionInterface):
"""
Expand Down
5 changes: 3 additions & 2 deletions plugins/data/imageGradients/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def read(fname):
packages=find_packages(),
entry_points={
DIGITS_PLUGIN_GROUP: [
'class=digitsDataPluginImageGradients:DataIngestion',
]},
'class=digitsDataPluginImageGradients:DataIngestion',
]
},
include_package_data=True,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .data import DataIngestion

__all__ = [DataIngestion]
14 changes: 8 additions & 6 deletions plugins/data/sunnybrook/digitsDataPluginSunnybrook/data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
from __future__ import absolute_import

import csv
import cv2
import fnmatch
import math
Expand Down Expand Up @@ -47,8 +46,10 @@
# Utility functions
#


def shrink_case(case):
toks = case.split("-")

def shrink_if_number(x):
try:
cvt = int(x)
Expand All @@ -73,9 +74,11 @@ def __str__(self):

def get_all_contours(contour_path):
# walk the directory structure for all the contour files
contours = [os.path.join(dirpath, f)
contours = [
os.path.join(dirpath, f)
for dirpath, dirnames, files in os.walk(contour_path)
for f in fnmatch.filter(files, 'IM-0001-*-icontour-manual.txt')]
for f in fnmatch.filter(files, 'IM-0001-*-icontour-manual.txt')
]
extracted = map(Contour, contours)
return extracted

Expand All @@ -94,6 +97,7 @@ def load_contour(contour, img_path):
# Main class
#


@subclass
class DataIngestion(DataIngestionInterface):
"""
Expand Down Expand Up @@ -123,16 +127,14 @@ def __init__(self, is_inference_db=False, **kwargs):
palette = [0, 0, 0, 255, 255, 255] + [0] * (254 * 3)
self.userdata[COLOR_PALETTE_ATTRIBUTE] = palette


@override
def encode_entry(self, entry):
img, label = load_contour(entry, self.image_folder)

if self.userdata['channel_conversion'] == 'L':
feature = img[np.newaxis, ...]
elif self.userdata['channel_conversion'] == 'RGB':
feature = np.empty(shape=(3, img.shape[0], img.shape[1]),
dtype=img.dtype)
feature = np.empty(shape=(3, img.shape[0], img.shape[1]), dtype=img.dtype)
# just copy the same data over the three color channels
feature[0] = img
feature[1] = img
Expand Down
4 changes: 1 addition & 3 deletions plugins/data/sunnybrook/digitsDataPluginSunnybrook/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from digits import utils
from digits.utils import subclass
from flask.ext.wtf import Form
import wtforms
from wtforms import HiddenField, validators
from wtforms import validators


@subclass
Expand Down Expand Up @@ -98,4 +97,3 @@ def validate_file_path(form, field):
default='none',
tooltip="Test a record from the validation set."
)

5 changes: 3 additions & 2 deletions plugins/data/sunnybrook/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def read(fname):
packages=find_packages(),
entry_points={
DIGITS_PLUGIN_GROUP: [
'class=digitsDataPluginSunnybrook:DataIngestion',
]},
'class=digitsDataPluginSunnybrook:DataIngestion',
]
},
include_package_data=True,
install_requires=['pydicom'],
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .view import Visualization

__all__ = [Visualization]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import wtforms
from wtforms import validators


@subclass
class ConfigForm(Form):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def process_data(self, input_id, input_data, output_data):
# assume only one output and grayscale input

output_vector = output_data[output_data.keys()[0]]
grad = np.array(
[output_vector[0] * self.width,
grad = np.array([
output_vector[0] * self.width,
output_vector[1] * self.height])
grad_rotated_90 = np.array([-grad[1], grad[0]])
center = np.array([self.width / 2, self.height / 2])
Expand Down
5 changes: 3 additions & 2 deletions plugins/view/imageGradients/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def read(fname):
packages=find_packages(),
entry_points={
DIGITS_PLUGIN_GROUP: [
'class=digitsViewPluginImageGradients:Visualization',
]},
'class=digitsViewPluginImageGradients:Visualization',
]
},
include_package_data=True,
)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 120
exclude = venv/,digits/,plugins/
exclude = venv/,digits/