You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added configurable batching for figure uploads via VM_FIGURE_MAX_BATCH_SIZE environment variable (defaults to 20 figures per batch)
Made API request timeout configurable via VM_API_TIMEOUT environment variable (defaults to 30 seconds)
Why
Test results with many figures (e.g., 20+ plots) could cause depending on the network environment timeouts issues when uploaded simultaneously. Batching prevents overwhelming the API.
Sequential batch processing with concurrent uploads within each batch provides a balance between speed and stability, reducing failed uploads due to resource constraints.
Configurable timeout and batch size allow users to adjust based on their network conditions without code changes.
How to test
Add the following code before importing validmind:
import os
os.environ["LOG_LEVEL"] = "DEBUG"
To reproduce a timeout error, set VM_API_TIMEOUT=5 in your .env and run the application_scorecard_full_suite.ipynb notebook.
To check the effect of batch processing, set VM_API_TIMEOUT=5 and VM_FIGURE_MAX_BATCH_SIZE=2 to avoid timeout errors.
What needs special review?
Dependencies, breaking changes, and deployment notes
Release notes
Checklist
What and why
Screenshots or videos (Frontend)
How to test
What needs special review
Dependencies, breaking changes, and deployment notes
This PR introduces several functional improvements related to API logging and figure upload processing in the project. The key changes include:
In the API client, the HTTP client timeout is now configurable via an environment variable (VM_API_TIMEOUT) instead of being hardcoded to 30 seconds. This allows dynamic adjustment of API call timeouts without code changes.
A new decorator, log_api_operation, has been implemented in the logging module. This decorator enables function-level logging for API operations. It logs the operation (using a provided operation name or the function name) and supports the extraction of a key from the function arguments for more informative logs. The decorator activates only if the logging level is set to DEBUG (unless forced), aiming to reduce unnecessary logging in production.
In the result module, the processing of figure uploads has been enhanced by breaking the figures into configurable batches. The batch size is determined by the environment variable (VM_FIGURE_MAX_BATCH_SIZE) with a default of 20, which allows better control over resource usage during the upload process. Each batch upload is wrapped with the new log_api_operation decorator to track the operation.
Overall, the changes aim to provide more flexibility and transparency in API operations and improve the handling of batch uploads for figures.
Test Suggestions
Verify that the API client session timeout correctly reads the value from the VM_API_TIMEOUT environment variable and falls back to 30 when not set.
Test the log_api_operation decorator to ensure it logs the operation name and extracted key correctly, particularly when the logger is in DEBUG mode.
Create tests for the alog_figure function to ensure that it is properly wrapped by log_api_operation and logs as expected.
Simulate different sizes of the figures list to confirm that batching works correctly with the batch size determined by VM_FIGURE_MAX_BATCH_SIZE.
Run tests with different log levels to ensure that the logging behavior changes appropriately when not in DEBUG mode.
juanmleng
deleted the
juan/sc-11676/improve-api-timeout-support-to-prevent-timeouts-with-large-datasets
branch
August 8, 2025 07:58
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Description
What and why?
What
VM_FIGURE_MAX_BATCH_SIZEenvironment variable (defaults to 20 figures per batch)VM_API_TIMEOUTenvironment variable (defaults to 30 seconds)Why
How to test
validmind:VM_API_TIMEOUT=5in your.envand run theapplication_scorecard_full_suite.ipynbnotebook.VM_API_TIMEOUT=5andVM_FIGURE_MAX_BATCH_SIZE=2to avoid timeout errors.What needs special review?
Dependencies, breaking changes, and deployment notes
Release notes
Checklist