Skip to content

add 'recreate_previews' process_addons task - #8553

Merged
eviljeff merged 4 commits into
mozilla:masterfrom
eviljeff:7908-devhub-larger-screenshots
Jun 19, 2018
Merged

eviljeff merged 4 commits into
mozilla:masterfrom
eviljeff:7908-devhub-larger-screenshots

Conversation

@eviljeff

Copy link
Copy Markdown
Member

@eviljeff
eviljeff requested a review from EnTeQuAk June 18, 2018 09:44

@EnTeQuAk EnTeQuAk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r+wc

Comment thread src/olympia/amo/models.py Outdated
% (filename, instance.pk))
storage.delete(filename)
if storage.exists(filename):
storage.delete(filename)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Django actually implies that check already and does os.path.exists itself in storage.delete

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread src/olympia/amo/tests/test_models.py Outdated
preview = self.get_object()
assert 'png' in preview.thumbnail_path
assert 'png' in preview.image_path
assert 'png' in preview.original_path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick, can we change these tests to assert preview.thumbnail_path.endswith('.png') to be a bit more failure-proof and make sure we actually have that as an ext of the filename.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

d002da8 but I went too far and had to fix with a37b5c6

'full': _size_tuple(700, 525)
'thumb': _size_tuple(320, 200),
'full': _size_tuple(1280, 800)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add a comment where these sizes come from? An issue or a link to the frontend?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread src/olympia/devhub/tasks.py Outdated

@task
def recreate_previews(addon_pk, **kw):
log.info('[1@None] Recreating previews for addon: %s' % addon_pk)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is this [1@None] prefix for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

tbh, no idea. I lazily copied the log.info from the resize_preview method above.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

d002da8 and it reminded me why that format may be used for test logging and that it wouldn't have worked as a command so 8827524 refactored things.

Comment thread src/olympia/devhub/tasks.py Outdated
# We have an original size image, so we can resize that.
src = preview.original_path
(preview.sizes['image'], _) = resize_image(
src, preview.image_path, amo.ADDON_PREVIEW_SIZES['full'])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note that we discussed this during the all hands: Make sure that we issue a blog post for developers to update/re-upload their screenshots if possible.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

#7908 is part of #7907 and that issue mentions Product will communicate changes.

Comment thread src/olympia/devhub/tasks.py Outdated
# use it for a new thumbnail
src = preview.image_path
# But we should resize the thumbnail regardless.
(preview.sizes['thumbnail'], _) = resize_image(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's actually no need to wrap this in parenthesis.

Comment thread src/olympia/devhub/tasks.py Outdated
src, preview.thumbnail_path, amo.ADDON_PREVIEW_SIZES['thumb'])
preview.save()
except Exception as e:
log.error("Error saving preview: %s" % e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either use log.exception or set exc_info=True so that we get the proper stack-trace of what happened. Also, this is very generic, I'd rather have a list of things that we know can go wrong and report everything else directly to sentry.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd imagine exceptions would fall into the rough buckets of "full size preview doesn't exist" and "full/original size preview is an invalid image somehow" but I'm not sure what we'd do with that information other than shrug and log. I suppose we could/should delete the Preview instance if that's happening?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

changed to log.exception in d002da8 but didn't delete the Preview instance.

@eviljeff
eviljeff merged commit 1a96a4b into mozilla:master Jun 19, 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

Development

Successfully merging this pull request may close these issues.

Allow uploading larger screenshots on devhub

2 participants