Skip to content

Conversation

@adubatl
Copy link
Owner

@adubatl adubatl commented Feb 23, 2025

📥 Pull Request

Windows errors on cli completion :(

📘 Description

🦾 Creating a new AgentStack project...
Using framework: crewai
Creating virtual environment...
uv: [error]
[WinError 10038] An operation was attempted on something that is not a socket
Installing dependencies...
uv: [error]
[WinError 10038] An operation was attempted on something that is not a socket
Retrying uv installation with --no-cache flag...
uv: [error]
[WinError 10038] An operation was attempted on something that is not a socket
📃 Added task "fetch_todays_weather" to your AgentStack project successfully!
📃 Added task "fetch_historic_weather" to your AgentStack project successfully!
🤖 Added agent "weatherman" to your AgentStack project successfully!
🚀 AgentStack project generated successfully!

To get started, activate the virtual environment with:
💫 cd my_agent
🌟 source .venv/bin/activate
Run your new agent with:
✨ agentstack run
Or, run agentstack quickstart or agentstack docs for more next steps.

🧪 Testing
All the tests with changes here fail by default on windows when running whatever flavor of the tox command you feel like. While going thru each one, it seems largely to be how the filesystem deals with existing files. I'm still trying to sus out any bad ideas in the tests since my pytest game is mid and my Cypress game is strong.

# the packages are installed into the correct virtual environment.
# In testing, when this was not set, packages could end up in the pyenv's
# site-packages directory; it's possible an environment variable can control this.
def _get_executeable_paths():
Copy link
Owner Author

Choose a reason for hiding this comment

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

I had just done this when the _python_executable PR merged in. I'm not sure if my version is worse than the other one, but since both paths mattered based on the OS I smashed them into one func at the top of the file.

try:
while process.poll() is None:
try:
stdout, stderr = process.communicate(timeout=1.0)
Copy link
Owner Author

Choose a reason for hiding this comment

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

process.communicate is the solution to the main issue on this PR.

Using it required changing around the std in/out handling a touch, but the internet tells me .communicate is more cross-platform compatible. I'll be testing on my mac when I find the password -.-

process.terminate()
except:
pass
except Exception as e:
Copy link
Owner Author

Choose a reason for hiding this comment

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

ruff barked at me for an naked except so I tossed this in here. If my linter is the problem I'd love to know how to make ruff obey the pyproject.toml. It also happens if I run the pre-commit like I usually do.

Copy link

Choose a reason for hiding this comment

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

Yeah the right move is to have it catch something that is of type Exception which is everything. If you any to go into best practice mode, it would be catch specific exceptions, but a catch all is fine if it doesn't get hidden and out the app in a weird state.

def install(package: str):
"""Install a package with `uv` and add it to pyproject.toml."""
global _python_executable
global _PYTHON_EXECUTABLE
Copy link

Choose a reason for hiding this comment

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

Any chance this constant will change? The only reason to use global is if the function will mutate it causing it to function scope.

process.terminate()
except:
pass
except Exception as e:
Copy link

Choose a reason for hiding this comment

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

Yeah the right move is to have it catch something that is of type Exception which is everything. If you any to go into best practice mode, it would be catch specific exceptions, but a catch all is fine if it doesn't get hidden and out the app in a weird state.

BASE_PATH = Path(__file__).parent


class CLIInitTest(unittest.TestCase):
Copy link

Choose a reason for hiding this comment

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

I would use functional pytest patterns and fixtures within conftests etc instead of using unittest.TestCase. It's the more supported pattern now a days and much easier to expand with reusable fixtures etc as the test suite grows.

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