Skip to content

fix(local): install requirements of string-defined functions - #8350

Open
Winoren (Winoren) wants to merge 1 commit into
microsoft:mainfrom
Winoren:fix/local-string-function-dependencies
Open

Winoren (Winoren) wants to merge 1 commit into
microsoft:mainfrom
Winoren:fix/local-string-function-dependencies

Conversation

@Winoren

Copy link
Copy Markdown

Why are these changes needed?

LocalCommandLineCodeExecutor accepts FunctionWithRequirementsStr, including its python_packages and global_imports, but _setup_functions() only collects package requirements from FunctionWithRequirements. A string-defined function with a dependency that is not already installed consequently fails while loading its generated module with ModuleNotFoundError, even though that dependency was explicitly declared.

Include FunctionWithRequirementsStr in the existing requirement collection. Installation, deduplication, virtual-environment selection, cancellation and function loading continue through the same setup path.

The regression test creates a tiny local wheel and a fresh virtual environment. It invokes the real executor, installs the declared wheel through real pip, imports the generated function module and checks the function returns 42. Package-index access and pip version checks are disabled for this test, so it runs without an external package server.

Related issue number

Found by inspecting the current local executor implementation; no linked issue.

Validation

Based on upstream 027ecf0a379bcc1d09956d46d12d44a3ad9cee14, using Python 3.11 in an isolated uv environment with editable AutoGen packages:

  • Before the fix, the new test fails with ModuleNotFoundError: No module named 'autogen_executor_test_dependency' during function setup.
  • python -m pytest python/packages/autogen-ext/tests/code_executors/test_commandline_code_executor.py -q: 14 passed, 1 skipped (platform-specific PowerShell case).
  • Ruff 0.4.8 lint and format checks on both changed files: passed.
  • Mypy 1.13.0, --config-file python/pyproject.toml --follow-imports=silent on both changed files: passed.
  • git diff --check: passed.

Full workspace checks, documentation builds, Docker/Azure execution and Windows execution were not run.

Checks

  • I've included any doc changes needed for https://microsoft.github.io/autogen/. No documentation change is needed; this restores declared dependency handling for an already accepted input type.
  • I've added tests (if relevant) corresponding to the changes introduced in this PR.
  • I've made sure all auto checks have passed. Local checks are listed above; upstream CI is pending.

Prepared with Codex assistance.

This branch has not been deployed

No deployments
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.

1 participant