mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
V1 Integration (#11183)
Co-authored-by: openhands <openhands@all-hands.dev> Co-authored-by: sp.wack <83104063+amanape@users.noreply.github.com> Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
@@ -5,12 +5,12 @@ import time
|
||||
|
||||
import docker
|
||||
|
||||
from openhands import __version__ as oh_version
|
||||
from openhands.core.exceptions import AgentRuntimeBuildError
|
||||
from openhands.core.logger import RollingLogger
|
||||
from openhands.core.logger import openhands_logger as logger
|
||||
from openhands.runtime.builder.base import RuntimeBuilder
|
||||
from openhands.utils.term_color import TermColor, colorize
|
||||
from openhands.version import get_version
|
||||
|
||||
|
||||
class DockerRuntimeBuilder(RuntimeBuilder):
|
||||
@@ -131,7 +131,7 @@ class DockerRuntimeBuilder(RuntimeBuilder):
|
||||
'buildx',
|
||||
'build',
|
||||
'--progress=plain',
|
||||
f'--build-arg=OPENHANDS_RUNTIME_VERSION={oh_version}',
|
||||
f'--build-arg=OPENHANDS_RUNTIME_VERSION={get_version()}',
|
||||
f'--build-arg=OPENHANDS_RUNTIME_BUILD_TIME={datetime.datetime.now().isoformat()}',
|
||||
f'--tag={target_image_hash_name}',
|
||||
'--load',
|
||||
|
||||
@@ -78,7 +78,7 @@ class JupyterPlugin(Plugin):
|
||||
|
||||
# Using synchronous subprocess.Popen for Windows as asyncio.create_subprocess_shell
|
||||
# has limitations on Windows platforms
|
||||
self.gateway_process = subprocess.Popen( # type: ignore[ASYNC101] # noqa: ASYNC101
|
||||
self.gateway_process = subprocess.Popen( # type: ignore[ASYNC101]
|
||||
jupyter_launch_command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
@@ -91,19 +91,19 @@ class JupyterPlugin(Plugin):
|
||||
output = ''
|
||||
while should_continue():
|
||||
if self.gateway_process.stdout is None:
|
||||
time.sleep(1) # type: ignore[ASYNC101] # noqa: ASYNC101
|
||||
time.sleep(1) # type: ignore[ASYNC101]
|
||||
continue
|
||||
|
||||
line = self.gateway_process.stdout.readline()
|
||||
if not line:
|
||||
time.sleep(1) # type: ignore[ASYNC101] # noqa: ASYNC101
|
||||
time.sleep(1) # type: ignore[ASYNC101]
|
||||
continue
|
||||
|
||||
output += line
|
||||
if 'at' in line:
|
||||
break
|
||||
|
||||
time.sleep(1) # type: ignore[ASYNC101] # noqa: ASYNC101
|
||||
time.sleep(1) # type: ignore[ASYNC101]
|
||||
logger.debug('Waiting for jupyter kernel gateway to start...')
|
||||
|
||||
logger.debug(
|
||||
|
||||
@@ -231,7 +231,7 @@ class BashSession:
|
||||
|
||||
# Set history limit to a large number to avoid losing history
|
||||
# https://unix.stackexchange.com/questions/43414/unlimited-history-in-tmux
|
||||
self.session.set_option('history-limit', str(self.HISTORY_LIMIT), _global=True)
|
||||
self.session.set_option('history-limit', str(self.HISTORY_LIMIT), global_=True)
|
||||
self.session.history_limit = self.HISTORY_LIMIT
|
||||
# We need to create a new pane because the initial pane's history limit is (default) 2000
|
||||
_initial_window = self.session.active_window
|
||||
|
||||
@@ -86,7 +86,7 @@ async def read_file(
|
||||
)
|
||||
|
||||
try:
|
||||
with open(whole_path, 'r', encoding='utf-8') as file: # noqa: ASYNC101
|
||||
with open(whole_path, 'r', encoding='utf-8') as file:
|
||||
lines = read_lines(file.readlines(), start, end)
|
||||
except FileNotFoundError:
|
||||
return ErrorObservation(f'File not found: {path}')
|
||||
@@ -127,7 +127,7 @@ async def write_file(
|
||||
os.makedirs(os.path.dirname(whole_path))
|
||||
mode = 'w' if not os.path.exists(whole_path) else 'r+'
|
||||
try:
|
||||
with open(whole_path, mode, encoding='utf-8') as file: # noqa: ASYNC101
|
||||
with open(whole_path, mode, encoding='utf-8') as file:
|
||||
if mode != 'w':
|
||||
all_lines = file.readlines()
|
||||
new_file = insert_lines(insert, all_lines, start, end)
|
||||
|
||||
@@ -12,10 +12,10 @@ from dirhash import dirhash
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
import openhands
|
||||
from openhands import __version__ as oh_version
|
||||
from openhands.core.exceptions import AgentRuntimeBuildError
|
||||
from openhands.core.logger import openhands_logger as logger
|
||||
from openhands.runtime.builder import DockerRuntimeBuilder, RuntimeBuilder
|
||||
from openhands.version import get_version
|
||||
|
||||
|
||||
class BuildFromImageType(Enum):
|
||||
@@ -93,11 +93,11 @@ def get_runtime_image_repo_and_tag(base_image: str) -> tuple[str, str]:
|
||||
repo = f'{repo_hash}_{repo[-24:]}' # Use 8 char hash + last 24 chars
|
||||
repo = repo.replace('/', '_s_')
|
||||
|
||||
new_tag = f'oh_v{oh_version}_image_{repo}_tag_{tag}'
|
||||
new_tag = f'oh_v{get_version()}_image_{repo}_tag_{tag}'
|
||||
|
||||
# if it's still too long, hash the entire image name
|
||||
if len(new_tag) > 128:
|
||||
new_tag = f'oh_v{oh_version}_image_{hashlib.md5(new_tag.encode()).hexdigest()[:64]}'
|
||||
new_tag = f'oh_v{get_version()}_image_{hashlib.md5(new_tag.encode()).hexdigest()[:64]}'
|
||||
logger.warning(
|
||||
f'The new tag [{new_tag}] is still too long, so we use an hash of the entire image name: {new_tag}'
|
||||
)
|
||||
@@ -177,10 +177,12 @@ def build_runtime_image_in_folder(
|
||||
enable_browser: bool = True,
|
||||
) -> str:
|
||||
runtime_image_repo, _ = get_runtime_image_repo_and_tag(base_image)
|
||||
lock_tag = f'oh_v{oh_version}_{get_hash_for_lock_files(base_image, enable_browser)}'
|
||||
lock_tag = (
|
||||
f'oh_v{get_version()}_{get_hash_for_lock_files(base_image, enable_browser)}'
|
||||
)
|
||||
versioned_tag = (
|
||||
# truncate the base image to 96 characters to fit in the tag max length (128 characters)
|
||||
f'oh_v{oh_version}_{get_tag_for_versioned_image(base_image)}'
|
||||
f'oh_v{get_version()}_{get_tag_for_versioned_image(base_image)}'
|
||||
)
|
||||
versioned_image_name = f'{runtime_image_repo}:{versioned_tag}'
|
||||
source_tag = f'{lock_tag}_{get_hash_for_source_files()}'
|
||||
|
||||
Reference in New Issue
Block a user