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

Cookiecutter error. #4944

Open
afourney opened this issue Jan 8, 2025 · 2 comments
Open

Cookiecutter error. #4944

afourney opened this issue Jan 8, 2025 · 2 comments

Comments

@afourney
Copy link
Member

afourney commented Jan 8, 2025

What happened?

There's a dependency missing or some other documentation bug that causes the cookiecutter instructions to fail. This is what I got when I attempted to create a new package:

(python) afourney@ADAMFOX1:~/repos/autogen/python$ cookiecutter ./templates/new-package/
  [1/4] package_name (my-project): magentic-one
  [2/4] version (0.1.dev0):
  [3/4] description (My package description): Magentic-One is a generalist multi-agent system, built on `AutoGen-AgentChat`, for solving complex web and file-based tasks. This package installs all AutoGen dependencies, as well as the `m1` command-line utility to quickly get started with Magentic-One.
  [4/4] depends_on_core [y/n] (n): y
Traceback (most recent call last):
  File "/tmp/tmpeffnupgm.py", line 5, in <module>
    import tomllib
ModuleNotFoundError: No module named 'tomllib'
ERROR: Stopping generation because post_gen_project hook script didn't exit successfully
Hook script failed (exit status: 1)

What did you expect to happen?

The instructions to work.

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

Try to create a new package in a fresh environment.

AutoGen version

0.4.0dev

Which package was this bug in

Other

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

@afourney
Copy link
Member Author

afourney commented Jan 8, 2025

Seems tomllib was added in Python 3.11. I'm on 3.10

@afourney
Copy link
Member Author

afourney commented Jan 8, 2025

After upgrading to 3.11 I get:

(python) afourney@ADAMFOX1:~/repos/autogen/python$ cookiecutter ./templates/new-package/
  [1/4] package_name (my-project): magentic-one
  [2/4] version (0.1.dev0):
  [3/4] description (My package description): Magentic-One is a generalist multi-agent system, built on `AutoGen-AgentChat`, for solving complex web and file-based tasks. This package installs all AutoGen dependencies, as well as the `m1` command-line utility to quickly get started with Magentic-One.
  [4/4] depends_on_core [y/n] (n): y
Traceback (most recent call last):
  File "/tmp/tmpblg87izg.py", line 18, in <module>
    with workspace_def_path.open("rb") as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/pathlib.py", line 1045, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/../../../pyproject.toml'
Traceback (most recent call last):
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/hooks.py", line 157, in run_hook_from_repo_dir
    run_hook(hook_name, project_dir, context)
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/hooks.py", line 140, in run_hook
    run_script_with_context(script, project_dir, context)
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/hooks.py", line 123, in run_script_with_context
    run_script(temp.name, cwd)
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/hooks.py", line 94, in run_script
    raise FailedHookException(
cookiecutter.exceptions.FailedHookException: Hook script failed (exit status: 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/shutil.py", line 719, in rmtree
    orig_st = os.lstat(path, dir_fd=dir_fd)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/home/afourney/repos/autogen/python/magentic-one'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/afourney/repos/autogen/python/.venv/bin/cookiecutter", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/cli.py", line 203, in main
    cookiecutter(
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/main.py", line 182, in cookiecutter
    result = generate_files(
             ^^^^^^^^^^^^^^^
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/generate.py", line 419, in generate_files
    run_hook_from_repo_dir(
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/hooks.py", line 163, in run_hook_from_repo_dir
    rmtree(project_dir)
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/utils.py", line 34, in rmtree
    shutil.rmtree(path, onerror=force_delete)
  File "/usr/lib/python3.11/shutil.py", line 721, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/home/afourney/repos/autogen/python/.venv/lib/python3.11/site-packages/cookiecutter/utils.py", line 25, in force_delete
    os.chmod(path, stat.S_IWRITE)
FileNotFoundError: [Errno 2] No such file or directory: '/home/afourney/repos/autogen/python/magentic-one'

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

1 participant