Skip to content
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

In code_utils.py, handling NotADirectoryError as well in get_powershell_command #1948

Merged
merged 1 commit into from
Mar 11, 2024
Merged

Conversation

abhaymathur21
Copy link
Contributor

@abhaymathur21 abhaymathur21 commented Mar 11, 2024

Why are these changes needed?

On MacOS for example, the windows powershell directory does not even exist and the python subprocess looks for the powershell directory in the path and throws a NotADirectoryError. In windows, the powershell directory exists so that error is not thrown but the file name may be different (powershell.exe or pwsh.exe) so a FileNotFoundError is thrown.

We must be able to deal with both these scenarios, hence these changes are necessary.

Related issue number

Closes #1947

Checks

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 47.76%. Comparing base (b0a8e6e) to head (32f580a).

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1948       +/-   ##
===========================================
+ Coverage   37.33%   47.76%   +10.42%     
===========================================
  Files          64       64               
  Lines        6913     6913               
  Branches     1519     1650      +131     
===========================================
+ Hits         2581     3302      +721     
+ Misses       4109     3336      -773     
- Partials      223      275       +52     
Flag Coverage Δ
unittests 47.63% <100.00%> (+10.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sonichi
Copy link
Contributor

sonichi commented Mar 11, 2024

@lestan could you test this PR in your environment? Thanks.

@sonichi sonichi added the code-execution execute generated code label Mar 11, 2024
@lestan
Copy link

lestan commented Mar 11, 2024

Hi @abhaymathur21

Thanks for looking into this and sharing your explanation. By that logic, shouldn't the function check for WIN32 before going into the main if statement and return None for any other platform? Seems unnecessary to execute the logic, trigger exceptions and handle them twice when we know that PowerShell is only available on Windows.

Thanks

Les

@abhaymathur21
Copy link
Contributor Author

Hi @abhaymathur21

Thanks for looking into this and sharing your explanation. By that logic, shouldn't the function check for WIN32 before going into the main if statement and return None for any other platform? Seems unnecessary to execute the logic, trigger exceptions and handle them twice when we know that PowerShell is only available on Windows.

Thanks

Les

That is a good suggestion but as far as I know it is possible to install and use powershell in various linux distributions as well and is a commonly followed practice so that's why it might be better to check the win32 condition later as I have given in the code

@lestan
Copy link

lestan commented Mar 11, 2024

Hi @abhaymathur21 and @sonichi,

I checked out the pr and built and ran it successfully. To test, I ran the test/twoagent.py and the test_chats test from test/agentchat/test_chats.py. Both tests passed.

Confirming the changes are good.

Thank you for the quick response to this!

Let me know if you need anything more from me to merge this pr. Looking forward to getting the fix into the next release!

@abhaymathur21
Copy link
Contributor Author

abhaymathur21 commented Mar 11, 2024

Hi @abhaymathur21 and @sonichi,

I checked out the pr and built and ran it successfully. To test, I ran the test/twoagent.py and the test_chats test from test/agentchat/test_chats.py. Both tests passed.

Confirming the changes are good.

Thank you for the quick response to this!

Let me know if you need anything more from me to merge this pr. Looking forward to getting the fix into the next release!

Happy to help! Thank you for pointing this issue out.

@sonichi sonichi added this pull request to the merge queue Mar 11, 2024
Merged via the queue into microsoft:main with commit b93e2c5 Mar 11, 2024
47 of 58 checks passed
@lestan
Copy link

lestan commented Mar 12, 2024

Confirmed this is working as expected in release 0.2.18! ⭐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-execution execute generated code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: PowerShell existence test broken on Mac
4 participants