Implementation:Datahub project Datahub Pytest Test Weights
| Knowledge Sources | |
|---|---|
| Domains | Testing |
| Last Updated | 2026-02-10 00:00 GMT |
Overview
A JSON data file containing measured execution durations for DataHub smoke test cases, used by the test batching system in conftest.py to distribute tests across CI workers with approximately equal total runtime.
Description
pytest_test_weights.json is a JSON array of objects, each containing:
testId-- A dotted test identifier in the formatmodule.path::test_function_name(e.g.,tests.knowledge.document_test::test_search_documents_with_filters)duration-- The measured test duration as a string with an "s" suffix (e.g.,"99.941s")
The file contains approximately 1502 lines covering all smoke test cases. Tests are sorted by duration in descending order, with the slowest tests first. The slowest tests include:
| Test | Duration |
|---|---|
test_search_across_entities_filters_documents |
99.941s |
test_openapi_all |
94.862s |
test_search_documents_with_filters |
91.213s |
test_col_col_propagation_large_fanout |
88.077s |
test_update_schemafield |
84.800s |
The load_pytest_test_weights() function in conftest.py reads this file and converts it to a dictionary mapping test IDs to float durations (stripping the "s" suffix). These weights feed into the bin_pack_tasks() algorithm to create balanced batches at the module level.
Usage
This file is consumed automatically by the smoke test batching system when BATCH_COUNT > 1. It should be periodically updated with fresh timing data from CI runs. If the file is missing or cannot be read, the system defaults all test weights to 1.0 (equal weight).
Code Reference
Source Location
- Repository: Datahub_project_Datahub
- File: smoke-test/pytest_test_weights.json
Signature
[
{
"testId": "tests.knowledge.document_search_filter_test::test_search_across_entities_filters_documents",
"duration": "99.941s"
},
{
"testId": "tests.openapi.test_openapi::test_openapi_all",
"duration": "94.862s"
}
// ... additional entries
]
Import
# Loaded via conftest.py
from conftest import load_pytest_test_weights
weights = load_pytest_test_weights()
# Returns: {"tests.knowledge.document_test::test_search_documents_with_filters": 91.213, ...}
I/O Contract
| Input | Type | Description |
|---|---|---|
| (none -- this is a data file) | Read by load_pytest_test_weights() in conftest.py
|
| Output | Type | Description |
|---|---|---|
| Test weight dictionary | Dict[str, float] |
Maps test ID strings to duration in seconds |
Usage Examples
# Loading weights programmatically
import json
from pathlib import Path
weights_file = Path("smoke-test/pytest_test_weights.json")
with open(weights_file) as f:
weights_data = json.load(f)
# Convert to dict
test_weights = {
item["testId"]: float(item["duration"][:-1]) # Strip 's' suffix
for item in weights_data
}
# Use in bin-packing
from conftest import bin_pack_tasks
batches = bin_pack_tasks(
[(test_id, weight) for test_id, weight in test_weights.items()],
n_buckets=4
)