Skip to content

Conversation

@AddisonSchiller
Copy link
Contributor

@AddisonSchiller AddisonSchiller commented Nov 9, 2017

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_name and get_renderer_name return 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 .UnoconvRenderer at the end of it, but it is rendered by both the .UnoconvRenderer and the PdfRenderer.

@coveralls
Copy link

coveralls commented Nov 9, 2017

Coverage Status

Coverage increased (+0.1%) to 63.973% when pulling eb5fc9d on AddisonSchiller:feature/SVCS-159-add-renderer-to-cached-file-names into ee122ff on CenterForOpenScience:develop.

@cslzchen cslzchen requested review from binoculars and cslzchen and removed request for binoculars November 10, 2017 21:33
Copy link
Contributor

@cslzchen cslzchen left a 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.


# 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
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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)
Copy link
Contributor

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 ... :-(.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think i remember, 👍

@cslzchen
Copy link
Contributor

Really like the comments and doc str, very helpful 🎆 🎆

@coveralls
Copy link

coveralls commented Nov 16, 2017

Coverage Status

Coverage increased (+4.3%) to 68.118% when pulling cf41e5a on AddisonSchiller:feature/SVCS-159-add-renderer-to-cached-file-names into ee122ff on CenterForOpenScience:develop.

Copy link
Contributor

@cslzchen cslzchen left a 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 🎆 🎆

@felliott felliott closed this in c8ffa75 Mar 2, 2018
Copy link
Contributor

@cslzchen cslzchen left a 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] never worked. Anything that needs exporting will fail. @felliott Need more testing, I will comment later.


# 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]
Copy link
Contributor

@cslzchen cslzchen Mar 20, 2018

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.

Copy link
Contributor

@cslzchen cslzchen Mar 20, 2018

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.

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.

3 participants