Skip to content

Commit

Permalink
Doc: Document keywords of run.py (#443)
Browse files Browse the repository at this point in the history
Closes #442
  • Loading branch information
klieret authored May 28, 2024
1 parent 689e869 commit 7032986
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
9 changes: 7 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
# Apply a patch in a local repository to an issue specified as Markdown file and run a custom installer script in the container
python run.py --model_name "gpt4" --data_path "/path/to/my_issue.md" --repo_path "/path/to/my/local/repo" --environment_setup "/path/to/setup.sh" --config_file "config/default_from_url.yaml" --apply_patch_locally
```
**For more information**: https://princeton-nlp.github.io/SWE-agent/usage/cl_tutorial/
"""

handler = RichHandler(show_time=False, show_path=False)
Expand Down Expand Up @@ -96,8 +98,11 @@ class ScriptArguments(FlattenedAccess, FrozenSerializable):
environment: EnvironmentArguments
agent: AgentArguments
actions: ActionsArguments
instance_filter: str = ".*" # Only run instances that completely match this regex
skip_existing: bool = True # Skip instances with existing trajectories
# Only run instances that completely match this regex
instance_filter: str = ".*"
# Skip instances with existing trajectories
skip_existing: bool = True
# Suffix for the run name (used for example in trajectory directory naming)
suffix: str = ""
# Raise unhandled exceptions during the run (useful for debugging)
raise_exceptions: bool = False
Expand Down
7 changes: 7 additions & 0 deletions sweagent/agent/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@
class ModelArguments(FrozenSerializable):
"""Arguments configuring the model and its behavior."""

# Name of the model to use
model_name: str
# Cost limit for every instance (task)
per_instance_cost_limit: float = 0.0
# Total cost limit
total_cost_limit: float = 0.0
# Sampling temperature
temperature: float = 1.0
# Sampling top-p
top_p: float = 1.0
# Path to replay file when using the replay model
replay_path: str = None
# Host URL when using Ollama model
host_url: str = "localhost:11434"


Expand Down
21 changes: 17 additions & 4 deletions sweagent/environment/swe_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,27 @@ class EnvironmentArguments(FrozenSerializable):
# (`json`, `jsonl`) or directory. To run over single issue: github issue url or path to markdown file
# with problem statement or problem statement as text prefixed with `text://`.
data_path: str
image_name: str
# Name of the docker image to use for the environment. Defaults to sweagent/swe-agent:latest
image_name: str = "sweagent/swe-agent:latest"
# When running over SWE-bench issues: Specify the split to use.
split: str = "dev"
# Specify a branch name or a commit hash to checkout before running the task.
# Only used when running over a single problem statement/issue.
base_commit: str | None = None
# Use a persistent container with this name
container_name: str | None = None
# Try to install the environment before running the task.
install_environment: bool = True
timeout: int = 35
# No effect, kept for backwards compatibility.
timeout: int | None = None
# Enable environment logger.
verbose: bool = False
# Do not use attempt to use a repository mirror from https://github.com/swe-bench.
no_mirror: bool = False
# Cache task images to speed up task initialization. This means that the environment will be saved as a
# docker image for every repository and base commit combination. This uses quite a bit of disk space
# but speeds up task initialization significantly when running over multiple issues from the same repository
# (or using different models for the same issues).
cache_task_images: bool = False
# Custom environment setup. Currently only used when data_path points to a single issue.
# This needs to be either a string pointing to a yaml file (with yaml, yml file extension)
Expand All @@ -78,6 +89,10 @@ class EnvironmentArguments(FrozenSerializable):
# Only used when running on single issue. Path to local repository or github repository.
repo_path: str = ""

def __post_init__(self):
if self.timeout is not None:
logger.warning("The 'timeout' argument is deprecated and has no effect.")


class EnvHook:
def on_init(self): ...
Expand Down Expand Up @@ -137,8 +152,6 @@ def __init__(self, args: EnvironmentArguments):
self.image_name = args.image_name
self._reset_container()

# Set timeout
self.timeout = self.args.timeout
self.idx = 0
self.clean_multi_line_functions = lambda x: x
self.hooks = []
Expand Down

0 comments on commit 7032986

Please sign in to comment.