scraping-pipeline 1.6.4__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.
@@ -0,0 +1,295 @@
1
+ **/.venv
2
+ .cache/
3
+ **/.python-version
4
+ **/.env
5
+ **/.mypy_cache/
6
+ **/.vscode/
7
+ **/.creds.json
8
+ **/.env.**
9
+ # Project specific files
10
+ *cookies.json
11
+ Readme.html
12
+ .idea
13
+ scrapers.conf
14
+
15
+ # ################
16
+ # Project specific files
17
+ .proj/
18
+ #################
19
+
20
+ #################
21
+ ## Sublime
22
+ #################
23
+ *.sublime-project
24
+ *.sublime-workspace
25
+
26
+ #################
27
+ ## Emacs
28
+ #################
29
+ ~*
30
+ #################
31
+ #Mr Developer
32
+ #################
33
+ .mr.developer.cfg
34
+
35
+ #################
36
+ # idea IDE file
37
+ #################
38
+ .idea
39
+
40
+ #################
41
+ ## Eclipse
42
+ #################
43
+ *.pydevproject
44
+ .project
45
+ .metadata
46
+ bin/
47
+ tmp/
48
+ *.tmp
49
+ *.bak
50
+ *.swp
51
+ *~.nib
52
+ local.properties
53
+ .classpath
54
+ .settings/
55
+ .loadpath
56
+
57
+ # External tool builders
58
+ .externalToolBuilders/
59
+
60
+ # Locally stored "Eclipse launch configurations"
61
+ *.launch
62
+
63
+ # CDT-specific
64
+ .cproject
65
+
66
+ # PDT-specific
67
+ .buildpath
68
+
69
+ #################
70
+ ## Visual Studio
71
+ #################
72
+
73
+ ## Ignore Visual Studio temporary files, build results, and
74
+ ## files generated by popular Visual Studio add-ons.
75
+
76
+ # User-specific files
77
+ *.suo
78
+ *.user
79
+ *.sln.docstates
80
+
81
+ # Build results
82
+ [Dd]ebug/
83
+ [Rr]elease/
84
+ x64/
85
+ build/
86
+ [Bb]in/
87
+ [Oo]bj/
88
+
89
+ # MSTest test Results
90
+ [Tt]est[Rr]esult*/
91
+ [Bb]uild[Ll]og.*
92
+
93
+ *_i.c
94
+ *_p.c
95
+ *.ilk
96
+ *.meta
97
+ *.obj
98
+ *.pch
99
+ *.pdb
100
+ *.pgc
101
+ *.pgd
102
+ *.rsp
103
+ *.sbr
104
+ *.tlb
105
+ *.tli
106
+ *.tlh
107
+ *.tmp_proj
108
+ *.log
109
+ *.vspscc
110
+ *.vssscc
111
+ .builds
112
+ *.pidb
113
+ *.scc
114
+
115
+ # Visual C++ cache files
116
+ ipch/
117
+ *.aps
118
+ *.ncb
119
+ *.opensdf
120
+ *.sdf
121
+ *.cachefile
122
+
123
+ # Visual Studio profiler
124
+ *.psess
125
+ *.vsp
126
+ *.vspx
127
+
128
+ # Guidance Automation Toolkit
129
+ *.gpState
130
+
131
+ # ReSharper is a .NET coding add-in
132
+ _ReSharper*/
133
+ *.[Rr]e[Ss]harper
134
+
135
+ # TeamCity is a build add-in
136
+ _TeamCity*
137
+
138
+ # DotCover is a Code Coverage Tool
139
+ *.dotCover
140
+
141
+ # NCrunch
142
+ *.ncrunch*
143
+ .*crunch*.local.xml
144
+
145
+ # Installshield output folder
146
+ [Ee]xpress/
147
+
148
+ # DocProject is a documentation generator add-in
149
+ DocProject/buildhelp/
150
+ DocProject/Help/*.HxT
151
+ DocProject/Help/*.HxC
152
+ DocProject/Help/*.hhc
153
+ DocProject/Help/*.hhk
154
+ DocProject/Help/*.hhp
155
+ DocProject/Help/Html2
156
+ DocProject/Help/html
157
+
158
+ # Click-Once directory
159
+ publish/
160
+
161
+ # Publish Web Output
162
+ *.Publish.xml
163
+ *.pubxml
164
+ *.publishproj
165
+
166
+ # NuGet Packages Directory
167
+ ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
168
+ #packages/
169
+
170
+ # Windows Azure Build Output
171
+ csx
172
+ *.build.csdef
173
+
174
+ # Windows Store app package directory
175
+ AppPackages/
176
+
177
+ # Others
178
+ *.Cache
179
+ ClientBin/
180
+ [Ss]tyle[Cc]op.*
181
+ ~$*
182
+ *~
183
+ *.dbmdl
184
+ *.[Pp]ublish.xml
185
+ *.pfx
186
+ *.publishsettings
187
+
188
+ # RIA/Silverlight projects
189
+ Generated_Code/
190
+
191
+ # Backup & report files from converting an old project file to a newer
192
+ # Visual Studio version. Backup files are not needed, because we have git ;-)
193
+ _UpgradeReport_Files/
194
+ Backup*/
195
+ UpgradeLog*.XML
196
+ UpgradeLog*.htm
197
+
198
+ # SQL Server files
199
+ App_Data/*.mdf
200
+ App_Data/*.ldf
201
+
202
+ #############
203
+ # Node rules
204
+ #############
205
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
206
+ .grunt
207
+
208
+ # Dependency directory
209
+ # Commenting this out is preferred by some people, see
210
+ # https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git
211
+ node_modules
212
+
213
+ #############
214
+ ## Python
215
+ #############
216
+
217
+ *.py[cod]
218
+
219
+ # Packages
220
+ *.egg
221
+ *.egg-info
222
+ dist/
223
+ eggs/
224
+ parts/
225
+ var/
226
+ sdist/
227
+ develop-eggs/
228
+ .installed.cfg
229
+ **/.ipynb_*
230
+
231
+ # Installer logs
232
+ pip-log.txt
233
+
234
+ # Unit test / coverage reports
235
+ .coverage
236
+ .tox
237
+
238
+ #Translations
239
+ *.mo
240
+
241
+ #############
242
+ # Operating System Files
243
+ #############
244
+
245
+ #------------
246
+ ## Windows detritus
247
+ #------------
248
+
249
+ # Windows image file caches
250
+ Thumbs.db
251
+ ehthumbs.db
252
+
253
+ # Folder config file
254
+ Desktop.ini
255
+
256
+ # Recycle Bin used on file shares
257
+ $RECYCLE.BIN/
258
+
259
+ # Mac crap
260
+ .DS_Store
261
+
262
+ # Windows Installer files
263
+ *.cab
264
+ *.msi
265
+ *.msm
266
+ *.msp
267
+
268
+ # Windows shortcuts
269
+ *.lnk
270
+
271
+ # ------------
272
+ # OSX
273
+ # ------------
274
+ .AppleDouble
275
+ .LSOverride
276
+
277
+ # Files that might appear in the root of a volume
278
+ .DocumentRevisions-V100
279
+ .fseventsd
280
+ .Spotlight-V100
281
+ .TemporaryItems
282
+ .Trashes
283
+ .VolumeIcon.icns
284
+
285
+ # Directories potentially created on remote AFP share
286
+ .AppleDB
287
+ .AppleDesktop
288
+ Network Trash Folder
289
+ Temporary Items
290
+ .apdisk
291
+
292
+ #########
293
+ # Vagrant
294
+ #########
295
+ .vagrant
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to Scraping Pipeline are documented in this file.
4
+
5
+ ## 1.6.4 - 2026-12-06
6
+
7
+ ### Fixed
8
+
9
+ - Exclude the in-repository uv cache from source distributions to prevent
10
+ oversized PyPI uploads.
11
+ - Make tagged PyPI uploads retryable with `twine --skip-existing`.
12
+
13
+ ## 1.6.3 - 2026-12-06
14
+
15
+ ### Changed
16
+
17
+ - Migrate dependency management and packaging from Poetry to uv and
18
+ Hatchling.
19
+ - Replace the legacy `pycommons` dependency with
20
+ `pycraftbox-serialization`.
21
+ - Add explicit runtime dependency metadata for Playwright.
22
+ - Publish tagged releases to PyPI automatically with GitLab Trusted
23
+ Publishing.
24
+ - Update the README, examples, GitLab pipeline, and developer instructions
25
+ for the uv workflow.
26
+
27
+ ### Removed
28
+
29
+ - Remove the obsolete development Dockerfile.
30
+ - Remove `pyls-black`, which depends on an incompatible legacy Python
31
+ language server.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Eric Chastan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,284 @@
1
+ Metadata-Version: 2.5
2
+ Name: scraping-pipeline
3
+ Version: 1.6.4
4
+ Summary: scraping pipeline framework
5
+ Author: Eric Chastan
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.13
8
+ Requires-Dist: playwright>=1.61.0
9
+ Requires-Dist: pycraftbox-serialization>=4
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Scraping Pipeline
13
+
14
+ [![Pipeline status](https://gitlab.com/eric-chastan/scraping_pipeline/badges/main/pipeline.svg)](https://gitlab.com/eric-chastan/scraping_pipeline/-/pipelines?ref=main)
15
+ [![Latest release](https://gitlab.com/eric-chastan/scraping_pipeline/-/badges/release.svg)](https://gitlab.com/eric-chastan/scraping_pipeline/-/releases)
16
+ [![PyPI](https://img.shields.io/pypi/v/scraping-pipeline?logo=pypi&logoColor=white)](https://pypi.org/project/scraping-pipeline/)
17
+ [![Python 3.13+](https://img.shields.io/badge/Python-3.13%2B-3776AB?logo=python&logoColor=white)](https://www.python.org/)
18
+ [![Built with uv](https://img.shields.io/badge/Built%20with-uv-DE5FE8?logo=astral&logoColor=white)](https://docs.astral.sh/uv/)
19
+ [![GitLab](https://img.shields.io/badge/GitLab-repository-FC6D26?logo=gitlab&logoColor=white)](https://gitlab.com/eric-chastan/scraping_pipeline)
20
+
21
+ A Python framework for organizing browser automation as typed actions and
22
+ dependency graphs. It uses [Playwright](https://playwright.dev/python/) for
23
+ browser control and keeps execution order, input passing, and prerequisite
24
+ validation separate from the actions' implementation.
25
+
26
+ The project can represent a scraping workflow as one pipeline or as several
27
+ nested pipelines, keeping navigation, authentication, extraction, and export
28
+ steps independently testable and reusable.
29
+
30
+ ## Contents
31
+
32
+ - [What it provides](#what-it-provides)
33
+ - [Quick start](#quick-start)
34
+ - [Installation](#installation)
35
+ - [Publishing to PyPI](#publishing-to-pypi)
36
+ - [Documentation](#documentation)
37
+ - [License](#license)
38
+
39
+ ---
40
+
41
+ ## What it provides
42
+
43
+ | Component | Responsibility |
44
+ |---|---|
45
+ | `WebAction` | Defines one executable step and its optional prerequisites. |
46
+ | `Pipeline` | Validates dependencies, computes execution order, and passes action outputs. |
47
+ | Nested `Pipeline` | Groups related actions while exposing a designated terminal output. |
48
+ | `ActionOutput` | Defines typed data emitted by an action. |
49
+ | `PlaywrightScraper` | Manages a Playwright browser, context, and pages when desired. |
50
+
51
+ The framework validates dependency cycles and missing prerequisites before
52
+ execution. Actions can exchange typed outputs by parameter name, with
53
+ `FromAction` available when multiple actions produce the same field. Pause
54
+ points support browser inspection before, after, or around selected actions.
55
+
56
+ `WebAction` requirements are evaluated across the complete pipeline tree. A
57
+ matching prerequisite can therefore run in a parent, sibling, or nested
58
+ pipeline rather than having to be adjacent to the consuming action.
59
+
60
+ ---
61
+
62
+ ## Quick start
63
+
64
+ ```python
65
+ from playwright.sync_api import sync_playwright
66
+
67
+ from scraping.core.pipeline import Pipeline
68
+ from scraping.examples.actions.quotes_actions import (
69
+ QuotesNavigateAction,
70
+ QuotesLoginAction,
71
+ QuotesTopTagSelectAction,
72
+ )
73
+
74
+ with sync_playwright() as p:
75
+ browser = p.chromium.launch(headless=False)
76
+ page = browser.new_page()
77
+
78
+ # 1. Create your actions
79
+ navigate = QuotesNavigateAction(page)
80
+ login = QuotesLoginAction(page)
81
+ tag = QuotesTopTagSelectAction(page, tag_index=1)
82
+
83
+ # 2. Build the pipeline and declare prerequisites with `after`
84
+ pipeline = Pipeline()
85
+ pipeline.add_pipeline_action(navigate)
86
+ pipeline.add_pipeline_action(login, after=navigate)
87
+ pipeline.add_pipeline_action(tag, after=login)
88
+
89
+ # 3. Execute the validated dependency graph.
90
+ pipeline.run()
91
+
92
+ browser.close()
93
+ ```
94
+
95
+ ### Debugging with pauses
96
+
97
+ Freeze the browser before and/or after specific actions to inspect state. Each
98
+ entry references an action by its **name** or by the **`WebAction` instance**,
99
+ and both forms can be mixed:
100
+
101
+ ```python
102
+ from scraping.core.web_action import PauseType
103
+
104
+ pipeline.add_pauses(
105
+ [
106
+ (login, PauseType.AFTER), # by instance
107
+ ("Quotes Top Tag Select", PauseType.BEFORE), # by name
108
+ ]
109
+ )
110
+ pipeline.run()
111
+ ```
112
+
113
+ ### Managing the browser with `PlaywrightScraper`
114
+
115
+ Rather than wiring the browser, context, and page by hand, compose a
116
+ `PlaywrightScraper`. It starts Playwright, launches Chromium, configures the
117
+ browser context, opens pages via `new_page()`, runs the pipeline you pass to
118
+ `run()`, and keeps the session alive until the window is closed:
119
+
120
+ ```python
121
+ from scraping.core.pipeline import Pipeline
122
+ from scraping.core.playwright_scraper import PlaywrightScraper
123
+ from scraping.examples.actions.quotes_actions import (
124
+ QuotesNavigateAction,
125
+ QuotesLoginAction,
126
+ QuotesTopTagSelectAction,
127
+ )
128
+
129
+ # Delegate browser and context management to PlaywrightScraper.
130
+ scraper = PlaywrightScraper()
131
+ page = scraper.new_page("https://quotes.toscrape.com")
132
+
133
+ navigate = QuotesNavigateAction(page)
134
+ login = QuotesLoginAction(page)
135
+ tag = QuotesTopTagSelectAction(page, tag_index=1)
136
+
137
+ pipeline = Pipeline()
138
+ pipeline.add_pipeline_action(navigate)
139
+ pipeline.add_pipeline_action(login, after=navigate)
140
+ pipeline.add_pipeline_action(tag, after=login)
141
+
142
+ scraper.run(pipeline)
143
+ ```
144
+
145
+ ### Composing pipelines sequentially
146
+
147
+ A `Pipeline` is itself a node, so you can **nest whole pipelines** and run them
148
+ one after another. A successor's first action only starts once every action of
149
+ its predecessor has finished:
150
+
151
+ ```python
152
+ from scraping.core.pipeline import Pipeline
153
+
154
+ # Phase 1: open the site and authenticate.
155
+ setup = Pipeline(name="Setup")
156
+ setup.add_pipeline_action(navigate)
157
+ setup.add_pipeline_action(login, after=navigate)
158
+
159
+ # Phase 2: select a tag and scrape (runs after "Setup").
160
+ scrape = Pipeline(name="Scrape")
161
+ scrape.add_pipeline_action(tag)
162
+ scrape.add_pipeline_action(save, after=tag)
163
+
164
+ # Root pipeline: "Scrape" runs after "Setup" completes.
165
+ root = Pipeline(name="Root")
166
+ root.add_pipeline_action(setup)
167
+ root.add_pipeline_action(scrape, after=setup)
168
+ root.run()
169
+ ```
170
+
171
+ A nested pipeline is a **gray box** on the data layer: transparent for inputs,
172
+ opaque for outputs. Its actions can read any output produced earlier in the
173
+ enclosing pipeline (a preceding `WebAction` or nested pipeline), so an injection
174
+ producer and its consumer no longer need to live in the *same* pipeline. In the
175
+ other direction, the nested pipeline exposes only the output of its terminal
176
+ action (re-emitted under its `name`); its internal actions' outputs stay
177
+ private.
178
+
179
+ Requirements, by contrast, are **transparent both ways**: because an action's
180
+ `requires()` is declared independently of any pipeline, requirement satisfaction
181
+ is evaluated globally. A prerequisite run in one pipeline (here `login` in
182
+ "Setup") satisfies the `requires()` of an action in another (a step in
183
+ "Scrape"), even across nesting boundaries.
184
+
185
+ ---
186
+
187
+ ## Installation
188
+
189
+ Install the published package:
190
+
191
+ ```bash
192
+ uv add scraping-pipeline
193
+ uv run playwright install chromium
194
+ ```
195
+
196
+ For a checkout of the repository, create the development environment with
197
+ [uv](https://docs.astral.sh/uv/):
198
+
199
+ ```bash
200
+ uv sync
201
+ uv run playwright install chromium
202
+ ```
203
+
204
+ The `[tool.uv.sources]` entries use editable sibling checkouts of PyCraftBox for
205
+ local development. They are development sources only: the published package
206
+ metadata contains normal version constraints for PyCraftBox.
207
+
208
+ Then run project commands through `uv`, for example:
209
+
210
+ ```bash
211
+ uv run pytest
212
+ ```
213
+
214
+ ## Publishing to PyPI
215
+
216
+ GitLab CI validates, tests, and builds the project on branches and merge
217
+ requests. Tagged pipelines automatically publish the wheel and source archive to
218
+ PyPI through Trusted Publishing after all preceding jobs succeed.
219
+
220
+ CI disables `[tool.uv.sources]` with `--no-sources`. Each validation job first
221
+ relocks the dependencies against the public package index:
222
+
223
+ ```bash
224
+ uv lock --no-sources
225
+ uv sync
226
+ ```
227
+
228
+ The build uses the same mode, so the source archive and wheel are built only
229
+ against publishable dependency constraints:
230
+
231
+ ```bash
232
+ uv lock --no-sources
233
+ uv build --no-sources --out-dir dist
234
+ ```
235
+
236
+ This makes the CI artifacts equivalent to what an external checkout can resolve
237
+ and prevents local PyCraftBox paths from leaking into release metadata. The
238
+ `publish:pypi` job runs only for tags, obtains a short-lived OIDC token for the
239
+ `pypi` GitLab environment, checks that the tag matches the package version, and
240
+ uploads `dist/` with Twine. Existing release files are skipped, so a retry can
241
+ complete a partially published release without reuploading files already
242
+ accepted by PyPI. No persistent PyPI token is stored in the repository.
243
+
244
+ For a first publication, configure the `scraping-pipeline` PyPI project with
245
+ these Trusted Publisher values:
246
+
247
+ | Setting | Value |
248
+ |---|---|
249
+ | Publisher | GitLab CI/CD |
250
+ | Namespace | `eric-chastan` |
251
+ | Project | `scraping_pipeline` |
252
+ | Top-level CI file | `.gitlab-ci.yml` |
253
+ | Environment | `pypi` |
254
+
255
+ To publish a release, update the project version, commit the changes, and push a
256
+ matching `v` tag:
257
+
258
+ ```bash
259
+ git tag v1.6.4
260
+ git push origin v1.6.4
261
+ ```
262
+
263
+ The publication job rejects a tag unless its version, without the `v` prefix,
264
+ exactly matches `uv version --short`.
265
+
266
+ ---
267
+
268
+ ## Documentation
269
+
270
+ - **[Pipeline User Guide](docs/PIPELINE_USER_GUIDE.md)** — Concepts, examples,
271
+ action definitions, pipeline composition, output injection, validation, and
272
+ debugging.
273
+ - **[Design Recommendations](docs/pipeline_design_recommendations.md)** —
274
+ Rationale and implementation guidance for the pipeline architecture and its
275
+ data flow.
276
+
277
+ Runnable examples are available in
278
+ [`python/main/scraping/examples`](python/main/scraping/examples).
279
+
280
+ ---
281
+
282
+ ## License
283
+
284
+ See [LICENSE](LICENSE).