Skip to content

Conversation

@felliott
Copy link
Member

Ticket

Not created yet

Purpose

Refuse to render tabular files if they exceed a certain size.

Changes

Add a configurable setting for tabular file size limits. If files is above this size, refuse to render it.

Side effects

QA Notes

Deployment Notes

 * Add more documentation for the `sheets` data structure.  Rename or
   create some derived variables to make code clearer.

 * Log the number of columns and rows when one or the other exceeds
   the maximum allowed number.
 * Tabular data has to be slurped into memory to be displayed, meaning
   large files can cause resource shortages or oom errors.  Throw an
   informative error if the user tries to render a file larger than
   `MAX_FILE_SIZE` bytes.

 * Fix order of imports, removed old commented-out code.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 72.305% when pulling 6e587e6 on felliott:feature/tabular-size-limit into 4cf6112 on CenterForOpenScience:develop.

@coveralls
Copy link

coveralls commented Mar 27, 2018

Coverage Status

Coverage decreased (-0.1%) to 72.305% when pulling b540713 on felliott:feature/tabular-size-limit into 4cf6112 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.

@felliott LGTM 🎆

Two minor and non-blocking issues:

  • Import order and style
  • Missing tests

I suggest we can make a ticket to do it after the release.

import os
import json
import logging
import os
Copy link
Contributor

@cslzchen cslzchen Mar 27, 2018

Choose a reason for hiding this comment

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

Fix import order which should be length based.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought for MFR we were doing alphabetical order, or am I misremembering that?


from mfr.core import extension
from mfr.extensions.tabular import settings
from mfr.extensions.tabular import exceptions
Copy link
Contributor

Choose a reason for hiding this comment

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

How about from mfr.extensions.tabular import settings, exceptions?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

from mfr.extensions.tabular import settings
from mfr.extensions.tabular import exceptions

logger = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

import logging
import os

from humanfriendly import format_size
Copy link
Contributor

@cslzchen cslzchen Mar 27, 2018

Choose a reason for hiding this comment

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

👍

A nice package that I was trying to find a while ago.

self.attr_stack.append([self.__TYPE, {'formatting_function': self.formatting_function}])


class FileTooLargeError(TabularRendererError):
Copy link
Contributor

@cslzchen cslzchen Mar 27, 2018

Choose a reason for hiding this comment

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

I remember you mentioned in WB but I am not sure about MFR: when an exception is added, should we update the tests somewhere to make sure that serialization works?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed for MFR. That test is to make sure the error survives the pickling/unpickling done by WB's celery worker.

@felliott felliott changed the title [SVCS-xxx] Add file size limit to tabular renderer. [SVCS-675] Add file size limit to tabular renderer. Mar 27, 2018
@felliott felliott closed this in 8c00faa Mar 28, 2018
@felliott felliott deleted the feature/tabular-size-limit branch March 28, 2018 13:49
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