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

MagenticOne code_executor [Errno 2] No such file or directory #4900

Open
zzulueta opened this issue Jan 6, 2025 · 3 comments
Open

MagenticOne code_executor [Errno 2] No such file or directory #4900

zzulueta opened this issue Jan 6, 2025 · 3 comments

Comments

@zzulueta
Copy link

zzulueta commented Jan 6, 2025

What happened?

I created a MagenticOneGroupChat with a File Surfer, Data Assistant, and Code Executor.
team = MagenticOneGroupChat([file_surfer, data_assistant, code_executor_agent], model_client=az_model_client, max_turns=100)

As you can see in the thought process below, the FileSurfer confirms the existence and accessibility of the file.

In order to make the system work, I deleted the FileSurfer agent and just placed the data file in the same working directory as the Code Executor.

Is there a way to specify a different file path for the Code Executor to get the data files?


---------- MagenticOneOrchestrator ----------
Please check the file path ..Data/assistant/bigfootsightings.csv to confirm its existence and accessibility.

---------- FileSurfer ----------
Path: ../Data/assistant/bigfootsightings.csv
Viewport position: Showing page 1 of 2067.
=======================
observed,county,state,season,title,latitude,longitude,date,number,classification,temperature_high,temperature_mid,temperature_low,dew_point,humidity,cloud_cover,moon_phase,precip_intensity,precip_probability,precip_type,pressure,summary,uv_index,visibility,wind_bearing,wind_speed
"I was canoeing on the Sipsey river in Alabama. It was dusk as I was pulling out of the river and I was trying to hurry to get all my gear in the car before it got dark as it was about a 60 yard walk up this steep hill to where my car was. Just as I was flipping the canoe up to put on my shoulders I heard this very loud ""WHOOOOP, WHOOOP, WHOOOP, WHOOOP"", then a pause then three more whoops. I 've been in the woods enough to know it was not an owl or like any sound I've EVER heard in the woods or on a river. Too loud, too powerful. It felt like it came frome about a quarter to a half mile away. It scared the piss out of me. You've never seen a guy hustle a 75 lbs canoe on their shoulders and practically run up the hill. I didn't even tie it on properly until I got up to the highway. The weird part was I had been watching the Monster Quest series and the month before had come down the same river and thought ""This area looks just like that crap they show in the Pacific Northwest where those bogfoots are. Wonder if there were ever any bigfoots in Alabama?"" So I did an internet search and it surprised the crap out of me and found a whole freakin website about Alabama Bigfoots. Those sounds I heard sounded just like the whoops you have on this web site. Of course after watching those shows it could have been somebody doing that call blasting thing but I had emailed the Alabama Research people and they said they did not have anyone working that area at that time(AUG 2010). Over the last year I have had a few ""unusual"" moments in this area. No sightings but well, I'm short on time. The WHOOOPS were the important thing, scared the hell out of me.",Winston County,Alabama,Summer,,,,,30680,Class B,,,,,,,,,,,,,,,,
"Ed L. was salmon fishing with a companion in Prince William Sound. After anchoring off shore, his companion took a small boat up a river to check on the state of the salmon run. As the day wore on toward evening and he didn't come back at the expected time, Ed scanned upriver and across the adjacent land with binoculars. There he saw a sasquatch walking across the tundra, with long, smooth steps and with dark hair flowing from its shoulders, bouncing behind ""like a cape"" at every step. The sasquatch paid no attention to the boat (distance about 1,000').",Valdez-Chitina-Whittier County,Alaska,Fall,,,,,1261,Class A,,,,,,,,,,,,,,,,
"While attending U.R.I in the Fall of 1974,I would stay at my girlfriends mother's house on weekends because I only had a five day mealbook plan. It was Sunday evening about 10:00pm when I decided to head back to school on my ten speed bike. Very dark in the area because it being mostly wooded, country like setting but yet city. I was going down her street and noticed my front center pull brake needed to be adjusted. I stopped under a street light at the end of her street which is an intersection to adjust the brake. Directly in front of me was a small field that sloped down and away from me,pitch black background, tall grass and a few bushes being light by the street light. Typical New England, Oak, Maple and, Pine trees. As I was fixing my brake I began hearing very loud foot steps of a biped, comig from the field on the slope side,more like a crushing thud. I could hear the actual compression being placed, like someone dropping a heavy metal ball/rock on the ground.I looked up to see if I could see anything and just said to myself ""its nothing"", and went back to fixing my brake. I noticed it was getting closer and felt very apprehensive, the sound was coming in my direction. All of sudden this dog starts barking like crazy, I can hear the chain snap as it either tries to attack or getaway from something. I said to myself ""its time to go!"", as I started I turned left to head north, into a few pedals. From out of the darkness steps into the street light this white looking gorilla. The legs present themselves then the body as it comes to rest on its knuckles. Twenty maybe twenty five feet away, directly across the street from me perhads six feet tall maybe 400 pounds or more. Massive arms that went straight down on its knuckles, knees slight bent.The head is higher in the back connected to the neck all-in-one mass. The face dark, deep strong  but primate.The eyes are close together and set deep in the face. The nose and mouth are human like, it's nose is wide, around the mouth black hair that went down on each side.It looks up with its head and chest see me, eyeball to eyeball as I look back trying to see if this thing is real. Humanlike in appearance, the face is not like a primate but has a distinct animal presence (the eye are close together). I was never so scared in my life and knew had I stayed I don't think I would of survived the attack.The way it was positioned gave it an explosive start as it decides to chase 

---------- MagenticOneOrchestrator ----------
Please execute the following Python script to count the number of rows in the dataset, which represents the total number of sightings: ```python
import pandas as pd

df = pd.read_csv('../Data/assistant/bigfootsightings.csv')
total_sightings = len(df)
total_sightings
```
---------- code_executor ----------
The script ran, then exited with an error (POSIX exit code: 2)
Its output was:
python: can't open file '/workspace/tmp_code_0ed6da71ea5b266df9cf2e5f67b4380f4f05c9e522ac957fe70ee74c8bfcb64d.python': [Errno 2] No such file or directory


What did you expect to happen?

I expected the Code Executor to have access to the data file given that the FileSurfer was able to display the file

How can we reproduce it (as minimally and precisely as possible)?

  1. create a code executor.
  2. create a filesurfer and provide it access to a data file located in a directory different from the code executors working directory.
  3. create MagenticOneGroupChat
    team = MagenticOneGroupChat([file_surfer, data_assistant, code_executor_agent], model_client=az_model_client, max_turns=100)

AutoGen version

0.4

Which package was this bug in

AgentChat

Model used

No response

Python version

No response

Operating system

No response

Any additional info you think would be helpful for fixing this bug

No response

@ekzhu
Copy link
Collaborator

ekzhu commented Jan 7, 2025

The file the code executor tried and failed to open is not the dataset file, is the generated code file. Do you have special permissions assigned to the file system? What is the environment your code is running.

@ekzhu ekzhu added the awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster label Jan 7, 2025
@zzulueta
Copy link
Author

zzulueta commented Jan 7, 2025

I am using GitHub Codespaces.

The Code Executor has access to the coding folder.
Image

Here is the actual error message from the code executor:
---------- code_executor ----------
The script ran, then exited with an error (POSIX exit code: 1)
Its output was:
Traceback (most recent call last):
File "/workspace/tmp_code_a7cf2e7e9a6d347d0074e5f79990dbd518fcd485e758cf22064494bfff04b8a1.python", line 6, in
data = pd.read_csv(file_path)
File "/usr/local/lib/python3.13/site-packages/pandas/io/parsers/readers.py", line 1026, in read_csv
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python3.13/site-packages/pandas/io/parsers/readers.py", line 620, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "/usr/local/lib/python3.13/site-packages/pandas/io/parsers/readers.py", line 1620, in init
self._engine = self._make_engine(f, self.engine)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/pandas/io/parsers/readers.py", line 1880, in _make_engine
self.handles = get_handle(
~~~~~~~~~~^
f,
^^
...<6 lines>...
storage_options=self.options.get("storage_options", None),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/pandas/io/common.py", line 873, in get_handle
handle = open(
handle,
...<3 lines>...
newline="",
)
FileNotFoundError: [Errno 2] No such file or directory: '/workspaces/AzureAI/Data/assistant/bigfootsightings.csv'

The File Surfer has access to the file:

---------- FileSurfer ----------
Path: /workspaces/AzureAI/Data/assistant/bigfootsightings.csv
Viewport position: Showing page 1 of 2067.

observed,county,state,season,title,latitude,longitude,date,number,classification,temperature_high,temperature_mid,temperature_low,dew_point,humidity,cloud_cover,moon_phase,precip_intensity,precip_probability,precip_type,pressure,summary,uv_index,visibility,wind_bearing,wind_speed
"I was canoeing on the Sipsey river in Alabama. It was dusk as I was pulling out of the river and I was trying to hurry to get all my gear in the car before it got dark as it was about a 60 yard walk up this steep hill to where my car was. Just as I was flipping the canoe up to put on my shoulders I heard this very loud ""WHOOOOP, WHOOOP, WHOOOP, WHOOOP"", then a pause then three more whoops. I 've been in the woods enough to know it was not an owl or like any sound I've EVER heard in the woods or on a river. Too loud, too powerful. It felt like it came frome about a quarter to a half mile away. It scared the piss out of me. You've never seen a guy hustle a 75 lbs canoe on their shoulders and practically run up the hill. I didn't even tie it on properly until I got up to the highway. The weird part was I had been watching the Monster Quest series and the month before had come down the same river and thought ""This area looks just like that crap they show in the Pacific Northwest where those bogfoots are. Wonder if there were ever any bigfoots in Alabama?"" So I did an internet search and it surprised the crap out of me and found a whole freakin website about Alabama Bigfoots. Those sounds I heard sounded just like the whoops you have on this web site. Of course after watching those shows it could have been somebody doing that call blasting thing but I had emailed the Alabama Research people and they said they did not have anyone working that area at that time(AUG 2010). Over the last year I have had a few ""unusual"" moments in this area. No sightings but well, I'm short on time. The WHOOOPS were the important thing, scared the hell out of me.",Winston County,Alabama,Summer,,,,,30680,Class B,,,,,,,,,,,,,,,,
"Ed L. was salmon fishing with a companion in Prince William Sound. After anchoring off shore, his companion took a small boat up a river to check on the state of the salmon run. As the day wore on toward evening and he didn't come back at the expected time, Ed scanned upriver and across the adjacent land with binoculars. There he saw a sasquatch walking across the tundra, with long, smooth steps and with dark hair flowing from its shoulders, bouncing behind ""like a cape"" at every step. The sasquatch paid no attention to the boat (distance about 1,000').",Valdez-Chitina-Whittier County,Alaska,Fall,,,,,1261,Class A,,,,,,,,,,,,,,,,
"While attending U.R.I in the Fall of 1974,I would stay

It seems that the code executor is using the wrong location where the data file is located. Here is the output of the Orchestrator

  • Updated Guess: The FileNotFoundError is likely due to a mismatch between the current working directory and the file path specified in the script, suggesting that an adjustment in the path construction or retrieval method (using os.getcwd() and os.path.join) may resolve the issue.
  • There might be environmental issues, such as differences in path handling between the script executor and the location of files, requiring adjustment.

The reason for updating the educated guess is that using Python's os module functions to dynamically determine and verify the current working directory and construct file paths can often clarify and resolve discrepancies that lead to FileNotFoundErrors, particularly when the system environment and provided file path information do not align.

Here is the plan to follow as best as possible:

Root Cause of the Failure:
The persistent FileNotFoundError suggests that there might be an issue with the file path used in the script. The current directory might not align with the location of the 'bigfootsightings.csv' file, leading the script to search for it in an incorrect directory.

New Plan:

  • FileSurfer:

    • Verify the absolute path to 'bigfootsightings.csv' again and ensure there's no discrepancy like hidden characters or incorrect directory structure.
    • Log the current working directory by running a simple command or using a Python snippet to confirm from where the script is executing.
  • code_executor:

    • Use os.getcwd() in a Python script to log the current working directory to ensure clarity on where the script is executing from.
    • Modify the script to use os.path.join to construct the file path based dynamically on the current working directory if needed.
    • Run a small script to validate file access, like checking if the file exists at the constructed path to rule out any path errors before running the full analysis script.

Here is the final output by the Orchestrator:
MagenticOneOrchestrator
It seems we encountered a FileNotFoundError while attempting to access the 'bigfootsightings.csv' file. Even though we confirmed the file existed using FileSurfer, the Python script still couldn't locate it.

To proceed, please double-check the file path and ensure it matches exactly with what was provided. Also, verify there are no issues related to file permissions or directory access in the execution environment.

Once the path issue is resolved, re-running the script should correctly generate the analysis and plot, saving it as a PNG file as requested.

If there are any specific configurations or peculiarities related to the environment where you're running this, adjusting for those may also help resolve the access issue.

So again, the question is, how can we set the path of the datafile? The code works if we remove the FileSurfer and just place the data file in the same directory as the coding folder

@github-actions github-actions bot removed the awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster label Jan 7, 2025
@zzulueta
Copy link
Author

zzulueta commented Jan 7, 2025

I individually ran one of the python files created by the code executor and the code was correct and provided the right result!

@zzulueta ➜ /workspaces/AzureAI/AutoGen/coding (main) $ python tmp_code_774f108a989a1b63e122b2629ecd8a4bff38277a4137459d34a674acd23775e9.python
5021

The code executor says it has no such file exists:
---------- code_executor ----------
The script ran, then exited with an error (POSIX exit code: 1)
Its output was:
Traceback (most recent call last):
File "/workspace/tmp_code_d4be2ae1c26f581d569750a2ca381bbf542dc1031f9135f75dd27cf63381fe4f.python", line 5, in
with open(file_path, 'r') as file:
~~~~^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/workspaces/AzureAI/Data/assistant/bigfootsightings.csv'

But the code inside the python file points to the same directory:
with open('/workspaces/AzureAI/Data/assistant/bigfootsightings.csv', 'r') as file:

So again, why wouldnt this result 5021 come out from the agent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants