mito icon indicating copy to clipboard operation
mito copied to clipboard

Allow Python Snippets in Cells

Open aarondr77 opened this issue 2 years ago • 2 comments

As doing some analysis, I wanted to count the number of items in a list, each cell containing one list. This would've been straight forward to do in Python, but not possible in Mito.

Ideally, I would like to write a single statement that gets applied to every cell. For example, I was looking to write the python code len(column_name.split(',')). However, handling this might be constrictive to more advanced python usage.

There is a previous comment about this by @franceme in Discussions about this, however moving it here for visibility. Their specific post was:

As a user, I would like the ability to use Python snippets within formulas to create columns. Using Python for certain functions may make things easier in scenarios.

Ex: Create a column of File Extensions based on a column of Files Python: os.path.basename(dataframe['File'].str) or something similar

aarondr77 avatar Mar 28 '22 20:03 aarondr77

Copying over @naterush's previous thoughts on implentation as well:

  1. We should be thoughtful about how we handle imports (e.g. os here would need to be in scope). Pandas has useful built ins as well.
  2. We shouldn't be restrictive on what this code can return - it would be useful to be able to compute intermediate results that aren't just series...
  3. How to handle multi-line statements?

aarondr77 avatar Mar 28 '22 20:03 aarondr77

This could be a useful feature as you suggest but from a CyberSecurity point of view I wonder if that functionality could be subverted for other purposes.

I would hope that by allowing snippets to be run, that a Nefarious Threat Actor (Hows that for CyberSecurity terminology), couldn't run something like "import naughty_ module" and then in a second column be able to execute code utilising info loaded from the Naughty module.

twelsh37 avatar Mar 30 '22 19:03 twelsh37