Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartManoj committed Sep 25, 2024
2 parents 735ecdb + 1d05281 commit f811c6d
Show file tree
Hide file tree
Showing 29 changed files with 1,080 additions and 184 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/ghcr_runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ jobs:
run: make install-python-dependencies
- name: Run runtime tests
run: |
# We install pytest-xdist in order to run tests across CPUs. However, tests start to fail when we run
# then across more than 2 CPUs for some reason
# We install pytest-xdist in order to run tests across CPUs
poetry run pip install pytest-xdist
# Install to be able to retry on failures for flaky tests
Expand All @@ -158,10 +157,10 @@ jobs:
SKIP_CONTAINER_LOGS=true \
TEST_RUNTIME=eventstream \
SANDBOX_USER_ID=$(id -u) \
SANDBOX_BASE_CONTAINER_IMAGE=$image_name \
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
TEST_IN_CI=true \
RUN_AS_OPENHANDS=false \
poetry run pytest -n 3 --reruns 1 --reruns-delay 3 --cov=agenthub --cov=openhands --cov-report=xml -s ./tests/runtime
poetry run pytest -n 3 -raR --reruns 1 --reruns-delay 3 --cov=agenthub --cov=openhands --cov-report=xml -s ./tests/runtime
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
Expand Down Expand Up @@ -207,8 +206,7 @@ jobs:
run: make install-python-dependencies
- name: Run runtime tests
run: |
# We install pytest-xdist in order to run tests across CPUs. However, tests start to fail when we run
# then across more than 2 CPUs for some reason
# We install pytest-xdist in order to run tests across CPUs
poetry run pip install pytest-xdist
# Install to be able to retry on failures for flaky tests
Expand All @@ -220,10 +218,10 @@ jobs:
SKIP_CONTAINER_LOGS=true \
TEST_RUNTIME=eventstream \
SANDBOX_USER_ID=$(id -u) \
SANDBOX_BASE_CONTAINER_IMAGE=$image_name \
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
TEST_IN_CI=true \
RUN_AS_OPENHANDS=true \
poetry run pytest -n 3 --reruns 1 --reruns-delay 3 --cov=agenthub --cov=openhands --cov-report=xml -s ./tests/runtime
poetry run pytest -n 3 -raR --reruns 1 --reruns-delay 3 --cov=agenthub --cov=openhands --cov-report=xml -s ./tests/runtime
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
Expand Down Expand Up @@ -275,7 +273,7 @@ jobs:
TEST_RUNTIME=eventstream \
SANDBOX_USER_ID=$(id -u) \
SANDBOX_BASE_CONTAINER_IMAGE=$image_name \
SANDBOX_RUNTIME_CONTAINER_IMAGE=$image_name \
TEST_IN_CI=true \
TEST_ONLY=true \
./tests/integration/regenerate.sh
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,5 @@ containers/runtime/project.tar.gz
trajectory.json
event_history.json
sc.py
t.py
t.py
containers/runtime/code
9 changes: 5 additions & 4 deletions containers/runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Dynamic constructed Dockerfile
# Dynamically constructed Dockerfile

This folder builds runtime image (sandbox), which will use a `Dockerfile` that is dynamically generated depends on the `base_image` AND a [Python source distribution](https://docs.python.org/3.10/distutils/sourcedist.html) that's based on the current commit of `openhands`.
This folder builds a runtime image (sandbox), which will use a dynamically generated `Dockerfile`
that depends on the `base_image` **AND** a [Python source distribution](https://docs.python.org/3.10/distutils/sourcedist.html) that is based on the current commit of `openhands`.

The following command will generate Dockerfile for `ubuntu:22.04` and the source distribution `.tar` into `containers/runtime`.
The following command will generate a `Dockerfile` file for `nikolaik/python-nodejs:python3.11-nodejs22` (the default base image), an updated `config.sh` and the runtime source distribution files/folders into `containers/runtime`:

```bash
poetry run python3 openhands/runtime/utils/runtime_build.py \
--base_image ubuntu:22.04 \
--base_image nikolaik/python-nodejs:python3.11-nodejs22 \
--build_folder containers/runtime
```
25 changes: 11 additions & 14 deletions evaluation/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import subprocess
import time
import traceback
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import Any, Awaitable, Callable, TextIO

import pandas as pd
Expand Down Expand Up @@ -302,6 +301,11 @@ def _process_instance_wrapper(
time.sleep(5)


def _process_instance_wrapper_mp(args):
"""Wrapper for multiprocessing, especially for imap_unordered."""
return _process_instance_wrapper(*args)


def run_evaluation(
dataset: pd.DataFrame,
metadata: EvalMetadata | None,
Expand All @@ -328,20 +332,13 @@ def run_evaluation(

try:
if use_multiprocessing:
with ProcessPoolExecutor(num_workers) as executor:
futures = [
executor.submit(
_process_instance_wrapper,
process_instance_func=process_instance_func,
instance=instance,
metadata=metadata,
use_mp=True,
max_retries=max_retries,
)
with mp.Pool(num_workers) as pool:
args_iter = (
(process_instance_func, instance, metadata, True, max_retries)
for _, instance in dataset.iterrows()
]
for future in as_completed(futures):
result = future.result()
)
results = pool.imap_unordered(_process_instance_wrapper_mp, args_iter)
for result in results:
update_progress(result, pbar, output_fp)
else:
for _, instance in dataset.iterrows():
Expand Down
8 changes: 4 additions & 4 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@types/node": "^22.5.5",
"@types/node": "^22.6.1",
"@types/react": "^18.3.8",
"@types/react-dom": "^18.3.0",
"@types/react-highlight": "^0.12.8",
Expand Down
42 changes: 32 additions & 10 deletions frontend/src/components/AgentStatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function AgentStatusBar() {
const { curAgentState, currentStep } = useSelector(
(state: RootState) => state.agent,
);
const { curStatusMessage } = useSelector((state: RootState) => state.status);

const AgentStatusMap: {
[k: string]: { message: string; indicator: IndicatorColor };
Expand Down Expand Up @@ -81,17 +82,38 @@ function AgentStatusBar() {
// - Agent is thinking
// - Agent is ready
// - Agent is not available
useEffect(() => {
if (
curAgentState === AgentState.AWAITING_USER_INPUT ||
curAgentState === AgentState.ERROR ||
curAgentState === AgentState.INIT
) {
if (document.cookie.indexOf("audio") !== -1) beep();
}
}, [curAgentState]);

const [statusMessage, setStatusMessage] = React.useState<string>("");

React.useEffect(() => {
const trimmedCustomMessage = curStatusMessage.message.trim();
if (trimmedCustomMessage) {
setStatusMessage(t(trimmedCustomMessage));
} else {
setStatusMessage(AgentStatusMap[curAgentState].message);
}
}, [curAgentState, curStatusMessage.message]);

return (
<div className="flex items-center">
<div
className={`w-3 h-3 mr-2 rounded-full animate-pulse ${AgentStatusMap[curAgentState].indicator}`}
/>
<span className="text-sm text-stone-400">
{AgentStatusMap[curAgentState].message}
</span>
{currentStep && (
<span className="text-sm text-stone-400 ml-2">{currentStep}</span>
)}
<div className="flex flex-col items-center">
<div className="flex items-center">
<div
className={`w-3 h-3 mr-2 rounded-full animate-pulse ${AgentStatusMap[curAgentState].indicator}`}
/>
<span className="text-sm text-stone-400">{statusMessage}</span>
{currentStep && (
<span className="text-sm text-stone-400 ml-2">{currentStep}</span>
)}
</div>
</div>
);
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/components/modals/settings/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ function SettingsForm({
const [enableAdvanced, setEnableAdvanced] =
React.useState(advancedAlreadyInUse);

const handleAdvancedChange = (value: boolean) => {
setEnableAdvanced(value);
};

return (
<>
<Switch
data-testid="advanced-options-toggle"
aria-checked={enableAdvanced}
isSelected={enableAdvanced}
onValueChange={(value) => setEnableAdvanced(value)}
onValueChange={handleAdvancedChange}
>
Advanced Options
</Switch>
Expand Down
Loading

0 comments on commit f811c6d

Please sign in to comment.