Skip to content

Commit

Permalink
[Lint] Fix the rest of the Python lint manually
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeyeager committed Oct 28, 2016
1 parent 2701998 commit 4254922
Show file tree
Hide file tree
Showing 94 changed files with 982 additions and 863 deletions.
2 changes: 2 additions & 0 deletions digits/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .version import __version__

__all__ = ['__version__']
30 changes: 17 additions & 13 deletions digits/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@

def main():
parser = argparse.ArgumentParser(description='DIGITS server')
parser.add_argument('-p', '--port',
type=int,
default=5000,
help='Port to run app on (default 5000)'
)
parser.add_argument('-d', '--debug',
action='store_true',
help='Run the application in debug mode (reloads when the source changes and gives more detailed error messages)'
)
parser.add_argument('--version',
action='store_true',
help='Print the version number and exit'
)
parser.add_argument(
'-p', '--port',
type=int,
default=5000,
help='Port to run app on (default 5000)'
)
parser.add_argument(
'-d', '--debug',
action='store_true',
help=('Run the application in debug mode (reloads when the source '
'changes and gives more detailed error messages)')
)
parser.add_argument(
'--version',
action='store_true',
help='Print the version number and exit'
)

args = vars(parser.parse_args())

Expand Down
16 changes: 9 additions & 7 deletions digits/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# Create this object before importing the following imports, since they edit the list
option_list = {}

from . import caffe
from . import gpu_list
from . import jobs_dir
from . import log_file
from . import torch
from . import server_name
from . import store_option
from . import ( # noqa
caffe,
gpu_list,
jobs_dir,
log_file,
torch,
server_name,
store_option,
)


def config_value(option):
Expand Down
6 changes: 2 additions & 4 deletions digits/config/caffe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from . import option_list
from digits import device_query
from digits.utils import parse_version
from digits.utils.errors import UnsupportedPlatformError


def load_from_envvar(envvar):
Expand Down Expand Up @@ -93,7 +92,7 @@ def is_pycaffe_in_dir(dirname=None):
sys.path = [dirname] # temporarily replace sys.path
try:
imp.find_module('caffe')
except ImportError as e:
except ImportError:
return False
finally:
sys.path = old_path
Expand All @@ -118,7 +117,7 @@ def import_pycaffe(dirname=None):

# for Windows environment, loading h5py before caffe solves the issue mentioned in
# https://github.com/NVIDIA/DIGITS/issues/47#issuecomment-206292824
import h5py
import h5py # noqa
try:
import caffe
except ImportError:
Expand Down Expand Up @@ -167,7 +166,6 @@ def get_version_and_flavor(executable):


def get_version_from_pycaffe():
import caffe
try:
from caffe import __version__ as version
return version
Expand Down
4 changes: 2 additions & 2 deletions digits/config/log_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import logging
import os
import sys

from . import option_list
import digits
Expand Down Expand Up @@ -61,7 +60,8 @@ def load_logfile_level():
return logging.CRITICAL
else:
raise ValueError(
'Invalid value "%s" for logfile_level. Set DIGITS_LOGFILE_LEVEL to fix your configuration.' % level)
'Invalid value "%s" for logfile_level. '
'Set DIGITS_LOGFILE_LEVEL to fix your configuration.' % level)
else:
return logging.INFO

Expand Down
11 changes: 9 additions & 2 deletions digits/dataset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
from __future__ import absolute_import

from .images import *
from .generic import *
from .images import ImageClassificationDatasetJob, GenericImageDatasetJob
from .generic import GenericDatasetJob
from .job import DatasetJob

__all__ = [
'ImageClassificationDatasetJob',
'GenericImageDatasetJob',
'GenericDatasetJob',
'DatasetJob',
]
2 changes: 2 additions & 0 deletions digits/dataset/generic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .job import GenericDatasetJob

__all__ = ['GenericDatasetJob']
1 change: 1 addition & 0 deletions digits/dataset/generic/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class GenericViewsTest(BaseViewsTest):

def test_page_dataset_new(self):
rv = self.app.get('/datasets/generic/new/%s' % self.EXTENSION_ID)
print rv.data
assert rv.status_code == 200, 'page load failed with %s' % rv.status_code
assert extensions.data.get_extension(self.EXTENSION_ID).get_title() in rv.data, 'unexpected page format'

Expand Down
6 changes: 4 additions & 2 deletions digits/dataset/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def explore():
# Get LMDB
db = job.path(flask.request.args.get('db'))
db_path = job.path(db)
labels = []

if COLOR_PALETTE_ATTRIBUTE in job.extension_userdata \
and job.extension_userdata[COLOR_PALETTE_ATTRIBUTE]:
Expand Down Expand Up @@ -194,7 +193,10 @@ def explore():
if len(imgs) >= size:
break

return flask.render_template('datasets/images/explore.html', page=page, size=size, job=job, imgs=imgs, labels=None, pages=pages, label=None, total_entries=total_entries, db=db)
return flask.render_template(
'datasets/images/explore.html',
page=page, size=size, job=job, imgs=imgs, labels=None,
pages=pages, label=None, total_entries=total_entries, db=db)


def show(job, related_jobs=None):
Expand Down
6 changes: 4 additions & 2 deletions digits/dataset/images/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
from __future__ import absolute_import

from .classification import *
from .generic import *
from .classification import * # noqa
from .generic import * # noqa
from .job import ImageDatasetJob

__all__ = ['ImageDatasetJob']
2 changes: 2 additions & 0 deletions digits/dataset/images/classification/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from __future__ import absolute_import

from .job import ImageClassificationDatasetJob

__all__ = ['ImageClassificationDatasetJob']
Loading

0 comments on commit 4254922

Please sign in to comment.