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

Remove duplicate worker code #19

Merged
merged 17 commits into from Aug 6, 2018
Merged

Remove duplicate worker code #19

merged 17 commits into from Aug 6, 2018

Conversation

@c-w
Copy link
Contributor

@c-w c-w commented Aug 6, 2018

See #9

@@ -91,7 +95,8 @@ def _get_img_ids_and_features(self):
known_features.append(current_features)
return img_ids, np.array(known_features)

def _prepare_matches(self, matches, that_img_id, distance_score):
@classmethod
Copy link
Collaborator

@michaelperel michaelperel Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be @staticmethod, as it does not seem that cls is used?

Loading

def _delete_img(self, img_id):
self.logger.debug('deleting img')
for extension in self.allowed_file_extensions:
img_name = "{}.{}".format(img_id, extension)
fpath = os.path.join(self.img_dir, img_name)
try:
os.remove(fpath)
self.logger.debug("removed {}".format(img_id))
except:
self.logger.debug("removed %s", img_id)
Copy link
Collaborator

@michaelperel michaelperel Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it preferable to use printf style strings over newer format strings? (should we consider using python 3.6, perhaps and using f'{}' instead?)

Loading

Copy link
Contributor Author

@c-w c-w Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using %s here is by design since this is a logger call. If you do self.logger.debug('removed {}'.format(img_id)), the format string will always be allocated even if the log level is higher than debug. With self.logger.debug('removed %s', img_id), the logging framework will only format the string if it's actually going to be printed.

Loading

@@ -1,3 +1,5 @@
# pylint: disable=too-few-public-methods
Copy link
Collaborator

@michaelperel michaelperel Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we specify the inline pylint instructions into a pylintrc or are they specific to these few cases?

Loading

Copy link
Contributor Author

@c-w c-w Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just a few cases (some of which I'll also refactor). In general you want .pylintrc to be as empty as possible so that you get the full linting goodness.

Loading

@c-w c-w merged commit 06dec57 into master Aug 6, 2018
@c-w c-w deleted the remove-duplicate-code branch Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants