agentos-project/agentos

dulwich_checkout() failing when called by repo.get_local_file_path()

Closed this issue · 1 comments

andyk commented

After the merge of #358, I'm hitting a bug that seems related.

Below are the steps to reproduce and the error output.

Note that it first checks out master from the remote andyk (which is currently 09c87fe), in which the folder documentation/api_doc_includes does not yet exist, and then fails when it tries to write a folder in that dir (since the dir doesn't exist).

# Delete my local agentos repo cache
rm -rf /Users/andyk/.agentos/cache/repos_cache
# checkout one of my dev branches  (make sure it is tracking the branch in remote andyk) and run a demo script inside of it
git checkout andyk/agent_runs_track_parent_agent_runs
/Users/andyk/Development/agentos/documentation/demos/demo_script_sb3_example_agent.py

# here is error output i see:

/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/bin/python /Users/andyk/Development/agentos/documentation/demos/demo_script_sb3_example_agent.py
WARNING: version was passed into get_local_path() on a LocalRepo, which means it is being ignored. If this is actually a versioned repo, use GithubRepo or another versioned Repo type.
WARNING: version was passed into get_local_path() on a LocalRepo, which means it is being ignored. If this is actually a versioned repo, use GithubRepo or another versioned Repo type.
WARNING: version was passed into get_local_path() on a LocalRepo, which means it is being ignored. If this is actually a versioned repo, use GithubRepo or another versioned Repo type.
WARNING: version was passed into get_local_path() on a LocalRepo, which means it is being ignored. If this is actually a versioned repo, use GithubRepo or another versioned Repo type.
Enumerating objects: 6735, done.
Counting objects: 100% (6735/6735), done.
Compressing objects: 100% (2344/2344), done.
Total 6735 (delta 4531), reused 6302 (delta 4197), pack-reused 0
Checking out 09c87fe1e855d2a8b25e326a843482b030ef186d
Traceback (most recent call last):
  File "/Users/andyk/Development/agentos/documentation/demos/demo_script_sb3_example_agent.py", line 7, in <module>
    learning_run = random_agent.run_with_arg_set(  # "learn", {})
  File "/Users/andyk/Development/agentos/pcs/component.py", line 382, in run_with_arg_set
    obj = self.get_object(arg_set=args)
  File "/Users/andyk/Development/agentos/pcs/component.py", line 425, in get_object
    return self._get_object(arg_set, collected)
  File "/Users/andyk/Development/agentos/pcs/component.py", line 430, in _get_object
    imported_obj = self._import_object()
  File "/Users/andyk/Development/agentos/pcs/component.py", line 454, in _import_object
    self._venv = self._build_virtual_env()
  File "/Users/andyk/Development/agentos/pcs/component.py", line 480, in _build_virtual_env
    full_req_path = self.repo.get_local_file_path(
  File "/Users/andyk/Development/agentos/pcs/repo.py", line 332, in get_local_file_path
    local_repo_path = self.get_local_repo_dir(version)
  File "/Users/andyk/Development/agentos/pcs/repo.py", line 326, in get_local_repo_dir
    self._checkout_version(local_repo_path, version)
  File "/Users/andyk/Development/agentos/pcs/repo.py", line 366, in _checkout_version
    dulwich_checkout(repo=repo, target=treeish, force=True)
  File "/Users/andyk/Development/agentos/pcs/utils.py", line 251, in dulwich_checkout
    porcelain.reset_file(repo, file.decode(), b"HEAD")
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/dulwich/porcelain.py", line 1761, in reset_file
    build_file_from_blob(blob, mode, full_path)
  File "/opt/homebrew/Caskroom/miniforge/base/envs/agentos_dev2/lib/python3.9/site-packages/dulwich/index.py", line 615, in build_file_from_blob
    with open(target_path, "wb") as f:
FileNotFoundError: [Errno 2] No such file or directory: b'/Users/andyk/.agentos/cache/repos_cache/andyk/agentos.git/a3001bd4cd151e75bf4e6340a76bb39a42c46858/documentation/api_doc_includes/agentos/agentos.cli.rst'

Process finished with exit code 1