mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
Fix linear-related mypy type errors and make Manager.start_job async (#13189)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -318,7 +318,7 @@ class GithubManager(Manager[GithubViewType]):
|
|||||||
logger.warning('Unsupported location')
|
logger.warning('Unsupported location')
|
||||||
return
|
return
|
||||||
|
|
||||||
async def start_job(self, github_view: GithubViewType):
|
async def start_job(self, github_view: GithubViewType) -> None:
|
||||||
"""Kick off a job with openhands agent.
|
"""Kick off a job with openhands agent.
|
||||||
|
|
||||||
1. Get user credential
|
1. Get user credential
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ class GitlabManager(Manager[GitlabViewType]):
|
|||||||
f'[GitLab] Unsupported view type: {type(gitlab_view).__name__}'
|
f'[GitLab] Unsupported view type: {type(gitlab_view).__name__}'
|
||||||
)
|
)
|
||||||
|
|
||||||
async def start_job(self, gitlab_view: GitlabViewType):
|
async def start_job(self, gitlab_view: GitlabViewType) -> None:
|
||||||
"""
|
"""
|
||||||
Start a job for the GitLab view.
|
Start a job for the GitLab view.
|
||||||
|
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ class JiraManager(Manager[JiraViewInterface]):
|
|||||||
|
|
||||||
return jira_user, saas_user_auth
|
return jira_user, saas_user_auth
|
||||||
|
|
||||||
async def start_job(self, view: JiraViewInterface):
|
async def start_job(self, view: JiraViewInterface) -> None:
|
||||||
"""Start a Jira job/conversation."""
|
"""Start a Jira job/conversation."""
|
||||||
# Import here to prevent circular import
|
# Import here to prevent circular import
|
||||||
from server.conversation_callback_processor.jira_callback_processor import (
|
from server.conversation_callback_processor.jira_callback_processor import (
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ class JiraDcManager(Manager[JiraDcViewInterface]):
|
|||||||
logger.error(f'[Jira DC] Error in is_job_requested: {str(e)}')
|
logger.error(f'[Jira DC] Error in is_job_requested: {str(e)}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def start_job(self, jira_dc_view: JiraDcViewInterface):
|
async def start_job(self, jira_dc_view: JiraDcViewInterface) -> None:
|
||||||
"""Start a Jira DC job/conversation."""
|
"""Start a Jira DC job/conversation."""
|
||||||
# Import here to prevent circular import
|
# Import here to prevent circular import
|
||||||
from server.conversation_callback_processor.jira_dc_callback_processor import (
|
from server.conversation_callback_processor.jira_dc_callback_processor import (
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ class LinearManager(Manager[LinearViewInterface]):
|
|||||||
logger.error(f'[Linear] Error in is_job_requested: {str(e)}')
|
logger.error(f'[Linear] Error in is_job_requested: {str(e)}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def start_job(self, linear_view: LinearViewInterface):
|
async def start_job(self, linear_view: LinearViewInterface) -> None:
|
||||||
"""Start a Linear job/conversation."""
|
"""Start a Linear job/conversation."""
|
||||||
# Import here to prevent circular import
|
# Import here to prevent circular import
|
||||||
from server.conversation_callback_processor.linear_callback_processor import (
|
from server.conversation_callback_processor.linear_callback_processor import (
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ class LinearExistingConversationView(LinearViewInterface):
|
|||||||
self.conversation_id, conversation_init_data, user_id
|
self.conversation_id, conversation_init_data, user_id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if agent_loop_info.event_store is None:
|
||||||
|
raise StartingConvoException('Event store not available')
|
||||||
|
|
||||||
final_agent_observation = get_final_agent_observation(
|
final_agent_observation = get_final_agent_observation(
|
||||||
agent_loop_info.event_store
|
agent_loop_info.event_store
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Manager(ABC, Generic[ViewT]):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def start_job(self, view: ViewT) -> None:
|
async def start_job(self, view: ViewT) -> None:
|
||||||
"""Kick off a job with openhands agent.
|
"""Kick off a job with openhands agent.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ class SlackManager(Manager[SlackViewInterface]):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def start_job(self, slack_view: SlackViewInterface):
|
async def start_job(self, slack_view: SlackViewInterface) -> None:
|
||||||
# Importing here prevents circular import
|
# Importing here prevents circular import
|
||||||
from server.conversation_callback_processor.slack_callback_processor import (
|
from server.conversation_callback_processor.slack_callback_processor import (
|
||||||
SlackCallbackProcessor,
|
SlackCallbackProcessor,
|
||||||
|
|||||||
@@ -523,6 +523,11 @@ async def get_current_workspace_link(request: Request):
|
|||||||
try:
|
try:
|
||||||
user_auth = cast(SaasUserAuth, await get_user_auth(request))
|
user_auth = cast(SaasUserAuth, await get_user_auth(request))
|
||||||
user_id = await user_auth.get_user_id()
|
user_id = await user_auth.get_user_id()
|
||||||
|
if not user_id:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail='User not authenticated',
|
||||||
|
)
|
||||||
|
|
||||||
user = await linear_manager.integration_store.get_user_by_active_workspace(
|
user = await linear_manager.integration_store.get_user_by_active_workspace(
|
||||||
user_id
|
user_id
|
||||||
@@ -576,6 +581,11 @@ async def unlink_workspace(request: Request):
|
|||||||
try:
|
try:
|
||||||
user_auth = cast(SaasUserAuth, await get_user_auth(request))
|
user_auth = cast(SaasUserAuth, await get_user_auth(request))
|
||||||
user_id = await user_auth.get_user_id()
|
user_id = await user_auth.get_user_id()
|
||||||
|
if not user_id:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||||
|
detail='User not authenticated',
|
||||||
|
)
|
||||||
|
|
||||||
user = await linear_manager.integration_store.get_user_by_active_workspace(
|
user = await linear_manager.integration_store.get_user_by_active_workspace(
|
||||||
user_id
|
user_id
|
||||||
|
|||||||
Reference in New Issue
Block a user