bigdata-smart-batching 0.2.0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/.gitignore +5 -0
- bigdata_smart_batching-1.0.1/CHANGELOG.md +104 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/Makefile +7 -1
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/PKG-INFO +12 -9
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/README.md +11 -8
- bigdata_smart_batching-1.0.1/docs/smart-batching-architecture.md +481 -0
- bigdata_smart_batching-1.0.1/examples/example.py +118 -0
- bigdata_smart_batching-1.0.1/examples/example_overlapping.py +185 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/pyproject.toml +9 -1
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/src/bigdata_smart_batching/__init__.py +24 -4
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/src/bigdata_smart_batching/search_function.py +341 -66
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/src/bigdata_smart_batching/smart_batching.py +712 -716
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/src/bigdata_smart_batching/smart_batching_config.py +16 -12
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/tests/test_config.py +0 -7
- bigdata_smart_batching-1.0.1/tests/test_validation.py +180 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/uv.lock +1 -1
- bigdata_smart_batching-0.2.0/CHANGELOG.md +0 -28
- bigdata_smart_batching-0.2.0/docs/smart-batching-architecture.md +0 -387
- bigdata_smart_batching-0.2.0/examples/example.py +0 -76
- bigdata_smart_batching-0.2.0/tests/test_validation.py +0 -84
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/LICENSE +0 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/src/bigdata_smart_batching/output_converter.py +0 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/tests/__init__.py +0 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/tests/test_output_converter.py +0 -0
- {bigdata_smart_batching-0.2.0 → bigdata_smart_batching-1.0.1}/tests/test_rate_limiter.py +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.1] - 2026-04-17
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Republish on PyPI after an erroneous publish of v1.0.0; package contents match the intended release.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [1.0.0] - 2026-04-17
|
|
16
|
+
|
|
17
|
+
First stable release. Redesigns the batching pipeline so every API request stays
|
|
18
|
+
within service limits while keeping plans deterministic.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `create_entity_groups` step: sorts companies by chunks desc and greedy-packs
|
|
23
|
+
under `MAX_CHUNKS_PER_BASKET` and `MAX_ENTITIES_IN_ANY_OF`, honoring
|
|
24
|
+
`min_entities_per_basket`, with tail-group merge when it fits the entity
|
|
25
|
+
limit.
|
|
26
|
+
- Automatic splitting of co-mention volume queries into sub-ranges of up to 365
|
|
27
|
+
days, with per-company chunks summed across sub-ranges in both three-pass and
|
|
28
|
+
iterative modes. Iterative mode now fans out `(batch, sub-range)` work items
|
|
29
|
+
to the thread pool and derives `very_low` from companies never seen in any
|
|
30
|
+
sub-range.
|
|
31
|
+
- Parallel execution of `get_volume_timeseries` via `ThreadPoolExecutor`.
|
|
32
|
+
- `volume_bucket` metadata on every group/basket via `classify_volume_bucket`
|
|
33
|
+
and `majority_volume_bucket` (ties broken by `VOLUME_BUCKET_PRIORITY`).
|
|
34
|
+
- Centralized `VOLUME_BUCKETS` in `smart_batching_config` with explicit
|
|
35
|
+
`[lower, upper)` semantics and new `VOLUME_BUCKET_PRIORITY` constant.
|
|
36
|
+
- INCLUDE/EXCLUDE category filtering for planning and all Bigdata query paths
|
|
37
|
+
(co-mention, volume, search), validated against a fixed set of allowed
|
|
38
|
+
category strings. `CategoryFilter`, `CategoryMode`, and validators/builders
|
|
39
|
+
are exported from the package.
|
|
40
|
+
- Shared payload builders `build_comention_payload`, `build_volume_payload`,
|
|
41
|
+
and `build_search_query`, which `SmartBatchingPlanner` now routes through
|
|
42
|
+
instead of constructing payloads inline.
|
|
43
|
+
- `content_diversification` option in `ranking_params`, exposed on
|
|
44
|
+
`plan_search`.
|
|
45
|
+
- Universe input accepts either a CSV path or an inline list of entity IDs
|
|
46
|
+
(`universe: str | list[str]`). Added `resolve_universe()` and `UniverseInput`,
|
|
47
|
+
both exported from the package.
|
|
48
|
+
- `Makefile` test targets and coverage settings in `pyproject.toml`.
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- **Breaking:** `SmartBatchingPlanner` public API redesigned. `create_baskets`
|
|
53
|
+
is replaced by `create_entity_groups` (new signature:
|
|
54
|
+
`min_entities_per_group` instead of `max_chunks`/`min_entities_per_basket`);
|
|
55
|
+
returned dicts no longer include `basket_id` or `volume_range` and expose
|
|
56
|
+
`volume_bucket` instead.
|
|
57
|
+
- **Breaking:** Removed helpers `group_by_volume`,
|
|
58
|
+
`consolidate_period_groups`, `sub_period_volumes_from_series`, and
|
|
59
|
+
`get_volume_timeseries_per_company`.
|
|
60
|
+
- **Breaking:** `very_low` basket IDs are now
|
|
61
|
+
`basket_{n}_very_low_{start}_{end}` instead of `very_low_basket_{n}`;
|
|
62
|
+
downstream parsers must be updated.
|
|
63
|
+
- **Breaking:** `VOLUME_BUCKETS` ranges are now enforced as `[lower, upper)`.
|
|
64
|
+
- **Breaking:** `plan_search(..., universe_csv_path=)` renamed to
|
|
65
|
+
`universe=` (accepts `str | list[str]`). `SmartBatchingPlanner.load_universe`
|
|
66
|
+
and `plan_all_periods` now take a required `universe` argument and delegate
|
|
67
|
+
to `resolve_universe`; `UNIVERSE_CSV_PATH` and duplicate CSV parsing removed.
|
|
68
|
+
- **Breaking:** `plan_search` / `plan_all_periods` now accept an optional
|
|
69
|
+
`text` parameter and parameter order has been reordered.
|
|
70
|
+
- Entity filters now use `search_in=BODY` for co-mention and volume payloads;
|
|
71
|
+
`ranking_params` dropped from the volume query.
|
|
72
|
+
- Omit `text` from co-mention, volume, and search payloads when topic/text is
|
|
73
|
+
`None`.
|
|
74
|
+
- Planned baskets are sorted by `basket_id` for stable ordering.
|
|
75
|
+
- Architecture documentation updated to reflect the new `plan_search` flow
|
|
76
|
+
(sub-range splitting, entity groups, pre-fetch only for heavy groups, one
|
|
77
|
+
basket per `(group, sub-period)`) and a new high-level flow diagram.
|
|
78
|
+
- `load_universe_from_csv` rejects empty CSV paths.
|
|
79
|
+
|
|
80
|
+
### Removed
|
|
81
|
+
|
|
82
|
+
- Obsolete `VOLUME_BUCKETS` structure test.
|
|
83
|
+
|
|
84
|
+
## [0.2.0] - 2026-04-14
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
|
|
88
|
+
- **Breaking:** `plan_search` now returns `chunk_upper_bound_estimate` instead of `total_expected_chunks`. Callers, saved plans, and any code reading the plan dict must use the new key. `execute_search` reads `chunk_upper_bound_estimate` when deriving sampling from the plan.
|
|
89
|
+
- Terminology and docs describe this value as a chunk upper bound estimate (module docstring, README, architecture diagram, and example output).
|
|
90
|
+
- README installation: document PyPI consumption (`pip install bigdata-smart-batching`, `uv add bigdata-smart-batching`) and keep a separate **Development** section for cloning the repo and `uv sync`.
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
|
|
94
|
+
- Align `uv.lock` `requires-python` with `pyproject.toml` (`>=3.11,<4.0`).
|
|
95
|
+
|
|
96
|
+
## [0.1.0] - 2026-04-14
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
|
|
100
|
+
- Initial release of **bigdata-smart-batching**: high-performance semantic search with intelligent company grouping and parallel execution.
|
|
101
|
+
- Planning API (`plan_search`) to organize searches via smart batching and report expected chunk counts.
|
|
102
|
+
- Execution API (`execute_search`) with rate-limited parallel requests and proportional sampling to preserve result distribution.
|
|
103
|
+
- Utilities: document deduplication, DataFrame conversion, and configurable search/batching behavior via `smart_batching` and related modules.
|
|
104
|
+
- Python 3.11+ support; dependencies include `requests`, `pandas`, `numpy`, `matplotlib`, and `python-dotenv`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.PHONY: lint lint-check format format-check
|
|
1
|
+
.PHONY: lint lint-check format format-check test test-cov
|
|
2
2
|
|
|
3
3
|
lint:
|
|
4
4
|
uvx ruff check --fix src/ tests/
|
|
@@ -11,3 +11,9 @@ format:
|
|
|
11
11
|
|
|
12
12
|
format-check:
|
|
13
13
|
uvx ruff format --check src/ tests/
|
|
14
|
+
|
|
15
|
+
test:
|
|
16
|
+
uv run pytest
|
|
17
|
+
|
|
18
|
+
test-cov:
|
|
19
|
+
uv run pytest --cov --cov-report=term-missing --cov-report=html
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bigdata-smart-batching
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: High-performance semantic search with intelligent company grouping and parallel execution
|
|
5
5
|
Project-URL: homepage, https://bigdata.com/api
|
|
6
6
|
Author-email: "Bigdata.com" <support@ravenpack.com>
|
|
@@ -68,9 +68,11 @@ BIGDATA_API_KEY=your_api_key_here
|
|
|
68
68
|
BIGDATA_API_BASE_URL=https://api.bigdata.com
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
## Universe CSV
|
|
71
|
+
## Universe (CSV path or entity list)
|
|
72
72
|
|
|
73
|
-
`plan_search()`
|
|
73
|
+
`plan_search()` takes a **`universe`** argument: either a path to a UTF-8 CSV file, or a `list[str]` of entity IDs. IDs must match the identifiers used by the Bigdata API for your dataset.
|
|
74
|
+
|
|
75
|
+
When using a CSV, two layouts are supported:
|
|
74
76
|
|
|
75
77
|
**1. Header row with an `id` column** (optional extra columns such as `name` are ignored):
|
|
76
78
|
|
|
@@ -94,7 +96,7 @@ from bigdata_smart_batching import (
|
|
|
94
96
|
# Step 1: Plan the search
|
|
95
97
|
plan = plan_search(
|
|
96
98
|
text="earnings revenue profit",
|
|
97
|
-
|
|
99
|
+
universe="id_name_mapping_us_top_3000.csv",
|
|
98
100
|
start_date="2023-01-01",
|
|
99
101
|
end_date="2023-12-31",
|
|
100
102
|
api_key="your_api_key", # or set BIGDATA_API_KEY env var
|
|
@@ -124,7 +126,7 @@ from bigdata_smart_batching import plan_search, execute_search, save_plan, load_
|
|
|
124
126
|
# Create and save a plan
|
|
125
127
|
plan = plan_search(
|
|
126
128
|
text="merger acquisition",
|
|
127
|
-
|
|
129
|
+
universe="id_name_mapping_us_top_3000.csv",
|
|
128
130
|
start_date="2023-01-01",
|
|
129
131
|
end_date="2023-12-31",
|
|
130
132
|
)
|
|
@@ -150,7 +152,7 @@ Step 2: EXECUTION
|
|
|
150
152
|
|
|
151
153
|
### Planning (`plan_search()`)
|
|
152
154
|
|
|
153
|
-
1. Loads the universe of companies from CSV
|
|
155
|
+
1. Loads the universe of companies from a CSV path or inline list
|
|
154
156
|
2. Queries the comention endpoint to get chunk volumes per company
|
|
155
157
|
3. Splits date ranges by volume when a company exceeds the chunk limit
|
|
156
158
|
4. Creates optimized baskets grouped by volume
|
|
@@ -170,7 +172,7 @@ Step 2: EXECUTION
|
|
|
170
172
|
| Parameter | Type | Default | Description |
|
|
171
173
|
|-----------|------|---------|-------------|
|
|
172
174
|
| `text` | `str` | required | Search query text |
|
|
173
|
-
| `
|
|
175
|
+
| `universe` | `str \| list[str]` | required | CSV path or list of entity IDs |
|
|
174
176
|
| `start_date` | `str` | required | Start date (YYYY-MM-DD) |
|
|
175
177
|
| `end_date` | `str` | required | End date (YYYY-MM-DD) |
|
|
176
178
|
| `api_key` | `str` | env var | API key |
|
|
@@ -192,7 +194,8 @@ Step 2: EXECUTION
|
|
|
192
194
|
### Helper Functions
|
|
193
195
|
|
|
194
196
|
- **`deduplicate_documents(documents)`** -- Merges duplicate documents by `id`
|
|
195
|
-
- **`
|
|
197
|
+
- **`resolve_universe(universe)`** -- Loads entity IDs from a CSV path or validates a `list[str]`
|
|
198
|
+
- **`load_universe_from_csv(csv_path)`** -- Loads entity IDs from CSV only
|
|
196
199
|
- **`convert_to_dataframe(raw_results)`** -- Converts documents to DataFrame (one row per chunk)
|
|
197
200
|
- **`save_plan(plan, path)`** / **`load_plan(path)`** -- Persist plans as JSON
|
|
198
201
|
- **`portfolio_backtesting_pipeline(...)`** -- Long-short portfolio backtesting
|
|
@@ -249,6 +252,6 @@ bigdata-smart-batching/
|
|
|
249
252
|
|
|
250
253
|
## License
|
|
251
254
|
|
|
252
|
-
This project is part of
|
|
255
|
+
This project is part of Bigdata.com.
|
|
253
256
|
|
|
254
257
|
**Disclaimer**: This software is provided "as is" without warranty of any kind, express or implied. The authors and contributors assume no responsibility for the accuracy, completeness, or usefulness of any information, results, or processes provided. This software is for educational and research purposes only and is not intended to be used as financial advice.
|
|
@@ -52,9 +52,11 @@ BIGDATA_API_KEY=your_api_key_here
|
|
|
52
52
|
BIGDATA_API_BASE_URL=https://api.bigdata.com
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
## Universe CSV
|
|
55
|
+
## Universe (CSV path or entity list)
|
|
56
56
|
|
|
57
|
-
`plan_search()`
|
|
57
|
+
`plan_search()` takes a **`universe`** argument: either a path to a UTF-8 CSV file, or a `list[str]` of entity IDs. IDs must match the identifiers used by the Bigdata API for your dataset.
|
|
58
|
+
|
|
59
|
+
When using a CSV, two layouts are supported:
|
|
58
60
|
|
|
59
61
|
**1. Header row with an `id` column** (optional extra columns such as `name` are ignored):
|
|
60
62
|
|
|
@@ -78,7 +80,7 @@ from bigdata_smart_batching import (
|
|
|
78
80
|
# Step 1: Plan the search
|
|
79
81
|
plan = plan_search(
|
|
80
82
|
text="earnings revenue profit",
|
|
81
|
-
|
|
83
|
+
universe="id_name_mapping_us_top_3000.csv",
|
|
82
84
|
start_date="2023-01-01",
|
|
83
85
|
end_date="2023-12-31",
|
|
84
86
|
api_key="your_api_key", # or set BIGDATA_API_KEY env var
|
|
@@ -108,7 +110,7 @@ from bigdata_smart_batching import plan_search, execute_search, save_plan, load_
|
|
|
108
110
|
# Create and save a plan
|
|
109
111
|
plan = plan_search(
|
|
110
112
|
text="merger acquisition",
|
|
111
|
-
|
|
113
|
+
universe="id_name_mapping_us_top_3000.csv",
|
|
112
114
|
start_date="2023-01-01",
|
|
113
115
|
end_date="2023-12-31",
|
|
114
116
|
)
|
|
@@ -134,7 +136,7 @@ Step 2: EXECUTION
|
|
|
134
136
|
|
|
135
137
|
### Planning (`plan_search()`)
|
|
136
138
|
|
|
137
|
-
1. Loads the universe of companies from CSV
|
|
139
|
+
1. Loads the universe of companies from a CSV path or inline list
|
|
138
140
|
2. Queries the comention endpoint to get chunk volumes per company
|
|
139
141
|
3. Splits date ranges by volume when a company exceeds the chunk limit
|
|
140
142
|
4. Creates optimized baskets grouped by volume
|
|
@@ -154,7 +156,7 @@ Step 2: EXECUTION
|
|
|
154
156
|
| Parameter | Type | Default | Description |
|
|
155
157
|
|-----------|------|---------|-------------|
|
|
156
158
|
| `text` | `str` | required | Search query text |
|
|
157
|
-
| `
|
|
159
|
+
| `universe` | `str \| list[str]` | required | CSV path or list of entity IDs |
|
|
158
160
|
| `start_date` | `str` | required | Start date (YYYY-MM-DD) |
|
|
159
161
|
| `end_date` | `str` | required | End date (YYYY-MM-DD) |
|
|
160
162
|
| `api_key` | `str` | env var | API key |
|
|
@@ -176,7 +178,8 @@ Step 2: EXECUTION
|
|
|
176
178
|
### Helper Functions
|
|
177
179
|
|
|
178
180
|
- **`deduplicate_documents(documents)`** -- Merges duplicate documents by `id`
|
|
179
|
-
- **`
|
|
181
|
+
- **`resolve_universe(universe)`** -- Loads entity IDs from a CSV path or validates a `list[str]`
|
|
182
|
+
- **`load_universe_from_csv(csv_path)`** -- Loads entity IDs from CSV only
|
|
180
183
|
- **`convert_to_dataframe(raw_results)`** -- Converts documents to DataFrame (one row per chunk)
|
|
181
184
|
- **`save_plan(plan, path)`** / **`load_plan(path)`** -- Persist plans as JSON
|
|
182
185
|
- **`portfolio_backtesting_pipeline(...)`** -- Long-short portfolio backtesting
|
|
@@ -233,6 +236,6 @@ bigdata-smart-batching/
|
|
|
233
236
|
|
|
234
237
|
## License
|
|
235
238
|
|
|
236
|
-
This project is part of
|
|
239
|
+
This project is part of Bigdata.com.
|
|
237
240
|
|
|
238
241
|
**Disclaimer**: This software is provided "as is" without warranty of any kind, express or implied. The authors and contributors assume no responsibility for the accuracy, completeness, or usefulness of any information, results, or processes provided. This software is for educational and research purposes only and is not intended to be used as financial advice.
|