fix: Refactor file reading and async task creation, fix return type in vertex_builds model (#4273)
This commit is contained in:
parent
80db2b92d2
commit
fab2d9afb3
3 changed files with 13 additions and 12 deletions
|
|
@ -329,7 +329,7 @@ async def build_flow(
|
||||||
client_consumed_queue: asyncio.Queue,
|
client_consumed_queue: asyncio.Queue,
|
||||||
event_manager: EventManager,
|
event_manager: EventManager,
|
||||||
) -> None:
|
) -> None:
|
||||||
build_task = asyncio.create_task(asyncio.to_thread(asyncio.run, _build_vertex(vertex_id, graph, event_manager)))
|
build_task = asyncio.create_task(_build_vertex(vertex_id, graph, event_manager))
|
||||||
try:
|
try:
|
||||||
await build_task
|
await build_task
|
||||||
except asyncio.CancelledError as exc:
|
except asyncio.CancelledError as exc:
|
||||||
|
|
@ -361,8 +361,8 @@ async def build_flow(
|
||||||
|
|
||||||
async def event_generator(event_manager: EventManager, client_consumed_queue: asyncio.Queue) -> None:
|
async def event_generator(event_manager: EventManager, client_consumed_queue: asyncio.Queue) -> None:
|
||||||
if not data:
|
if not data:
|
||||||
# using another thread since the DB query is I/O bound
|
# using another task since the build_graph_and_get_order is now an async function
|
||||||
vertices_task = asyncio.create_task(asyncio.to_thread(asyncio.run, build_graph_and_get_order()))
|
vertices_task = asyncio.create_task(build_graph_and_get_order())
|
||||||
try:
|
try:
|
||||||
await vertices_task
|
await vertices_task
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,10 @@ class DirectoryReader:
|
||||||
_file_path = Path(file_path)
|
_file_path = Path(file_path)
|
||||||
if not _file_path.is_file():
|
if not _file_path.is_file():
|
||||||
return None
|
return None
|
||||||
with _file_path.open(encoding="utf-8") as file:
|
|
||||||
# UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3069: character maps to <undefined>
|
|
||||||
try:
|
try:
|
||||||
|
with _file_path.open(encoding="utf-8") as file:
|
||||||
|
# UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 3069:
|
||||||
|
# character maps to <undefined>
|
||||||
return file.read()
|
return file.read()
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
# This is happening in Windows, so we need to open the file in binary mode
|
# This is happening in Windows, so we need to open the file in binary mode
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class VertexBuildBase(SQLModel):
|
||||||
return truncate_long_strings(data)
|
return truncate_long_strings(data)
|
||||||
|
|
||||||
@field_serializer("params")
|
@field_serializer("params")
|
||||||
def serialize_params(self, data) -> dict:
|
def serialize_params(self, data) -> str:
|
||||||
return truncate_long_strings(data)
|
return truncate_long_strings(data)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue