-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #989 from julep-ai/f/migrate-workflows-to-pg
feat(agents-api): migrate workflows to pg
- Loading branch information
Showing
96 changed files
with
215 additions
and
7,343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ | |
|
||
with workflow.unsafe.imports_passed_through(): | ||
import msgpack as msgpack | ||
|
||
import os |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
agents-api/agents_api/activities/task_steps/cozo_query_step.py
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
agents-api/agents_api/activities/task_steps/pg_query_step.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Any | ||
|
||
from async_lru import alru_cache | ||
from beartype import beartype | ||
from temporalio import activity | ||
|
||
from ... import queries | ||
from ...clients.pg import create_db_pool | ||
from ...env import pg_dsn, testing | ||
|
||
|
||
@alru_cache(maxsize=1) | ||
async def get_db_pool(dsn: str): | ||
return await create_db_pool(dsn=dsn) | ||
|
||
|
||
@beartype | ||
async def pg_query_step( | ||
query_name: str, | ||
values: dict[str, Any], | ||
dsn: str = pg_dsn, | ||
) -> Any: | ||
pool = await get_db_pool(dsn=dsn) | ||
|
||
(module_name, name) = query_name.split(".") | ||
|
||
module = getattr(queries, module_name) | ||
query = getattr(module, name) | ||
return await query(**values, connection_pool=pool) | ||
|
||
|
||
# Note: This is here just for clarity. We could have just imported pg_query_step directly | ||
# They do the same thing, so we dont need to mock the pg_query_step function | ||
mock_pg_query_step = pg_query_step | ||
|
||
pg_query_step = activity.defn(name="pg_query_step")( | ||
pg_query_step if not testing else mock_pg_query_step | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.