AgentOps-AI / agentops

Python SDK for agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks like CrewAI, Langchain, and Autogen
https://agentops.ai
MIT License
1.27k stars 102 forks source link

meta_client.py-meta_client:48 - WARNING: 🖇 AgentOps: Error: [WinError 21] The device is not ready: 'G:\\' ---> In Windows #170

Closed Richardson143 closed 2 months ago

Richardson143 commented 2 months ago

🐛 Bug Report

(venv) PS E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew> python main.py
2024-04-30 10:04:06,923 - 3368 - meta_client.py-meta_client:48 - WARNING: 🖇 AgentOps: Error: [WinError 21] The device is not ready: 'G:\' 2024-04-30 10:04:07,007 - 3368 - meta_client.py-meta_client:48 - WARNING: 🖇 AgentOps: Error: [WinError 21] The device is not ready: 'G:\' 2024-04-30 10:04:07,039 - 3368 - client.py-client:242 - WARNING: 🖇 AgentOps: Cannot end session - no current session Traceback (most recent call last): File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\meta_client.py", line 46, in wrapper return method(self, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\client.py", line 217, in start_session self._session = Session(inherited_session_id or uuid4(), tags or self._tags, host_env=get_host_env()) ^^^^^^^^^^^^^^ File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\host_env.py", line 63, in get_host_env "Disk": get_disk_details(), ^^^^^^^^^^^^^^^^^^ File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\agentops\host_env.py", line 46, in get_disk_details usage = psutil.disk_usage(partition.mountpoint) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\psutil__init__.py", line 2049, in disk_usage return _psplatform.disk_usage(path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "E:\Appdata\program files\python\projects\projects folder on crewAI\insta crew\venv\Lib\site-packages\psutil_pswindows.py", line 291, in disk_usage total, free = cext.disk_usage(path) ^^^^^^^^^^^^^^^^^^^^^ PermissionError: [WinError 21] The device is not ready: 'G:\'

🔎 Describe the Bug The application crashes with a PermissionError when trying to access the 'G:\' drive, which is not ready or inaccessible.

🔄 Reproduction Steps

Run the main.py script. The application attempts to retrieve disk usage details using the psutil library. The psutil library tries to access the 'G:\' drive, which is not ready. A PermissionError is raised, causing the application to crash. 🙁 Expected Behavior The application should handle the situation gracefully when the 'G:\' drive is not ready, without raising an error.

📸 Screenshots image

🔍 Additional Context The error occurs in the get_disk_details() function in host_env.py, which is called by the start_session() function in client.py. The get_disk_details() function uses the psutil.disk_partitions() function to retrieve a list of all mounted partitions, and then calls the psutil.disk_usage() function for each partition to retrieve usage details. If the 'G:\' drive is not ready, the psutil.disk_usage() function raises a PermissionError, causing the application to crash.

bboynton97 commented 2 months ago

Thank you for submitting this! It looks like a mistake with our telemetry and we're on a fix :)

Richardson143 commented 2 months ago

Hope this helps, i just tried to avoid accessing a specific partition def get_disk_details(skip_partitions=None): partitions = psutil.disk_partitions() disk_info = {} for partition in partitions: if skip_partitions and partition.device in skip_partitions: print(f"Skipping {partition.device}") continue try: usage = psutil.disk_usage(partition.mountpoint) disk_info[partition.device] = { "Mountpoint": partition.mountpoint, "Total": f"{usage.total / (10243):.2f} GB", "Used": f"{usage.used / (10243):.2f} GB", "Free": f"{usage.free / (1024**3):.2f} GB", "Percentage": f"{usage.percent}%" } except PermissionError: print(f"Skipping {partition.device} as it's not accessible") return disk_info

Richardson143 commented 2 months ago

my crew works fine after the above change

Richardson143 commented 2 months ago

I can still find the same bug in the latest update v-0.1.8 image

image

areibman commented 2 months ago

@Richardson143 We updated the docs so that you can turn off data collection. Set AGENTOPS_ENV_DATA_OPT_OUT=True in your .env and this will no longer be collected.

That said, AgentOps by design shouldn't cause runtime errors like this. Re-opening this issue so we can work on a patch

Richardson143 commented 2 months ago

Got It, Thanks @areibman , let me try it out ..!

mbarnathan commented 1 month ago

While setting the environment variable will skip the offending code, I agree that it should just handle the exception gracefully even when the environment variable isn't set. There can be numerous reasons a volume is inaccessible (in my case, it is an optical drive without a CD/DVD/Blu-Ray present). I will send in a PR that skips the offending volume but reports the remainder.