microsoft / python-in-excel

Python in Microsoft Excel
MIT License
517 stars 34 forks source link

Run Locally #11

Open sirinath opened 1 year ago

sirinath commented 1 year ago

Please ad an option to run locally with the installed Python distribution.

stonebig commented 1 year ago

Maybe then there is a big warm-up cost ?

stonebig commented 1 year ago

What would be truly nice, is to not have to pay for Python cpu cycles on Azure, but use the Local PC Cpu instead. A python- inside-a-wasm option ? For what I could test:

richardwesthaver commented 1 year ago

I’d like to second this feature request - Excel -> Python is a great pathway for getting folks interested in programming and this could be a great tool for education. It would be awesome to have an ‘escape hatch’ toggle though which doesn’t rely on O365 services and would make for a very smooth transition to programming outside of excel workbooks.

Also there are some orgs which may be interested in this feature for security/legal reasons - where cloud compute resources need to go through some lengthy audits.

Cheers, Richard

sirinath commented 1 year ago

Maybe the Python can be integrated with PowerFX (https://github.com/microsoft/Power-Fx) too.

jflam commented 1 year ago

I’d like to second this feature request - Excel -> Python is a great pathway for getting folks interested in programming and this could be a great tool for education. It would be awesome to have an ‘escape hatch’ toggle though which doesn’t rely on O365 services and would make for a very smooth transition to programming outside of excel workbooks.

We've definitely thought about the possibilities in education here and what we can do with potentially WASM hosted local execution. But that tech isn't mature enough yet for products like Excel, but we are monitoring (and have MSFT employees actively working on Python in WASM) this closely.

Do you have any examples of a scenario where you would start from an Excel workbook and then transition the Python code to something running outside of Excel? Would love to learn more about this.

GaryT25 commented 1 year ago

I’d like to second this feature request - Excel -> Python is a great pathway for getting folks interested in programming and this could be a great tool for education. It would be awesome to have an ‘escape hatch’ toggle though which doesn’t rely on O365 services and would make for a very smooth transition to programming outside of excel workbooks.

Also there are some orgs which may be interested in this feature for security/legal reasons - where cloud compute resources need to go through some lengthy audits.

Cheers,

Richard

I agree. A lot of organizations do not like to add cloud resources when not absolutely necessary, and this feature would be amazing using just your local machine with python installed!

stonebig commented 1 year ago

On a test sample of 1, the main complaint of Python teachers in a Classroom is the internet Bandwith & reliability. You can't rely on internet for your lessons.

elubarsky-hs commented 1 year ago

Running locally would likely have reduced CO2 impact compared with a cloud solution as data doesn't have to be transferred to/from the cloud (especially if data volume is large)? And it would be much better when internet access is slow or expensive..

DrEntropy commented 1 year ago

I agree that the choice of using a cloud service for the python kernel seems strange to me. Why this choice? I see several issues:

  1. Security: Some companies and organizations will not (or cannot, if they are air gapped) send data offsite for analysis.
  2. Bandwidth: Sending large dataframes back and forth over the internet seems to be wasteful and slow
  3. Offline use: This will (obviously) preclude offline use. Which is a shame, I have a perfectly good python environment I can use instead.

    I think it would be a fine 'option' for people who don't want to bother with learning the care and feeding of a python environment. But anyone who knows enough python to make use of this feature probably has several such environments already set up and ready to go. So perhaps I don't understand the use case? Education?

jflam commented 1 year ago

I tried to answer this question in this tweet: https://twitter.com/john_lam/status/1694480333184569400. Also copying and pasting it into this thread as well. Hope this helps clarify the design constraints that we had for this feature!

A common question that has come up is why don't we run Python locally? There are three main reasons:

  1. Running Python securely on a local machine is a really hard problem. We treat all Python code in the workbook as untrusted, so we execute it in a hypervisor-isolated container on Azure that does not have any outbound network access. Python code and the data that it operates on is sent to be executed in the container. The Microsoft-licensed Python environment in the container is provided by Anaconda and was prepared using their stringent security practices as documented here: https://docs.anaconda.com/free/anaconda/reference/security/

  2. Sharing Excel workbooks with others is a really important scenario. We wanted to ensure that Python code in a workbook that you share will behave as you intended when someone else opens it; they wouldn't first need to install Python first.

  3. We need to ensure that the Python in Excel feature always works for our customers. The value of Python is in its ecosystem of libraries, not just in providing a Python interpreter. But managing a local Python environment is challenging even for the most experienced developers. By running on Azure, we remove the need for users or their systems administrators to have to maintain a local installation of Python on every machine that uses the feature in their organization.

DrEntropy commented 1 year ago

I tried to answer this question in this tweet: https://twitter.com/john_lam/status/1694480333184569400. Also copying and pasting it into this thread as well. Hope this helps clarify the design constraints that we had for this feature!

Ah, I had not thought of it in that way. This was very helpful! Still would love to see an offline mode ('unsafe' or using local docker containers) in the future, but now I think I understand why you went down this road first.

sirinath commented 1 year ago

You can have the option do run the container locally.

A firewall or restricted network access can effect the working of Excel.

jflam commented 1 year ago

Local container runtimes do not provide sufficient isolation today. It's also true that firewalls / NAT rules could block access as well. What we shipped is a tradeoff that we had to make to ship something sooner rather than later once all issues could be resolved. It's a hard problem!

ismasanchez commented 11 months ago

While I understand the security concerns, the user/organization should be the ones that weights the risk and allow the possibility to run the code locally. My proposal is to provide some option to configure the environment where python code should run. This way, personal or professionals could use all its potential, and large organizations or public institutions (education, etc...) could limit its usage to mitigate risks.