-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Updated code_utils.py & local_commandline_code_executor.py (powershell to pwsh) #1710
Conversation
Updated the powershell command to pwsh
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1710 +/- ##
===========================================
+ Coverage 39.21% 50.59% +11.37%
===========================================
Files 57 57
Lines 6082 6096 +14
Branches 1363 1484 +121
===========================================
+ Hits 2385 3084 +699
+ Misses 3502 2766 -736
- Partials 195 246 +51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thanks for the PR! Have you also checked out the new code executor? It’s here https://github.com/microsoft/autogen/blob/main/autogen/coding/local_commandline_code_executor.py
You can use the new code executor like
proxy = CoversableAgent(“proxy”, code_execution_config={“executor”: “commadline-local”})
Perhaps you want to add the handling for powershell there as well? It’s okay to do it in a separate PR.
Co-authored-by: Chi Wang <[email protected]>
…l to pwsh) (microsoft#1710) * Update code_utils.py Updated the powershell command to pwsh * Update code_utils.py added a split to handle powershell in the first condition as well * Update local_commandline_code_executor.py added "pwsh" as a command option in lang variable * Update autogen/coding/local_commandline_code_executor.py Co-authored-by: Eric Zhu <[email protected]> * Update code_utils.py * Update code_utils.py fixed formatting * Update code_utils.py defined a function to detect whether 'powershell' or 'pwsh' works and accordingly use the one that works * Update code_utils.py fixed formatting * Update and rename test_code.py to test_code_utils.py added a unit test for get_powershell_command function in code_utils.py * Update test_code_utils.py fixed formatting * Update test_code_utils.py fixed formatting * Update autogen/code_utils.py Co-authored-by: Chi Wang <[email protected]> --------- Co-authored-by: Eric Zhu <[email protected]> Co-authored-by: Chi Wang <[email protected]>
Updated the 'powershell' command to 'pwsh' for a ps1 executable file
Why are these changes needed?
I was trying to use autogen to execute terminal commands (eg: git status, ls) but it was throwing an error. So these changes are required if terminal commands are to be executed in the new 7.x version of PowerShell. To execute terminal commands in powershell, autogen first makes a ps1 shell script with those commands written in it and then executes that ps1 shell script. In order for that shell script execution to work, these changes are required.
In March 2020, microsoft released a new version of powershell (7.0) in which the powershell.exe file was renamed to pwsh.exe
https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.4
In your code, if the user is working in a powershell window and a '.ps1' script is to be executed, your code uses the 'powershell' command to execute it which has now been replaced with 'pwsh' in the new Microsoft PowerShell version 7.0
So in your code I replaced the command 'powershell' with 'pwsh' when a ps1 script has to be executed
I also added the 'pwsh' command to the list of commands in the local_commandline_code_executor.py file
Checks