-
Notifications
You must be signed in to change notification settings - Fork 76
[SVCS-159] Add renderer/exporter names to cached files #296
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
[SVCS-159] Add renderer/exporter names to cached files #296
Conversation
cslzchen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed in person. One typo and something I forgot. Back to you now while I am testing locally with cache enabled.
mfr/core/utils.py
Outdated
|
|
||
| # ep.attrs is a tuple of attributes. There should only ever be one or `None`. | ||
| # None case occurs when trying to render an unsupported file type | ||
| # entry_attrs is an itrable object, so we turn into a list to index it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo "iterable"
| :rtype : `str` | ||
| """ | ||
|
|
||
| # `make_renderer` should have already caught if an extension doesn't exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mfr/server/handlers/export.py
Outdated
| self.output_file_id = '{}.{}'.format(self.source_file_path.name, self.format) | ||
| self.output_file_path = await self.local_cache_provider.validate_path( | ||
| '/export/{}'.format(self.output_file_id) | ||
| '/export/{}.{}'.format(self.output_file_id, self.exporter_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember we did want to change something here during discussion but I forget the detail. My bad ... :-(.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i remember, 👍
|
Really like the comments and doc str, very helpful 🎆 🎆 |
cslzchen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and move to PCR 🎆 🎆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more testing, I will comment later.list(entry_attrs)[0].attrs[0] never worked. Anything that needs exporting will fail. @felliott
|
|
||
| # ep.attrs is a tuple of attributes. There should only ever be one or `None`. | ||
| # For our case however there shouldn't be `None` | ||
| return list(entry_attrs)[0].attrs[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list(entry_attrs)[0].attrs[0] always fails with index error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code works. However, entry_attrs is an iterator but is accessed in an array way. The first call to list(entry_attrs) moves the iteration forward, thus further access will fail with index error. This will be updated in #320.
Ticket
https://openscience.atlassian.net/browse/SVCS-159
Purpose
Add renderer name to cached files
Add exporter name to cached files
Changes
Added renderer to cached renderer files
Added exporter name to cached exported files
Added tests for changes
Side effects
Should be none
QA Notes
In order to test this locally, you need to turn MFR caching on: https://github.com/CenterForOpenScience/modular-file-renderer/blob/develop/mfr/server/settings.py#L28
Once this is on, in your logs you will see the caching messages, and it will show you the names of the cached files as well.
The tests do not directly test this change in action, instead it tests to make sure that the added
get_exporter_nameandget_renderer_namereturn the proper values.Deployment Notes
Some things to note: While renderer/exporter names have been added to cached files, this isn't always indicative of which files should be cleared when changes are made to a specific renderer.
For instance a cached .docx file will have
.UnoconvRendererat the end of it, but it is rendered by both the.UnoconvRendererand thePdfRenderer.