Skip to content

Merge Dev - Multi-file support for code optimization#113

Merged
aliroberts merged 6 commits intomainfrom
dev
Feb 25, 2026
Merged

Merge Dev - Multi-file support for code optimization#113
aliroberts merged 6 commits intomainfrom
dev

Conversation

@aliroberts
Copy link
Contributor

Add multi-file optimization support to weco-cli

Summary

  • Add --sources flag to optimize multiple files simultaneously
  • Simplify internal code handling to work exclusively with dict[str, str] file maps
  • Update README with multi-file usage and examples

Changes

New --sources flag

Added --sources as a mutually exclusive alternative to -s/--source:

# Single file (existing)
weco run -s model.py -c "python eval.py" -m accuracy -g maximize

# Multiple files (new)
weco run --sources model.py utils.py config.py -c "python eval.py" -m accuracy -g maximize

Accepts one or more file paths via nargs="+". Internally, both flags normalize to the same list[str] passed to the optimizer.

Simplified code handling

The server now always returns code as dict[str, str] to new CLI versions. Removed isinstance branching in:

  • Execution loop (optimizer.py): code from the server is always a dict file map — removed the string-to-dict conversion branch
  • Best solution handler (optimizer.py): best_code is always a dict — removed string branch, always iterates file map to write each file to disk
  • Resume handler (optimizer.py): resume_source_code from server is always a dict — removed source_path/scoped_files fallback branches

API signature

source_code parameter in api.py changed from str | dict[str, str] to dict[str, str].

Validation

Source validation (validation.py) updated to accept list[str] and validate all paths exist and are readable.

README

  • Added --sources to the required arguments table (mutually exclusive with -s/--source)
  • Added multi-file usage example
  • Updated evaluation note to reference both flags

@aliroberts aliroberts merged commit 775512d into main Feb 25, 2026
2 checks passed
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