ref: Make check_langflow_version async (#4701)
Make check_langflow_version async
This commit is contained in:
parent
67a9fff581
commit
1b39ce6f6e
3 changed files with 7 additions and 7 deletions
|
|
@ -100,7 +100,7 @@ def get_is_component_from_data(data: dict):
|
|||
return data.get("is_component")
|
||||
|
||||
|
||||
def check_langflow_version(component: StoreComponentCreate) -> None:
|
||||
async def check_langflow_version(component: StoreComponentCreate) -> None:
|
||||
from langflow.utils.version import get_version_info
|
||||
|
||||
__version__ = get_version_info()["version"]
|
||||
|
|
@ -108,7 +108,7 @@ def check_langflow_version(component: StoreComponentCreate) -> None:
|
|||
if not component.last_tested_version:
|
||||
component.last_tested_version = __version__
|
||||
|
||||
langflow_version = get_lf_version_from_pypi()
|
||||
langflow_version = await get_lf_version_from_pypi()
|
||||
if langflow_version is None:
|
||||
raise HTTPException(status_code=500, detail="Unable to verify the latest version of Langflow")
|
||||
if langflow_version != component.last_tested_version:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import asyncio
|
||||
from typing import Annotated
|
||||
from uuid import UUID
|
||||
|
||||
|
|
@ -68,7 +67,7 @@ async def share_component(
|
|||
store_api_key: Annotated[str, Depends(get_user_store_api_key)],
|
||||
) -> CreateComponentResponse:
|
||||
try:
|
||||
await asyncio.to_thread(check_langflow_version, component)
|
||||
await check_langflow_version(component)
|
||||
return await get_store_service().upload(store_api_key, component)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
|
@ -81,7 +80,7 @@ async def update_shared_component(
|
|||
store_api_key: Annotated[str, Depends(get_user_store_api_key)],
|
||||
) -> CreateComponentResponse:
|
||||
try:
|
||||
await asyncio.to_thread(check_langflow_version, component)
|
||||
await check_langflow_version(component)
|
||||
return await get_store_service().update(store_api_key, component_id, component)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
|
|
|||
|
|
@ -41,9 +41,10 @@ async def update_components_with_user_data(
|
|||
|
||||
|
||||
# Get the latest released version of langflow (https://pypi.org/project/langflow/)
|
||||
def get_lf_version_from_pypi():
|
||||
async def get_lf_version_from_pypi():
|
||||
try:
|
||||
response = httpx.get("https://pypi.org/pypi/langflow/json")
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = client.get("https://pypi.org/pypi/langflow/json")
|
||||
if response.status_code != httpx.codes.OK:
|
||||
return None
|
||||
return response.json()["info"]["version"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue