Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: implement pagination for transaction log queries #5281

Merged
merged 12 commits into from
Dec 16, 2024

Conversation

dhlidongming
Copy link
Contributor

This PR introduces pagination to the transactions log using fastapi-pagination on the backend and PaginatorComponent on the frontend.
These changes aim to enhance retrieval speed, reduce memory consumption, and prevent potential lags during frequent debugging sessions.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Dec 16, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
Copy link

codspeed-hq bot commented Dec 16, 2024

CodSpeed Performance Report

Merging #5281 will degrade performances by 45.18%

Comparing dhlidongming:add-transaction-pagination (7bdd67d) with main (4736aae)

Summary

⚡ 2 improvements
❌ 1 regressions
✅ 12 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main dhlidongming:add-transaction-pagination Change
test_setup_llm_caching 1.2 ms 2.2 ms -45.18%
test_successful_run_with_input_type_any 331.1 ms 273.5 ms +21.05%
test_successful_run_with_output_type_any 279.5 ms 239.1 ms +16.86%

Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dhlidongming

Are you using the Transactions table in your developments?

Comment on lines 22 to 52
const {
data: TransactionData,
isLoading,
refetch,
} = useGetTransactionsQuery({
id: currentFlowId,
params: {
page: pageIndex,
size: pageSize,
},
mode: "union",
});

const data = {
rows: TransactionData?.rows ?? [],
columns: TransactionData?.columns ?? [],
pagination: {
page: TransactionData?.pagination?.page ?? 1,
size: TransactionData?.pagination?.size ?? 10,
total: TransactionData?.pagination?.total ?? 0,
pages: TransactionData?.pagination?.pages ?? 0,
},
};

useEffect(() => {
if (data) {
if (TransactionData) {
const { columns, rows } = data;
setColumns(columns.map((col) => ({ ...col, editable: true })));
setRows(rows);
}
if (open) refetch();
}, [data, open, isLoading]);
}, [TransactionData]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the variables named TransactionData be data instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogabrielluiz Thank you for pointing that out.I have removed the redundant TransactionData variable and updated the code accordingly.

@dhlidongming
Copy link
Contributor Author

@ogabrielluiz Yes, we need to use the Transactions table to view the execution logs of various components to determine if the Agent is running correctly.
Recently, we found that when a certain flow is executed frequently, the Logs page opens very slowly and consumes a lot of browser memory because pagination was not implemented for the queries.

Hey @dhlidongming

Are you using the Transactions table in your developments?

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 16, 2024
@ogabrielluiz ogabrielluiz force-pushed the add-transaction-pagination branch from 0611411 to 8c32ef1 Compare December 16, 2024 18:16
@ogabrielluiz ogabrielluiz enabled auto-merge (squash) December 16, 2024 18:16
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
@ogabrielluiz
Copy link
Contributor

@ogabrielluiz Yes, we need to use the Transactions table to view the execution logs of various components to determine if the Agent is running correctly. Recently, we found that when a certain flow is executed frequently, the Logs page opens very slowly and consumes a lot of browser memory because pagination was not implemented for the queries.

Hey @dhlidongming
Are you using the Transactions table in your developments?

That's good to know. We are planning on improving logs and stuff like that. We'll use this PR as an example that people are still using the transactions.

Thanks @dhlidongming !

@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
dhlidongming and others added 12 commits December 16, 2024 17:51
… check for 'items' in JSON response instead of direct equality to an empty list.
- Updated TransactionReadResponse to use 'id' as an alias for 'transaction_id'.
- Introduced a new function, transform_transaction_table, to convert TransactionTable instances to TransactionReadResponse, supporting both single and list inputs.
- Improved import structure for better readability in crud.py.
…ion retrieval

- Updated the get_transactions function to utilize the new transform_transaction_table function, enhancing the transformation of TransactionTable instances during pagination.
- Improved the import structure by adding the necessary import for transform_transaction_table.
…eval

- Added 'params' to VertexTuple for better clarity in transaction logging.
- Modified assertions in test_delete_folder_with_flows_with_transaction_and_build to check for 'items' in the JSON response instead of direct equality to an empty list, ensuring more accurate test validation.
- Integrated fastapi_pagination into the main application by adding the add_pagination function to the FastAPI instance.
- Removed the redundant add_pagination call from the flows module to streamline the pagination setup.
@ogabrielluiz ogabrielluiz force-pushed the add-transaction-pagination branch from ff280e1 to 7bdd67d Compare December 16, 2024 20:51
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 16, 2024
@ogabrielluiz ogabrielluiz merged commit 1ec6380 into langflow-ai:main Dec 16, 2024
36 checks passed
@dhlidongming dhlidongming deleted the add-transaction-pagination branch December 17, 2024 02:12
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants