bigdata-smart-batching 0.1.0__tar.gz → 0.2.0__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.
Files changed (25) hide show
  1. bigdata_smart_batching-0.2.0/.gitignore +110 -0
  2. bigdata_smart_batching-0.2.0/CHANGELOG.md +28 -0
  3. bigdata_smart_batching-0.2.0/LICENSE +5 -0
  4. bigdata_smart_batching-0.1.0/README.md → bigdata_smart_batching-0.2.0/PKG-INFO +46 -10
  5. bigdata_smart_batching-0.1.0/PKG-INFO → bigdata_smart_batching-0.2.0/README.md +30 -23
  6. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/docs/smart-batching-architecture.md +1 -1
  7. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/examples/example.py +1 -1
  8. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/pyproject.toml +6 -2
  9. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/src/bigdata_smart_batching/search_function.py +6 -6
  10. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/uv.lock +1 -1
  11. bigdata_smart_batching-0.1.0/.env +0 -1
  12. bigdata_smart_batching-0.1.0/.python-version +0 -1
  13. bigdata_smart_batching-0.1.0/.vscode/launch.json +0 -19
  14. bigdata_smart_batching-0.1.0/id_name_mapping_us_top_3000.csv +0 -4732
  15. bigdata_smart_batching-0.1.0/id_name_mapping_us_top_3000_reduced.csv +0 -100
  16. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/Makefile +0 -0
  17. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/src/bigdata_smart_batching/__init__.py +0 -0
  18. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/src/bigdata_smart_batching/output_converter.py +0 -0
  19. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/src/bigdata_smart_batching/smart_batching.py +0 -0
  20. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/src/bigdata_smart_batching/smart_batching_config.py +0 -0
  21. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/tests/__init__.py +0 -0
  22. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/tests/test_config.py +0 -0
  23. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/tests/test_output_converter.py +0 -0
  24. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/tests/test_rate_limiter.py +0 -0
  25. {bigdata_smart_batching-0.1.0 → bigdata_smart_batching-0.2.0}/tests/test_validation.py +0 -0
@@ -0,0 +1,110 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+ cover/
51
+
52
+ # Translations
53
+ *.mo
54
+ *.pot
55
+
56
+ # Environments
57
+ .env
58
+ .venv
59
+ env/
60
+ venv/
61
+ ENV/
62
+ env.bak/
63
+ venv.bak/
64
+
65
+ # Spyder project settings
66
+ .spyderproject
67
+ .spyproject
68
+
69
+ # Rope project settings
70
+ .ropeproject
71
+
72
+ # mkdocs documentation
73
+ /site
74
+
75
+ # mypy
76
+ .mypy_cache/
77
+ .dmypy.json
78
+ dmypy.json
79
+
80
+ # Pyre type checker
81
+ .pyre/
82
+
83
+ # pytype static type analyzer
84
+ .pytype/
85
+
86
+ # Cython debug symbols
87
+ cython_debug/
88
+
89
+ # Ruff
90
+ .ruff_cache/
91
+
92
+ # IDEs and editors
93
+ .idea/
94
+ .vscode/
95
+ *.swp
96
+ *.swo
97
+ *~
98
+
99
+ # Jupyter Notebook
100
+ .ipynb_checkpoints/
101
+
102
+ # pyenv
103
+ .python-version
104
+
105
+ # Local / OS
106
+ .DS_Store
107
+ Thumbs.db
108
+
109
+ # CSV files
110
+ *.csv
@@ -0,0 +1,28 @@
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
+ ## [0.2.0] - 2026-04-14
9
+
10
+ ### Changed
11
+
12
+ - **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.
13
+ - Terminology and docs describe this value as a chunk upper bound estimate (module docstring, README, architecture diagram, and example output).
14
+ - 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`.
15
+
16
+ ### Fixed
17
+
18
+ - Align `uv.lock` `requires-python` with `pyproject.toml` (`>=3.11,<4.0`).
19
+
20
+ ## [0.1.0] - 2026-04-14
21
+
22
+ ### Added
23
+
24
+ - Initial release of **bigdata-smart-batching**: high-performance semantic search with intelligent company grouping and parallel execution.
25
+ - Planning API (`plan_search`) to organize searches via smart batching and report expected chunk counts.
26
+ - Execution API (`execute_search`) with rate-limited parallel requests and proportional sampling to preserve result distribution.
27
+ - Utilities: document deduplication, DataFrame conversion, and configurable search/batching behavior via `smart_batching` and related modules.
28
+ - Python 3.11+ support; dependencies include `requests`, `pandas`, `numpy`, `matplotlib`, and `python-dotenv`.
@@ -0,0 +1,5 @@
1
+ This software is licensed for use solely under the terms agreed upon in the applicable Master Agreement and
2
+ Order Schedule between the parties. For trials, the applicable legal documents are the Mutual Non-Disclosure
3
+ Agreement, or if applicable the Trial Agreement. No other rights or licenses are granted by implication,
4
+ estoppel, or otherwise. For further details, please refer to your specific Master Agreement and Order
5
+ Schedule or contact us at legal@ravenpack.com.
@@ -1,9 +1,25 @@
1
+ Metadata-Version: 2.4
2
+ Name: bigdata-smart-batching
3
+ Version: 0.2.0
4
+ Summary: High-performance semantic search with intelligent company grouping and parallel execution
5
+ Project-URL: homepage, https://bigdata.com/api
6
+ Author-email: "Bigdata.com" <support@ravenpack.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: <4.0,>=3.11
10
+ Requires-Dist: matplotlib>=3.7
11
+ Requires-Dist: numpy>=1.24
12
+ Requires-Dist: pandas>=2.0
13
+ Requires-Dist: python-dotenv>=1.2.2
14
+ Requires-Dist: requests>=2.31.0
15
+ Description-Content-Type: text/markdown
16
+
1
17
  # Smart Batching Search
2
18
 
3
19
  A high-performance semantic search system that reduces API queries by **67-99%** (varies by topic specificity) through intelligent company grouping and parallel execution.
4
20
 
5
21
  This module provides a two-step system for efficient semantic search:
6
- 1. **Planning**: Organize search using smart batching and return total expected chunks
22
+ 1. **Planning**: Organize search using smart batching and return Chunk upper bound estimate
7
23
  2. **Execution**: Perform search with proportional sampling to preserve distribution
8
24
 
9
25
  ## Key Benefits
@@ -16,17 +32,24 @@ This module provides a two-step system for efficient semantic search:
16
32
 
17
33
  ## Installation
18
34
 
19
- ### Using uv (Recommended)
35
+ Install the package from PyPI (Python 3.11+):
20
36
 
21
37
  ```bash
22
- # Clone or navigate to the project
23
- cd bigdata-smart-batching
38
+ pip install bigdata-smart-batching
39
+ ```
24
40
 
25
- # Install in development mode
26
- uv sync
41
+ With [uv](https://docs.astral.sh/uv/):
27
42
 
28
- # Or with dev dependencies
29
- uv sync --all-extras
43
+ ```bash
44
+ uv add bigdata-smart-batching
45
+ ```
46
+
47
+ ### Development
48
+
49
+ To work on this repository locally, from the project root:
50
+
51
+ ```bash
52
+ uv sync
30
53
  ```
31
54
 
32
55
  ### Environment Setup
@@ -45,6 +68,19 @@ BIGDATA_API_KEY=your_api_key_here
45
68
  BIGDATA_API_BASE_URL=https://api.bigdata.com
46
69
  ```
47
70
 
71
+ ## Universe CSV file
72
+
73
+ `plan_search()` loads company **entity IDs** from a UTF-8 CSV. IDs must match the identifiers used by the Bigdata API for your dataset. Two layouts are supported:
74
+
75
+ **1. Header row with an `id` column** (optional extra columns such as `name` are ignored):
76
+
77
+ ```csv
78
+ id,name
79
+ B8EF97,Example Corp A
80
+ BB07E4,Example Corp B
81
+ 3461CF,Example Corp C
82
+ ```
83
+
48
84
  ## Quick Start
49
85
 
50
86
  ```python
@@ -64,7 +100,7 @@ plan = plan_search(
64
100
  api_key="your_api_key", # or set BIGDATA_API_KEY env var
65
101
  )
66
102
 
67
- print(f"Total expected chunks: {plan['total_expected_chunks']:,}")
103
+ print(f"Chunk upper bound estimate: {plan['chunk_upper_bound_estimate']:,}")
68
104
 
69
105
  # Step 2: Execute search with 10% of total chunks (preserves distribution)
70
106
  results_raw = execute_search(
@@ -118,7 +154,7 @@ Step 2: EXECUTION
118
154
  2. Queries the comention endpoint to get chunk volumes per company
119
155
  3. Splits date ranges by volume when a company exceeds the chunk limit
120
156
  4. Creates optimized baskets grouped by volume
121
- 5. Returns a plan with total expected chunks and basket configurations
157
+ 5. Returns a plan with Chunk upper bound estimate and basket configurations
122
158
 
123
159
  ### Execution (`execute_search()`)
124
160
 
@@ -1,22 +1,9 @@
1
- Metadata-Version: 2.4
2
- Name: bigdata-smart-batching
3
- Version: 0.1.0
4
- Summary: High-performance semantic search with intelligent company grouping and parallel execution
5
- License: MIT
6
- Requires-Python: >=3.11
7
- Requires-Dist: matplotlib>=3.7
8
- Requires-Dist: numpy>=1.24
9
- Requires-Dist: pandas>=2.0
10
- Requires-Dist: python-dotenv>=1.2.2
11
- Requires-Dist: requests>=2.31.0
12
- Description-Content-Type: text/markdown
13
-
14
1
  # Smart Batching Search
15
2
 
16
3
  A high-performance semantic search system that reduces API queries by **67-99%** (varies by topic specificity) through intelligent company grouping and parallel execution.
17
4
 
18
5
  This module provides a two-step system for efficient semantic search:
19
- 1. **Planning**: Organize search using smart batching and return total expected chunks
6
+ 1. **Planning**: Organize search using smart batching and return Chunk upper bound estimate
20
7
  2. **Execution**: Perform search with proportional sampling to preserve distribution
21
8
 
22
9
  ## Key Benefits
@@ -29,17 +16,24 @@ This module provides a two-step system for efficient semantic search:
29
16
 
30
17
  ## Installation
31
18
 
32
- ### Using uv (Recommended)
19
+ Install the package from PyPI (Python 3.11+):
33
20
 
34
21
  ```bash
35
- # Clone or navigate to the project
36
- cd bigdata-smart-batching
22
+ pip install bigdata-smart-batching
23
+ ```
37
24
 
38
- # Install in development mode
39
- uv sync
25
+ With [uv](https://docs.astral.sh/uv/):
40
26
 
41
- # Or with dev dependencies
42
- uv sync --all-extras
27
+ ```bash
28
+ uv add bigdata-smart-batching
29
+ ```
30
+
31
+ ### Development
32
+
33
+ To work on this repository locally, from the project root:
34
+
35
+ ```bash
36
+ uv sync
43
37
  ```
44
38
 
45
39
  ### Environment Setup
@@ -58,6 +52,19 @@ BIGDATA_API_KEY=your_api_key_here
58
52
  BIGDATA_API_BASE_URL=https://api.bigdata.com
59
53
  ```
60
54
 
55
+ ## Universe CSV file
56
+
57
+ `plan_search()` loads company **entity IDs** from a UTF-8 CSV. IDs must match the identifiers used by the Bigdata API for your dataset. Two layouts are supported:
58
+
59
+ **1. Header row with an `id` column** (optional extra columns such as `name` are ignored):
60
+
61
+ ```csv
62
+ id,name
63
+ B8EF97,Example Corp A
64
+ BB07E4,Example Corp B
65
+ 3461CF,Example Corp C
66
+ ```
67
+
61
68
  ## Quick Start
62
69
 
63
70
  ```python
@@ -77,7 +84,7 @@ plan = plan_search(
77
84
  api_key="your_api_key", # or set BIGDATA_API_KEY env var
78
85
  )
79
86
 
80
- print(f"Total expected chunks: {plan['total_expected_chunks']:,}")
87
+ print(f"Chunk upper bound estimate: {plan['chunk_upper_bound_estimate']:,}")
81
88
 
82
89
  # Step 2: Execute search with 10% of total chunks (preserves distribution)
83
90
  results_raw = execute_search(
@@ -131,7 +138,7 @@ Step 2: EXECUTION
131
138
  2. Queries the comention endpoint to get chunk volumes per company
132
139
  3. Splits date ranges by volume when a company exceeds the chunk limit
133
140
  4. Creates optimized baskets grouped by volume
134
- 5. Returns a plan with total expected chunks and basket configurations
141
+ 5. Returns a plan with Chunk upper bound estimate and basket configurations
135
142
 
136
143
  ### Execution (`execute_search()`)
137
144
 
@@ -98,7 +98,7 @@ flowchart TD
98
98
 
99
99
  PHASE2 --> ASSEMBLE["Assemble plan:<br/>Convert baskets → query payloads<br/>Add very_low baskets<br/>(0-chunk companies, max_chunks=100)"]
100
100
 
101
- ASSEMBLE --> PLAN_OUT["Plan Output:<br/>total_expected_chunks,<br/>baskets[ ] with embedded queries,<br/>planning_metadata"]
101
+ ASSEMBLE --> PLAN_OUT["Plan Output:<br/>chunk_upper_bound_estimate,<br/>baskets[ ] with embedded queries,<br/>planning_metadata"]
102
102
 
103
103
  PLAN_OUT --> EXEC_START(["Start: execute_search()"])
104
104
 
@@ -55,7 +55,7 @@ def main() -> None:
55
55
  min_entities_per_basket=10,
56
56
  )
57
57
 
58
- print(f"Total expected chunks: {plan['total_expected_chunks']:,}")
58
+ print(f"Chunk upper bound estimate: {plan['chunk_upper_bound_estimate']:,}")
59
59
 
60
60
  # Step 2: Execute search with 10% of total chunks (preserves distribution)
61
61
  results_raw = execute_search(
@@ -1,9 +1,10 @@
1
1
  [project]
2
2
  name = "bigdata-smart-batching"
3
- version = "0.1.0"
3
+ version = "0.2.0"
4
4
  description = "High-performance semantic search with intelligent company grouping and parallel execution"
5
5
  readme = "README.md"
6
- requires-python = ">=3.11"
6
+ authors = [{ name = "Bigdata.com", email = "support@ravenpack.com" }]
7
+ requires-python = ">=3.11,<4.0"
7
8
  license = { text = "MIT" }
8
9
  dependencies = [
9
10
  "requests>=2.31.0",
@@ -28,6 +29,9 @@ build-backend = "hatchling.build"
28
29
  [tool.hatch.build.targets.wheel]
29
30
  packages = ["src/bigdata_smart_batching"]
30
31
 
32
+ [project.urls]
33
+ homepage = "https://bigdata.com/api"
34
+
31
35
  [tool.ruff]
32
36
  line-length = 100
33
37
  target-version = "py311"
@@ -2,7 +2,7 @@
2
2
  Smart Batching Search Function
3
3
 
4
4
  This module provides a two-step system for efficient semantic search:
5
- 1. Planning: Organize search using smart batching and return total expected chunks
5
+ 1. Planning: Organize search using smart batching and return Chunk upper bound estimate
6
6
  2. Execution: Perform search with proportional sampling to preserve distribution
7
7
  """
8
8
 
@@ -411,7 +411,7 @@ def plan_search(
411
411
  (no consolidation).
412
412
  Returns:
413
413
  Dict with planning results:
414
- - total_expected_chunks: Total chunks expected
414
+ - chunk_upper_bound_estimate: Total chunks expected
415
415
  - baskets: List of basket configs with complete query structures
416
416
  - planning_metadata: Additional metadata
417
417
  """
@@ -479,7 +479,7 @@ def plan_search(
479
479
  }
480
480
 
481
481
  plan = {
482
- "total_expected_chunks": estimated_chunks,
482
+ "chunk_upper_bound_estimate": estimated_chunks,
483
483
  "baskets": [basket],
484
484
  "planning_metadata": {
485
485
  "total_companies": len(companies),
@@ -589,7 +589,7 @@ def plan_search(
589
589
  baskets.append(basket)
590
590
 
591
591
  plan = {
592
- "total_expected_chunks": total_expected,
592
+ "chunk_upper_bound_estimate": total_expected,
593
593
  "baskets": baskets,
594
594
  "planning_metadata": {
595
595
  "total_companies": len(companies),
@@ -603,7 +603,7 @@ def plan_search(
603
603
  }
604
604
 
605
605
  logger.info(
606
- f"Planning complete: {plan['total_expected_chunks']:,} expected chunks in {len(plan['baskets'])} baskets"
606
+ f"Planning complete: {plan['chunk_upper_bound_estimate']:,} expected chunks in {len(plan['baskets'])} baskets"
607
607
  )
608
608
  return plan
609
609
 
@@ -778,7 +778,7 @@ def execute_search(
778
778
 
779
779
  api_base_url = api_base_url or os.getenv("BIGDATA_API_BASE_URL", DEFAULT_API_BASE_URL)
780
780
 
781
- total_expected = search_plan.get("total_expected_chunks", 0)
781
+ total_expected = search_plan.get("chunk_upper_bound_estimate", 0)
782
782
  target_chunks = int(total_expected * chunk_percentage)
783
783
  logger.info(f"Executing search with {chunk_percentage * 100:.1f}% of chunks")
784
784
  logger.info(f"Total maximum expected chunks: {target_chunks:,}")
@@ -1,6 +1,6 @@
1
1
  version = 1
2
2
  revision = 2
3
- requires-python = ">=3.11"
3
+ requires-python = ">=3.11, <4.0"
4
4
  resolution-markers = [
5
5
  "python_full_version >= '3.14' and sys_platform == 'win32'",
6
6
  "python_full_version >= '3.14' and sys_platform == 'emscripten'",
@@ -1 +0,0 @@
1
- BIGDATA_API_KEY=bd_v1_UPdNGgq44wBO9XR8THfiGvHd7Km9TCIvDmnT5AiatA9T56
@@ -1 +0,0 @@
1
- 3.11
@@ -1,19 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "example",
9
- "type": "debugpy",
10
- "request": "launch",
11
- "python": ".venv/bin/python",
12
- "program": "examples/example.py",
13
- "console": "integratedTerminal",
14
- //"env": {"LOGNAME": "amartinezg",
15
- //"AWS_DS_S3_DEFAULT_BUCKET": "s3://com.ravenpack.dsteam.datalake"},
16
- "justMyCode": false,
17
- },
18
- ]
19
- }