refactored all relative paths to absolute paths (#3495)

This commit is contained in:
Mahmood Alhawaj
2024-08-20 19:09:48 +03:00
committed by GitHub
parent d0df95ac62
commit 6487175a31
63 changed files with 128 additions and 147 deletions

View File

@@ -1,14 +1,13 @@
from dotenv import load_dotenv
from agenthub.micro.agent import MicroAgent
from agenthub.micro.registry import all_microagents
from openhands.controller.agent import Agent
from .micro.agent import MicroAgent
from .micro.registry import all_microagents
load_dotenv()
from . import ( # noqa: E402
from agenthub import ( # noqa: E402
browsing_agent,
codeact_agent,
codeact_swe_agent,

View File

@@ -1,5 +1,4 @@
from agenthub.browsing_agent.browsing_agent import BrowsingAgent
from openhands.controller.agent import Agent
from .browsing_agent import BrowsingAgent
Agent.register('BrowsingAgent', BrowsingAgent)

View File

@@ -12,12 +12,11 @@ from browsergym.core.action.base import AbstractActionSet
from browsergym.core.action.highlevel import HighLevelActionSet
from browsergym.core.action.python import PythonActionSet
from openhands.runtime.browser.browser_env import BrowserEnv
from .utils import (
from agenthub.browsing_agent.utils import (
ParseError,
parse_html_tags_raise,
)
from openhands.runtime.browser.browser_env import BrowserEnv
@dataclass

View File

@@ -1,5 +1,4 @@
from agenthub.codeact_agent.codeact_agent import CodeActAgent
from openhands.controller.agent import Agent
from .codeact_agent import CodeActAgent
Agent.register('CodeActAgent', CodeActAgent)

View File

@@ -1,5 +1,4 @@
from agenthub.codeact_swe_agent.codeact_swe_agent import CodeActSWEAgent
from openhands.controller.agent import Agent
from .codeact_swe_agent import CodeActSWEAgent
Agent.register('CodeActSWEAgent', CodeActSWEAgent)

View File

@@ -1,5 +1,4 @@
from agenthub.delegator_agent.agent import DelegatorAgent
from openhands.controller.agent import Agent
from .agent import DelegatorAgent
Agent.register('DelegatorAgent', DelegatorAgent)

View File

@@ -1,5 +1,4 @@
from agenthub.dummy_agent.agent import DummyAgent
from openhands.controller.agent import Agent
from .agent import DummyAgent
Agent.register('DummyAgent', DummyAgent)

View File

@@ -1,5 +1,7 @@
from jinja2 import BaseLoader, Environment
from agenthub.micro.instructions import instructions
from agenthub.micro.registry import all_microagents
from openhands.controller.agent import Agent
from openhands.controller.state.state import State
from openhands.core.config import AgentConfig
@@ -11,9 +13,6 @@ from openhands.events.serialization.event import event_to_memory
from openhands.llm.llm import LLM
from openhands.memory.history import ShortTermHistory
from .instructions import instructions
from .registry import all_microagents
def parse_response(orig_response: str) -> Action:
# attempt to load the JSON dict from the response

View File

@@ -1,5 +1,4 @@
from agenthub.planner_agent.agent import PlannerAgent
from openhands.controller.agent import Agent
from .agent import PlannerAgent
Agent.register('PlannerAgent', PlannerAgent)

View File

@@ -1,3 +1,4 @@
from agenthub.planner_agent.prompt import get_prompt_and_images
from agenthub.planner_agent.response_parser import PlannerResponseParser
from openhands.controller.agent import Agent
from openhands.controller.state.state import State
@@ -6,8 +7,6 @@ from openhands.core.message import ImageContent, Message, TextContent
from openhands.events.action import Action, AgentFinishAction
from openhands.llm.llm import LLM
from .prompt import get_prompt_and_images
class PlannerAgent(Agent):
VERSION = '1.0'

View File

@@ -1,6 +1,10 @@
from .base import Task
from .codegen import HumanEvalTask, MBPPTask
from .reasoning import MultipleChoiceTask, ReasoningTask, TheoremqaTask
from evaluation.mint.tasks.base import Task
from evaluation.mint.tasks.codegen import HumanEvalTask, MBPPTask
from evaluation.mint.tasks.reasoning import (
MultipleChoiceTask,
ReasoningTask,
TheoremqaTask,
)
__all__ = [
'Task',

View File

@@ -2,7 +2,7 @@ import logging
from utils import check_correctness
from .base import Task
from evaluation.mint.tasks.base import Task
LOGGER = logging.getLogger('MINT')

View File

@@ -1,4 +1,4 @@
from .agent_controller import AgentController
from openhands.controller.agent_controller import AgentController
__all__ = [
'AgentController',

View File

@@ -1,7 +1,7 @@
from .action import ActionType
from .agent import AgentState
from .config import ConfigType
from .observation import ObservationType
from openhands.core.schema.action import ActionType
from openhands.core.schema.agent import AgentState
from openhands.core.schema.config import ConfigType
from openhands.core.schema.observation import ObservationType
__all__ = [
'ActionType',

View File

@@ -1,3 +1,3 @@
from .singleton import Singleton
from openhands.core.utils.singleton import Singleton
__all__ = ['Singleton']

View File

@@ -1,5 +1,5 @@
from .event import Event, EventSource
from .stream import EventStream, EventStreamSubscriber
from openhands.events.event import Event, EventSource
from openhands.events.stream import EventStream, EventStreamSubscriber
__all__ = [
'Event',

View File

@@ -1,17 +1,17 @@
from .action import Action, ActionConfirmationStatus
from .agent import (
from openhands.events.action.action import Action, ActionConfirmationStatus
from openhands.events.action.agent import (
AgentDelegateAction,
AgentFinishAction,
AgentRejectAction,
AgentSummarizeAction,
ChangeAgentStateAction,
)
from .browse import BrowseInteractiveAction, BrowseURLAction
from .commands import CmdRunAction, IPythonRunCellAction
from .empty import NullAction
from .files import FileReadAction, FileWriteAction
from .message import MessageAction
from .tasks import AddTaskAction, ModifyTaskAction
from openhands.events.action.browse import BrowseInteractiveAction, BrowseURLAction
from openhands.events.action.commands import CmdRunAction, IPythonRunCellAction
from openhands.events.action.empty import NullAction
from openhands.events.action.files import FileReadAction, FileWriteAction
from openhands.events.action.message import MessageAction
from openhands.events.action.tasks import AddTaskAction, ModifyTaskAction
__all__ = [
'Action',

View File

@@ -2,8 +2,7 @@ from dataclasses import dataclass, field
from typing import Any
from openhands.core.schema import ActionType
from .action import Action
from openhands.events.action.action import Action
@dataclass

View File

@@ -2,8 +2,7 @@ from dataclasses import dataclass
from typing import ClassVar
from openhands.core.schema import ActionType
from .action import Action, ActionSecurityRisk
from openhands.events.action.action import Action, ActionSecurityRisk
@dataclass

View File

@@ -2,8 +2,11 @@ from dataclasses import dataclass
from typing import ClassVar
from openhands.core.schema import ActionType
from .action import Action, ActionConfirmationStatus, ActionSecurityRisk
from openhands.events.action.action import (
Action,
ActionConfirmationStatus,
ActionSecurityRisk,
)
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ActionType
from .action import Action
from openhands.events.action.action import Action
@dataclass

View File

@@ -2,8 +2,7 @@ from dataclasses import dataclass
from typing import ClassVar
from openhands.core.schema import ActionType
from .action import Action, ActionSecurityRisk
from openhands.events.action.action import Action, ActionSecurityRisk
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ActionType
from .action import Action, ActionSecurityRisk
from openhands.events.action.action import Action, ActionSecurityRisk
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass, field
from openhands.core.schema import ActionType
from .action import Action
from openhands.events.action.action import Action
@dataclass

View File

@@ -1,13 +1,16 @@
from .agent import AgentStateChangedObservation
from .browse import BrowserOutputObservation
from .commands import CmdOutputObservation, IPythonRunCellObservation
from .delegate import AgentDelegateObservation
from .empty import NullObservation
from .error import ErrorObservation
from .files import FileReadObservation, FileWriteObservation
from .observation import Observation
from .reject import UserRejectObservation
from .success import SuccessObservation
from openhands.events.observation.agent import AgentStateChangedObservation
from openhands.events.observation.browse import BrowserOutputObservation
from openhands.events.observation.commands import (
CmdOutputObservation,
IPythonRunCellObservation,
)
from openhands.events.observation.delegate import AgentDelegateObservation
from openhands.events.observation.empty import NullObservation
from openhands.events.observation.error import ErrorObservation
from openhands.events.observation.files import FileReadObservation, FileWriteObservation
from openhands.events.observation.observation import Observation
from openhands.events.observation.reject import UserRejectObservation
from openhands.events.observation.success import SuccessObservation
__all__ = [
'Observation',

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass, field
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,8 +1,7 @@
from dataclasses import dataclass
from openhands.core.schema import ObservationType
from .observation import Observation
from openhands.events.observation.observation import Observation
@dataclass

View File

@@ -1,12 +1,12 @@
from .action import (
from openhands.events.serialization.action import (
action_from_dict,
)
from .event import (
from openhands.events.serialization.event import (
event_from_dict,
event_to_dict,
event_to_memory,
)
from .observation import (
from openhands.events.serialization.observation import (
observation_from_dict,
)

View File

@@ -3,10 +3,9 @@ from datetime import datetime
from openhands.events import Event, EventSource
from openhands.events.observation.observation import Observation
from .action import action_from_dict
from .observation import observation_from_dict
from .utils import remove_fields
from openhands.events.serialization.action import action_from_dict
from openhands.events.serialization.observation import observation_from_dict
from openhands.events.serialization.utils import remove_fields
# TODO: move `content` into `extras`
TOP_KEYS = ['id', 'timestamp', 'source', 'message', 'cause', 'action', 'observation']

View File

@@ -6,11 +6,10 @@ from typing import Callable, Iterable
from openhands.core.logger import openhands_logger as logger
from openhands.core.utils import json
from openhands.events.event import Event, EventSource
from openhands.events.serialization.event import event_from_dict, event_to_dict
from openhands.storage import FileStore
from .event import Event, EventSource
class EventStreamSubscriber(str, Enum):
AGENT_CONTROLLER = 'agent_controller'

View File

@@ -1,5 +1,5 @@
from .condenser import MemoryCondenser
from .history import ShortTermHistory
from .memory import LongTermMemory
from openhands.memory.condenser import MemoryCondenser
from openhands.memory.history import ShortTermHistory
from openhands.memory.memory import LongTermMemory
__all__ = ['LongTermMemory', 'ShortTermHistory', 'MemoryCondenser']

View File

@@ -1,14 +1,14 @@
from .e2b.sandbox import E2BBox
from openhands.runtime.e2b.sandbox import E2BBox
def get_runtime_cls(name: str):
# Local imports to avoid circular imports
if name == 'eventstream':
from .client.runtime import EventStreamRuntime
from openhands.runtime.client.runtime import EventStreamRuntime
return EventStreamRuntime
elif name == 'e2b':
from .e2b.runtime import E2BRuntime
from openhands.runtime.e2b.runtime import E2BRuntime
return E2BRuntime
else:

View File

@@ -1,3 +1,3 @@
from .utils import browse
from openhands.runtime.browser.utils import browse
__all__ = ['browse']

View File

@@ -1,4 +1,4 @@
from .base import RuntimeBuilder
from .docker import DockerRuntimeBuilder
from openhands.runtime.builder.base import RuntimeBuilder
from openhands.runtime.builder.docker import DockerRuntimeBuilder
__all__ = ['RuntimeBuilder', 'DockerRuntimeBuilder']

View File

@@ -1,8 +1,7 @@
import docker
from openhands.core.logger import openhands_logger as logger
from .base import RuntimeBuilder
from openhands.runtime.builder.base import RuntimeBuilder
class DockerRuntimeBuilder(RuntimeBuilder):

View File

@@ -10,12 +10,11 @@ from openhands.events.observation import (
Observation,
)
from openhands.events.stream import EventStream
from openhands.runtime.e2b.filestore import E2BFileStore
from openhands.runtime.e2b.sandbox import E2BSandbox
from openhands.runtime.plugins import PluginRequirement
from openhands.runtime.runtime import Runtime
from ..utils.files import insert_lines, read_lines
from .filestore import E2BFileStore
from .sandbox import E2BSandbox
from openhands.runtime.utils.files import insert_lines, read_lines
class E2BRuntime(Runtime):

View File

@@ -1,7 +1,10 @@
# Requirements
from .agent_skills import AgentSkillsPlugin, AgentSkillsRequirement
from .jupyter import JupyterPlugin, JupyterRequirement
from .requirement import Plugin, PluginRequirement
from openhands.runtime.plugins.agent_skills import (
AgentSkillsPlugin,
AgentSkillsRequirement,
)
from openhands.runtime.plugins.jupyter import JupyterPlugin, JupyterRequirement
from openhands.runtime.plugins.requirement import Plugin, PluginRequirement
__all__ = [
'Plugin',

View File

@@ -1,9 +1,8 @@
from dataclasses import dataclass
from openhands.runtime.plugins.agent_skills import agentskills
from openhands.runtime.plugins.requirement import Plugin, PluginRequirement
from . import agentskills
@dataclass
class AgentSkillsRequirement(PluginRequirement):

View File

@@ -1,7 +1,7 @@
from inspect import signature
from . import file_ops, file_reader
from .utils.dependency import import_functions
from openhands.runtime.plugins.agent_skills import file_ops, file_reader
from openhands.runtime.plugins.agent_skills.utils.dependency import import_functions
import_functions(
module=file_ops, function_names=file_ops.__all__, target_globals=globals()

View File

@@ -1,5 +1,5 @@
from ..utils.dependency import import_functions
from . import file_ops
from openhands.runtime.plugins.agent_skills.file_ops import file_ops
from openhands.runtime.plugins.agent_skills.utils.dependency import import_functions
import_functions(
module=file_ops, function_names=file_ops.__all__, target_globals=globals()

View File

@@ -24,7 +24,7 @@ import tempfile
if __package__ is None or __package__ == '':
from aider import Linter
else:
from ..utils.aider import Linter
from openhands.runtime.plugins.agent_skills.utils.aider import Linter
CURRENT_FILE: str | None = None
CURRENT_LINE = 1

View File

@@ -1,5 +1,5 @@
from ..utils.dependency import import_functions
from . import file_readers
from openhands.runtime.plugins.agent_skills.file_reader import file_readers
from openhands.runtime.plugins.agent_skills.utils.dependency import import_functions
import_functions(
module=file_readers, function_names=file_readers.__all__, target_globals=globals()

View File

@@ -25,7 +25,7 @@ import PyPDF2
from pptx import Presentation
from pylatexenc.latex2text import LatexNodes2Text
from ..utils.config import (
from openhands.runtime.plugins.agent_skills.utils.config import (
_get_max_token,
_get_openai_api_key,
_get_openai_base_url,

View File

@@ -1,6 +1,9 @@
if __package__ is None or __package__ == '':
from linter import Linter, LintResult
else:
from .linter import Linter, LintResult
from openhands.runtime.plugins.agent_skills.utils.aider.linter import (
Linter,
LintResult,
)
__all__ = ['Linter', 'LintResult']

View File

@@ -5,11 +5,10 @@ from dataclasses import dataclass
from openhands.core.logger import openhands_logger as logger
from openhands.events.action import Action, IPythonRunCellAction
from openhands.events.observation import IPythonRunCellObservation
from openhands.runtime.plugins.jupyter.execute_server import JupyterKernel
from openhands.runtime.plugins.requirement import Plugin, PluginRequirement
from openhands.runtime.utils import find_available_tcp_port
from .execute_server import JupyterKernel
@dataclass
class JupyterRequirement(PluginRequirement):

View File

@@ -1,4 +1,4 @@
from .bash import split_bash_commands
from .system import find_available_tcp_port
from openhands.runtime.utils.bash import split_bash_commands
from openhands.runtime.utils.system import find_available_tcp_port
__all__ = ['find_available_tcp_port', 'split_bash_commands']

View File

@@ -1,5 +1,5 @@
from .analyzer import SecurityAnalyzer
from .invariant.analyzer import InvariantAnalyzer
from openhands.security.analyzer import SecurityAnalyzer
from openhands.security.invariant.analyzer import InvariantAnalyzer
__all__ = [
'SecurityAnalyzer',

View File

@@ -1,4 +1,4 @@
from .analyzer import InvariantAnalyzer
from openhands.security.invariant.analyzer import InvariantAnalyzer
__all__ = [
'InvariantAnalyzer',

View File

@@ -1,3 +1,3 @@
from .auth import get_sid_from_token, sign_token
from openhands.server.auth.auth import get_sid_from_token, sign_token
__all__ = ['get_sid_from_token', 'sign_token']

View File

@@ -1,4 +1,4 @@
from .manager import SessionManager
from .session import Session
from openhands.server.session.manager import SessionManager
from openhands.server.session.session import Session
__all__ = ['Session', 'SessionManager']

View File

@@ -5,10 +5,9 @@ from fastapi import WebSocket
from openhands.core.config import AppConfig
from openhands.core.logger import openhands_logger as logger
from openhands.server.session.session import Session
from openhands.storage.files import FileStore
from .session import Session
class SessionManager:
_sessions: dict[str, Session] = {}

View File

@@ -20,10 +20,9 @@ from openhands.events.observation import (
from openhands.events.serialization import event_from_dict, event_to_dict
from openhands.events.stream import EventStreamSubscriber
from openhands.llm.llm import LLM
from openhands.server.session.agent import AgentSession
from openhands.storage.files import FileStore
from .agent import AgentSession
DEL_DELT_SEC = 60 * 60 * 5

View File

@@ -1,7 +1,7 @@
from .files import FileStore
from .local import LocalFileStore
from .memory import InMemoryFileStore
from .s3 import S3FileStore
from openhands.storage.files import FileStore
from openhands.storage.local import LocalFileStore
from openhands.storage.memory import InMemoryFileStore
from openhands.storage.s3 import S3FileStore
def get_file_store(file_store: str, file_store_path: str | None = None) -> FileStore:

View File

@@ -2,8 +2,7 @@ import os
import shutil
from openhands.core.logger import openhands_logger as logger
from .files import FileStore
from openhands.storage.files import FileStore
class LocalFileStore(FileStore):

View File

@@ -1,8 +1,7 @@
import os
from openhands.core.logger import openhands_logger as logger
from .files import FileStore
from openhands.storage.files import FileStore
class InMemoryFileStore(FileStore):

View File

@@ -2,7 +2,7 @@ import os
from minio import Minio
from .files import FileStore
from openhands.storage.files import FileStore
AWS_S3_ENDPOINT = 's3.amazonaws.com'