brightdata-hotdata-bridge 0.1.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.
- brightdata_hotdata_bridge-0.1.1/.env.example +35 -0
- brightdata_hotdata_bridge-0.1.1/.gitignore +38 -0
- brightdata_hotdata_bridge-0.1.1/CHANGELOG.md +39 -0
- brightdata_hotdata_bridge-0.1.1/LICENSE +202 -0
- brightdata_hotdata_bridge-0.1.1/NOTICE +4 -0
- brightdata_hotdata_bridge-0.1.1/PKG-INFO +258 -0
- brightdata_hotdata_bridge-0.1.1/README.md +219 -0
- brightdata_hotdata_bridge-0.1.1/docs/README.md +12 -0
- brightdata_hotdata_bridge-0.1.1/docs/architecture.md +93 -0
- brightdata_hotdata_bridge-0.1.1/docs/configuration.md +85 -0
- brightdata_hotdata_bridge-0.1.1/docs/setup.md +71 -0
- brightdata_hotdata_bridge-0.1.1/docs/troubleshooting.md +77 -0
- brightdata_hotdata_bridge-0.1.1/docs/usage.md +140 -0
- brightdata_hotdata_bridge-0.1.1/pyproject.toml +117 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/__about__.py +3 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/__init__.py +105 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/brightdata.py +371 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/catalog.py +254 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/cli.py +471 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/config.py +173 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/errors.py +184 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/hotdata_client.py +511 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/inputs.py +250 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/logging_setup.py +104 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/models.py +286 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/pipeline.py +640 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/py.typed +0 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/state.py +194 -0
- brightdata_hotdata_bridge-0.1.1/src/brightdata_hotdata_bridge/validation.py +276 -0
- brightdata_hotdata_bridge-0.1.1/tests/__init__.py +0 -0
- brightdata_hotdata_bridge-0.1.1/tests/conftest.py +136 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_brightdata.py +227 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_catalog.py +106 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_cli.py +277 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_config_and_state.py +99 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_database_resolution.py +151 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_hotdata_client.py +259 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_inputs.py +99 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_pipeline.py +330 -0
- brightdata_hotdata_bridge-0.1.1/tests/test_validation.py +144 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Copy to .env and fill in. Both the `bdh` CLI and the Python library read these.
|
|
2
|
+
# Never commit the real .env file.
|
|
3
|
+
|
|
4
|
+
# --- Required ------------------------------------------------------------
|
|
5
|
+
BRIGHTDATA_API_KEY=
|
|
6
|
+
HOTDATA_API_KEY=
|
|
7
|
+
HOTDATA_WORKSPACE_ID=
|
|
8
|
+
|
|
9
|
+
# --- Optional (defaults shown) -------------------------------------------
|
|
10
|
+
# Target database. When neither is set, the workspace's only database is used;
|
|
11
|
+
# if the workspace has several, set one of these (`bdh databases` lists them).
|
|
12
|
+
# HOTDATA_DATABASE_ID=
|
|
13
|
+
# HOTDATA_DATABASE_NAME=
|
|
14
|
+
# Schema that tables are published into. Defaults to the database's default schema,
|
|
15
|
+
# or `public` when the database has none.
|
|
16
|
+
# HOTDATA_SCHEMA=
|
|
17
|
+
# Override only when targeting a non-production Hotdata environment.
|
|
18
|
+
# HOTDATA_HOST=https://api.hotdata.dev
|
|
19
|
+
|
|
20
|
+
# Seconds between Bright Data progress checks, and the overall wait limit.
|
|
21
|
+
# BDH_POLL_INTERVAL_SECONDS=10
|
|
22
|
+
# BDH_POLL_TIMEOUT_SECONDS=3600
|
|
23
|
+
|
|
24
|
+
# Seconds to wait for a background Hotdata load job to finish.
|
|
25
|
+
# BDH_LOAD_TIMEOUT_SECONDS=1800
|
|
26
|
+
|
|
27
|
+
# Timeout for a single HTTP request.
|
|
28
|
+
# BDH_HTTP_TIMEOUT_SECONDS=60
|
|
29
|
+
|
|
30
|
+
# Where run records, downloaded snapshots and the scraper catalog cache live.
|
|
31
|
+
# BDH_STATE_DIR=.bdh
|
|
32
|
+
|
|
33
|
+
# Scraper catalog source and how long the cached copy stays fresh.
|
|
34
|
+
# BDH_CATALOG_URL=https://docs.brightdata.com/scrapers-full.json
|
|
35
|
+
# BDH_CATALOG_TTL_HOURS=24
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Secrets: never commit credentials
|
|
2
|
+
.env
|
|
3
|
+
.env.*
|
|
4
|
+
!.env.example
|
|
5
|
+
*.pem
|
|
6
|
+
*.key
|
|
7
|
+
|
|
8
|
+
# Pipeline working state (downloaded snapshots, run records, catalog cache)
|
|
9
|
+
.bdh/
|
|
10
|
+
|
|
11
|
+
# Python
|
|
12
|
+
__pycache__/
|
|
13
|
+
*.py[cod]
|
|
14
|
+
*.egg-info/
|
|
15
|
+
build/
|
|
16
|
+
dist/
|
|
17
|
+
.venv/
|
|
18
|
+
venv/
|
|
19
|
+
|
|
20
|
+
# Tooling caches
|
|
21
|
+
.mypy_cache/
|
|
22
|
+
.ruff_cache/
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
coverage.xml
|
|
26
|
+
htmlcov/
|
|
27
|
+
|
|
28
|
+
# Editors / OS
|
|
29
|
+
.idea/
|
|
30
|
+
.vscode/
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
# Internal working documents (kept locally, not published)
|
|
34
|
+
BrightData_Hotdata_Functional_Specification_Document.docx.md
|
|
35
|
+
Technical Specification_ Bright Data → Hotdata Integration.md
|
|
36
|
+
audit.md
|
|
37
|
+
dataset_id.json
|
|
38
|
+
.cursorrules
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.1]
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Release workflow reads `__version__` from `__about__.py`, so the tag check matches the package version.
|
|
14
|
+
|
|
15
|
+
## [0.1.0]
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- `NOTICE` file for the Apache-2.0 license, shipped in the wheel and sdist.
|
|
20
|
+
- Individual Contributor License Agreement (`CLA.md`), signed with a GitHub login through
|
|
21
|
+
CLA assistant and checked on every pull request.
|
|
22
|
+
- `PushResult.row_count`: rows loaded by the run (the same as `rows_published`).
|
|
23
|
+
- `docs/` with setup, configuration, usage, troubleshooting and architecture pages.
|
|
24
|
+
- `examples/push_with_library.py`: end-to-end library use with handling for each failure.
|
|
25
|
+
- `SECURITY.md` (private vulnerability reporting), `CODE_OF_CONDUCT.md` (Contributor
|
|
26
|
+
Covenant 2.1), and issue and pull request templates.
|
|
27
|
+
- End-to-end pipeline: trigger a Bright Data collection, poll until ready, stream the
|
|
28
|
+
snapshot, validate it, upload it to Hotdata object storage and load it into a table.
|
|
29
|
+
- Support for any scraper in Bright Data's catalog, with CSV inputs validated against
|
|
30
|
+
the selected collection method (`collect_by_url` and `discover_by_*`).
|
|
31
|
+
- Output validation against the scraper's output schema, with error records set aside
|
|
32
|
+
and a JSON report on mismatch.
|
|
33
|
+
- Resumable run records, `bdh replay` for failed writes, and `replace`, `append`,
|
|
34
|
+
`upsert`, `update` and `delete` load modes.
|
|
35
|
+
- Target database looked up from the Hotdata workspace when `HOTDATA_DATABASE_ID` is not
|
|
36
|
+
set (the only database, or one chosen by `HOTDATA_DATABASE_NAME`), recorded per run so
|
|
37
|
+
replays publish to the same database. The schema defaults to the database's own.
|
|
38
|
+
- `bdh` CLI: `push`, `trigger`, `status`, `replay`, `runs`, `databases`,
|
|
39
|
+
`scrapers list|show`.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: brightdata-hotdata-bridge
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Trigger Bright Data scraper collections and publish the results into Hotdata tables.
|
|
5
|
+
Project-URL: Documentation, https://github.com/adomhamza/brightdata-hotdata-bridge#readme
|
|
6
|
+
Project-URL: Source, https://github.com/adomhamza/brightdata-hotdata-bridge
|
|
7
|
+
Project-URL: Issues, https://github.com/adomhamza/brightdata-hotdata-bridge/issues
|
|
8
|
+
Author: Adom Hamza
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: brightdata,data-pipeline,etl,hotdata,web-scraping
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Database
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: hotdata<1,>=0.11
|
|
27
|
+
Requires-Dist: httpx<1,>=0.27
|
|
28
|
+
Requires-Dist: pydantic-settings<3,>=2.3
|
|
29
|
+
Requires-Dist: pydantic<3,>=2.7
|
|
30
|
+
Requires-Dist: typer<1,>=0.12
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
36
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# brightdata-hotdata-bridge
|
|
41
|
+
|
|
42
|
+
Collect web data with [Bright Data](https://brightdata.com) scrapers and publish it into
|
|
43
|
+
[Hotdata](https://www.hotdata.dev) tables, from Python or the `bdh` command line.
|
|
44
|
+
|
|
45
|
+
Give it a scraper's dataset id and a CSV of URLs (or keywords, usernames, and so on).
|
|
46
|
+
It triggers the collection, waits for it, validates the records, and loads them into a
|
|
47
|
+
Hotdata table.
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
inputs.csv ─► Bright Data trigger ─► poll until ready ─► download NDJSON
|
|
51
|
+
─► validate against the scraper schema ─► Hotdata upload ─► table load
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Full documentation is in [`docs/`](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/README.md): [setup](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/setup.md),
|
|
55
|
+
[configuration](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/configuration.md), [usage](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/usage.md),
|
|
56
|
+
[troubleshooting](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/troubleshooting.md) and [architecture](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/docs/architecture.md).
|
|
57
|
+
|
|
58
|
+
## Features
|
|
59
|
+
|
|
60
|
+
- **Any Bright Data scraper.** Dataset ids and their inputs are checked against Bright
|
|
61
|
+
Data's published [scraper catalog](https://docs.brightdata.com/scrapers-full.json)
|
|
62
|
+
(1,200+ scrapers, cached locally), so a bad CSV is rejected before a paid collection
|
|
63
|
+
starts.
|
|
64
|
+
- **Collect and discover.** Supports `collect_by_url` and every `discover_by_*` method
|
|
65
|
+
(keyword, category, user name, and more).
|
|
66
|
+
- **Validated before writing.** Records are type-checked against the scraper's output
|
|
67
|
+
schema. A mismatch pauses ingestion and writes a report. Records Bright Data flags
|
|
68
|
+
as errors are set aside rather than loaded.
|
|
69
|
+
- **Large snapshots.** The snapshot is streamed to disk and uploaded straight to Hotdata
|
|
70
|
+
object storage, using multipart for big files. Loads run as background jobs.
|
|
71
|
+
- **Resumable and replayable.** Every stage is saved to a local run record. A timeout,
|
|
72
|
+
a failed write or a fixed schema problem is resumed with `bdh replay`, and a run is
|
|
73
|
+
never loaded twice.
|
|
74
|
+
- **Polite to the APIs.** Honours `Retry-After` with exponential backoff, and only
|
|
75
|
+
retries a Bright Data trigger when it provably never reached the server.
|
|
76
|
+
|
|
77
|
+
## Install
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install brightdata-hotdata-bridge # library + CLI
|
|
81
|
+
pipx install brightdata-hotdata-bridge # CLI only, isolated environment
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Requires Python 3.10+.
|
|
85
|
+
|
|
86
|
+
## Configure
|
|
87
|
+
|
|
88
|
+
Copy `.env.example` to `.env` (or export the variables):
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
BRIGHTDATA_API_KEY=...
|
|
92
|
+
HOTDATA_API_KEY=...
|
|
93
|
+
HOTDATA_WORKSPACE_ID=...
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The target database is looked up from the workspace before anything is triggered. If the
|
|
97
|
+
workspace has exactly one database it is used automatically; if it has several, set
|
|
98
|
+
`HOTDATA_DATABASE_ID` or `HOTDATA_DATABASE_NAME` (run `bdh databases` to list them). Each
|
|
99
|
+
run records the database it used, so `bdh replay` always publishes to the same place.
|
|
100
|
+
|
|
101
|
+
Optional settings (schema, polling interval and timeout, state directory, catalog
|
|
102
|
+
source) are documented in [`.env.example`](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/.env.example). The library and the CLI read
|
|
103
|
+
the same configuration.
|
|
104
|
+
|
|
105
|
+
## CLI
|
|
106
|
+
|
|
107
|
+
Find a scraper and the CSV columns it needs:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
bdh scrapers list --search amazon
|
|
111
|
+
bdh scrapers show gd_l7q7dkf244hwjntr0
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Collect and publish in one step:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# urls.csv has a header row: url
|
|
118
|
+
bdh push --dataset-id gd_l7q7dkf244hwjntr0 --input-file urls.csv --table amazon_products
|
|
119
|
+
|
|
120
|
+
# A single required input can be passed inline
|
|
121
|
+
bdh push -d gd_l7q7dkf244hwjntr0 -q "https://www.amazon.com/dp/B0CRMZHDG8" -t amazon_products
|
|
122
|
+
|
|
123
|
+
# Discovery methods take their own inputs (keywords.csv header: keyword)
|
|
124
|
+
bdh push -d gd_l7q7dkf244hwjntr0 -m discover_by_keyword -i keywords.csv \
|
|
125
|
+
--limit-per-input 50 -t amazon_search --mode append
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Publish a snapshot that already exists, or start a collection and finish it later:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
bdh push --snapshot-id sd_m1a2b3c4d5e6f7g8h --table amazon_products
|
|
132
|
+
bdh trigger -d gd_l7q7dkf244hwjntr0 -i urls.csv -t amazon_products # prints snapshot id
|
|
133
|
+
bdh replay sd_m1a2b3c4d5e6f7g8h
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Operate:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
bdh status sd_m1a2b3c4d5e6f7g8h # Bright Data status + local stage + last error
|
|
140
|
+
bdh runs # all local runs
|
|
141
|
+
bdh databases # Hotdata databases, and which one push will use
|
|
142
|
+
bdh replay sd_m1a2b3c4d5e6f7g8h # resume after a timeout or failed write
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Add `--json` to `push`, `replay`, `status`, `runs` and `trigger` for machine-readable
|
|
146
|
+
output, and `--log-json` for JSON logs.
|
|
147
|
+
|
|
148
|
+
### Load modes
|
|
149
|
+
|
|
150
|
+
| Mode | Effect |
|
|
151
|
+
| --------- | --------------------------------------------------------- |
|
|
152
|
+
| `replace` | The snapshot becomes the table's contents (default). |
|
|
153
|
+
| `append` | Rows are added to the existing table. |
|
|
154
|
+
| `upsert` | Rows matching `--key` columns are replaced, others added. |
|
|
155
|
+
| `update` | Rows matching `--key` columns are replaced. |
|
|
156
|
+
| `delete` | Rows matching `--key` columns are removed. |
|
|
157
|
+
|
|
158
|
+
> **`replace` is the default and discards every existing row.** Pushing to a table that
|
|
159
|
+
> already holds data without `--mode` leaves only the new snapshot's rows. To keep earlier
|
|
160
|
+
> data, use `--mode append`, or `--mode upsert --key <column>` to keep one up-to-date row
|
|
161
|
+
> per record (for example `--key id` for LinkedIn profiles).
|
|
162
|
+
|
|
163
|
+
The first load into a new table is always `replace`, as Hotdata requires. If you ask
|
|
164
|
+
for another mode on a table that does not exist yet, `replace` is used automatically.
|
|
165
|
+
Every load is atomic: readers see the old contents or the new ones, never a mix, and a
|
|
166
|
+
failed load leaves the table unchanged.
|
|
167
|
+
|
|
168
|
+
### Validation options
|
|
169
|
+
|
|
170
|
+
- `--require-field name` (repeatable): the field must be present and non-null.
|
|
171
|
+
- `--strict-fields`: fail on fields that are not in the scraper's output schema
|
|
172
|
+
(by default they are allowed and listed as schema drift in the report).
|
|
173
|
+
- `--stringify-nested`: store nested objects and arrays as JSON text.
|
|
174
|
+
|
|
175
|
+
### Exit codes
|
|
176
|
+
|
|
177
|
+
| Code | Meaning |
|
|
178
|
+
| ---- | ------------------------------------------ |
|
|
179
|
+
| 0 | Success |
|
|
180
|
+
| 2 | Configuration or usage error |
|
|
181
|
+
| 3 | Unknown dataset / method, or invalid input |
|
|
182
|
+
| 4 | Bright Data API error |
|
|
183
|
+
| 5 | Collection failed or was canceled |
|
|
184
|
+
| 6 | Snapshot not ready in time (resumable) |
|
|
185
|
+
| 7 | Schema mismatch or no publishable records |
|
|
186
|
+
| 8 | Hotdata write failed (replayable) |
|
|
187
|
+
| 9 | Local run record missing or unusable |
|
|
188
|
+
|
|
189
|
+
## Library
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from brightdata_hotdata_bridge import push_snapshot_to_hotdata
|
|
193
|
+
|
|
194
|
+
result = push_snapshot_to_hotdata(
|
|
195
|
+
dataset_id="gd_l7q7dkf244hwjntr0",
|
|
196
|
+
input_file="urls.csv",
|
|
197
|
+
table_name="amazon_products",
|
|
198
|
+
)
|
|
199
|
+
print(f"Loaded {result.row_count} rows; the table now has {result.table_row_count}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
[`examples/push_with_library.py`](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/examples/push_with_library.py) shows how to handle each
|
|
203
|
+
failure.
|
|
204
|
+
|
|
205
|
+
Async code (FastAPI, notebooks, orchestrators) should use the async API:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
from brightdata_hotdata_bridge import (
|
|
209
|
+
PushRequest,
|
|
210
|
+
TableTarget,
|
|
211
|
+
arun_pipeline,
|
|
212
|
+
build_collection_request,
|
|
213
|
+
get_settings,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
settings = get_settings()
|
|
217
|
+
collection = await build_collection_request(
|
|
218
|
+
dataset_id="gd_l7q7dkf244hwjntr0",
|
|
219
|
+
queries=["https://www.amazon.com/dp/B0CRMZHDG8"],
|
|
220
|
+
settings=settings,
|
|
221
|
+
)
|
|
222
|
+
result = await arun_pipeline(
|
|
223
|
+
PushRequest(collection=collection, target=TableTarget(table="amazon_products")),
|
|
224
|
+
settings,
|
|
225
|
+
)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Every error derives from `BridgeError`. Catch `HotdataWriteError` to schedule a
|
|
229
|
+
`replay_run(snapshot_id)`, or `SchemaMismatchError` to inspect `exc.report_path`.
|
|
230
|
+
|
|
231
|
+
## How failures are handled
|
|
232
|
+
|
|
233
|
+
| Situation | Behaviour |
|
|
234
|
+
| --------------------------------- | ------------------------------------------------------------------------- |
|
|
235
|
+
| Collection `failed` / `canceled` | Logged with the snapshot id; nothing is written to Hotdata. |
|
|
236
|
+
| Snapshot not ready before timeout | Run is saved; `bdh push --snapshot-id` or `bdh replay` resumes polling. |
|
|
237
|
+
| Schema or type mismatch | Ingestion pauses; `report.json` lists every issue; nothing is written. |
|
|
238
|
+
| Hotdata upload or load fails | Logged with Hotdata's trace id; `bdh replay` retries from that stage. |
|
|
239
|
+
| Bright Data / Hotdata rate limits | `Retry-After` honoured, exponential backoff (2, 4, 8, 16, 32 s). |
|
|
240
|
+
|
|
241
|
+
Run state lives in `.bdh/runs/<snapshot_id>/`: `run.json` (stage, target, upload id,
|
|
242
|
+
last error), the raw and validated NDJSON, the rejected records, and the validation
|
|
243
|
+
report.
|
|
244
|
+
|
|
245
|
+
## Development
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
python -m venv .venv && source .venv/bin/activate
|
|
249
|
+
pip install -e ".[dev]"
|
|
250
|
+
ruff check . && ruff format --check .
|
|
251
|
+
mypy
|
|
252
|
+
pytest --cov
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
See [CONTRIBUTING.md](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/CODE_OF_CONDUCT.md). Report
|
|
256
|
+
security problems privately as described in [SECURITY.md](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/SECURITY.md). Contributors sign the
|
|
257
|
+
[Contributor License Agreement](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/CLA.md) on their first pull request. Licensed under
|
|
258
|
+
[Apache-2.0](https://github.com/adomhamza/brightdata-hotdata-bridge/blob/main/LICENSE).
|