refac
This commit is contained in:
@@ -217,9 +217,7 @@ async def load_tool_module_by_id(tool_id, content=None):
|
||||
# Install required packages found within the frontmatter.
|
||||
# Runs `pip install` via subprocess, which can take a long time;
|
||||
# offload to a thread so it doesn't block the event loop.
|
||||
await asyncio.to_thread(
|
||||
install_frontmatter_requirements, frontmatter.get('requirements', '')
|
||||
)
|
||||
await asyncio.to_thread(install_frontmatter_requirements, frontmatter.get('requirements', ''))
|
||||
|
||||
module_name = f'tool_{tool_id}'
|
||||
module = types.ModuleType(module_name)
|
||||
@@ -264,9 +262,7 @@ async def load_function_module_by_id(function_id: str, content: str | None = Non
|
||||
else:
|
||||
frontmatter = extract_frontmatter(content)
|
||||
# `pip install` via subprocess can block for a long time; offload it.
|
||||
await asyncio.to_thread(
|
||||
install_frontmatter_requirements, frontmatter.get('requirements', '')
|
||||
)
|
||||
await asyncio.to_thread(install_frontmatter_requirements, frontmatter.get('requirements', ''))
|
||||
|
||||
module_name = f'function_{function_id}'
|
||||
module = types.ModuleType(module_name)
|
||||
@@ -468,8 +464,6 @@ async def install_tool_and_function_dependencies():
|
||||
all_dependencies += f'{dependencies}, '
|
||||
|
||||
# `pip install` via subprocess can block for a long time; offload it.
|
||||
await asyncio.to_thread(
|
||||
install_frontmatter_requirements, all_dependencies.strip(', ')
|
||||
)
|
||||
await asyncio.to_thread(install_frontmatter_requirements, all_dependencies.strip(', '))
|
||||
except Exception as e:
|
||||
log.error(f'Error installing requirements: {e}')
|
||||
|
||||
Reference in New Issue
Block a user