hfpclawer 0.4.8__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 (52) hide show
  1. hfpclawer-0.4.8/LICENSE +21 -0
  2. hfpclawer-0.4.8/PKG-INFO +238 -0
  3. hfpclawer-0.4.8/README.md +192 -0
  4. hfpclawer-0.4.8/hfpapers/__init__.py +5 -0
  5. hfpclawer-0.4.8/hfpapers/arxiv_search.py +367 -0
  6. hfpclawer-0.4.8/hfpapers/cli.py +1216 -0
  7. hfpclawer-0.4.8/hfpapers/code_matcher.py +361 -0
  8. hfpclawer-0.4.8/hfpapers/config.py +224 -0
  9. hfpclawer-0.4.8/hfpapers/download_queue.py +592 -0
  10. hfpclawer-0.4.8/hfpapers/enrich_entities.py +301 -0
  11. hfpclawer-0.4.8/hfpapers/evolved.py +411 -0
  12. hfpclawer-0.4.8/hfpapers/fix_entity_map.py +161 -0
  13. hfpclawer-0.4.8/hfpapers/hardware.py +89 -0
  14. hfpclawer-0.4.8/hfpapers/items.py +35 -0
  15. hfpclawer-0.4.8/hfpapers/logger.py +318 -0
  16. hfpclawer-0.4.8/hfpapers/mcp_server.py +400 -0
  17. hfpclawer-0.4.8/hfpapers/middlewares.py +232 -0
  18. hfpclawer-0.4.8/hfpapers/paper_store.py +1053 -0
  19. hfpclawer-0.4.8/hfpapers/pdf_downloader_async.py +245 -0
  20. hfpclawer-0.4.8/hfpapers/pipelines.py +266 -0
  21. hfpclawer-0.4.8/hfpapers/search_queue.py +389 -0
  22. hfpclawer-0.4.8/hfpapers/searcher_registry.py +393 -0
  23. hfpclawer-0.4.8/hfpapers/settings.py +81 -0
  24. hfpclawer-0.4.8/hfpapers/settings_redis.py +52 -0
  25. hfpclawer-0.4.8/hfpapers/sources.py +434 -0
  26. hfpclawer-0.4.8/hfpapers/spiders/__init__.py +0 -0
  27. hfpclawer-0.4.8/hfpapers/spiders/hfspider.py +175 -0
  28. hfpclawer-0.4.8/hfpapers/spiders/multi_source_spider.py +412 -0
  29. hfpclawer-0.4.8/hfpclawer/__init__.py +5 -0
  30. hfpclawer-0.4.8/hfpclawer/audit.py +352 -0
  31. hfpclawer-0.4.8/hfpclawer/download/__init__.py +20 -0
  32. hfpclawer-0.4.8/hfpclawer/download/base.py +256 -0
  33. hfpclawer-0.4.8/hfpclawer/download/kaggle.py +502 -0
  34. hfpclawer-0.4.8/hfpclawer/download/monitor.py +198 -0
  35. hfpclawer-0.4.8/hfpclawer/download/oai.py +461 -0
  36. hfpclawer-0.4.8/hfpclawer/download/resume.py +7 -0
  37. hfpclawer-0.4.8/hfpclawer.egg-info/PKG-INFO +238 -0
  38. hfpclawer-0.4.8/hfpclawer.egg-info/SOURCES.txt +50 -0
  39. hfpclawer-0.4.8/hfpclawer.egg-info/dependency_links.txt +1 -0
  40. hfpclawer-0.4.8/hfpclawer.egg-info/entry_points.txt +2 -0
  41. hfpclawer-0.4.8/hfpclawer.egg-info/requires.txt +26 -0
  42. hfpclawer-0.4.8/hfpclawer.egg-info/top_level.txt +2 -0
  43. hfpclawer-0.4.8/pyproject.toml +95 -0
  44. hfpclawer-0.4.8/setup.cfg +4 -0
  45. hfpclawer-0.4.8/tests/test_audit.py +473 -0
  46. hfpclawer-0.4.8/tests/test_cli.py +151 -0
  47. hfpclawer-0.4.8/tests/test_config.py +75 -0
  48. hfpclawer-0.4.8/tests/test_evolved.py +104 -0
  49. hfpclawer-0.4.8/tests/test_hardware.py +34 -0
  50. hfpclawer-0.4.8/tests/test_integration.py +820 -0
  51. hfpclawer-0.4.8/tests/test_paper_store.py +161 -0
  52. hfpclawer-0.4.8/tests/test_sources.py +94 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 listen_at_zhejianglab.org
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,238 @@
1
+ Metadata-Version: 2.4
2
+ Name: hfpclawer
3
+ Version: 0.4.8
4
+ Summary: Multi-source academic paper clawler for PDE/neural operator/physics-informed ML — OAI-PMH download + PDF download + SQLite paper_store + Cross-Ref + MCP server
5
+ Author: Li Shen
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/diamond2nv/hfpapers-crawler
8
+ Project-URL: Repository, https://github.com/diamond2nv/hfpapers-crawler
9
+ Project-URL: Documentation, https://github.com/diamond2nv/hfpapers-crawler
10
+ Keywords: pdf,clawler,snowflake,crossref,scrapy,pytorch,arxiv,neural-operator,paper-store
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: pyyaml>=6.0
24
+ Requires-Dist: python-dotenv>=1.0
25
+ Requires-Dist: requests>=2.28
26
+ Requires-Dist: beautifulsoup4>=4.12
27
+ Requires-Dist: lxml>=4.9
28
+ Requires-Dist: typer>=0.9
29
+ Provides-Extra: llm
30
+ Requires-Dist: litellm; extra == "llm"
31
+ Provides-Extra: pdf
32
+ Requires-Dist: pymupdf4llm; extra == "pdf"
33
+ Provides-Extra: scrapy
34
+ Requires-Dist: scrapy>=2.10; extra == "scrapy"
35
+ Requires-Dist: scrapy-redis; extra == "scrapy"
36
+ Provides-Extra: dev
37
+ Requires-Dist: hfpclawer[scrapy]; extra == "dev"
38
+ Requires-Dist: hfpclawer[llm]; extra == "dev"
39
+ Requires-Dist: hfpclawer[pdf]; extra == "dev"
40
+ Requires-Dist: ruff; extra == "dev"
41
+ Requires-Dist: pyright; extra == "dev"
42
+ Requires-Dist: pytest>=7.0; extra == "dev"
43
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
44
+ Requires-Dist: pytest-mock>=3.10; extra == "dev"
45
+ Dynamic: license-file
46
+
47
+ <p align="center">
48
+ <a href="README.md">English</a> | <a href="docs/cn/README.zh-CN.md">简体中文</a>
49
+ </p>
50
+
51
+ # hfpapers-clawler
52
+
53
+ > **Naming philosophy**: `claw` (sharp grasp) ≠ `crawl` (creep).
54
+ > `hfpclawer` = **H**ugging**F**ace **P**apers + **claw** + **er**
55
+ > = "A sharp tool that claws HF papers with precision" 🦞
56
+ >
57
+ > Not a crawler — faster, sharper, more precise. Same series: OpenClaw, Hermes Agent ecosystem.
58
+
59
+ A multi-source academic paper clawler for PDE / neural operator / physics-informed ML.
60
+ Built with SQLite paper_store, Crossref cross-validation, anti-crawl Scrapy pipelines, and MCP server.
61
+
62
+ ---
63
+
64
+ ## Quick Install
65
+
66
+ ---
67
+
68
+ ## Quick Install
69
+
70
+ ```bash
71
+ pip install hfpclawer
72
+ ```
73
+
74
+ ### Dependencies
75
+
76
+ - **Core** (auto-installed): pyyaml, requests, beautifulsoup4, typer, etc.
77
+ - **LLM features** (optional): `pip install hfpclawer[llm]` — for `sniff` / `analyze` commands
78
+ - **PDF conversion** (optional): `pip install hfpclawer[pdf]`
79
+ - **Scrapy spiders** (optional): `pip install hfpclawer[scrapy]`
80
+ - **Dev** (testing): `pip install hfpclawer[dev]`
81
+ - **arXiv local search** (optional): `pip install hfpclawer[arxiv]` — requires access to private GitLab repo
82
+
83
+ ### Local Development
84
+
85
+ ```bash
86
+ git clone <your-repo>
87
+ cd hfpapers-clawler
88
+
89
+ # Create virtual environment
90
+ python3 -m venv venv
91
+ source venv/bin/activate
92
+
93
+ # Install in editable mode with dev dependencies
94
+ pip install -e ".[dev]"
95
+
96
+ # Verify
97
+ hfpclawer --help
98
+ ```
99
+
100
+ ### Configuration
101
+
102
+ First run `hfpclawer init` to generate config and env template:
103
+
104
+ ```bash
105
+ hfpclawer init --quick # Quick mode (defaults)
106
+ # or
107
+ hfpclawer init # Interactive wizard
108
+ cp .env.template .env # Fill in API keys
109
+ # Edit config.yaml to customize search queries
110
+ ```
111
+
112
+ Or manually create files (see [docs/USAGE.md](docs/USAGE.md) for full reference):
113
+
114
+ ---
115
+
116
+ ## CLI Commands
117
+
118
+ ```bash
119
+ # Search for new papers
120
+ hfpclawer search # Default 3 pages, threshold 30
121
+ hfpclawer search --max-pages 5 # More pages
122
+ hfpclawer search --dry-run # Show only, don't save
123
+
124
+ # Full pipeline: search → download → convert
125
+ hfpclawer full
126
+
127
+ # SQLite Paper Store operations
128
+ hfpclawer store stats # Storage statistics
129
+ hfpclawer store search # List all papers
130
+ hfpclawer store search --keyword "FNO"
131
+ hfpclawer store verify --aid 2301.11167
132
+
133
+ # Download & convert
134
+ hfpclawer download # Download top-20 PDFs
135
+ hfpclawer convert # PDF → Markdown
136
+
137
+ # MCP Server (for Hermes Agent / OpenCode)
138
+ hfpclawer mcp # Default port :8765
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Python API
144
+
145
+ ```python
146
+ from hfpapers.paper_store import PaperStore, PaperRecord, ensure_paper
147
+
148
+ # Create a store
149
+ store = PaperStore(db_path="/tmp/papers.db")
150
+
151
+ # Add a paper
152
+ rec = PaperRecord(
153
+ title="Fourier Neural Operator",
154
+ abstract="Learning PDE solution operators with Fourier transforms",
155
+ year=2023,
156
+ source="my_app",
157
+ relevance=90,
158
+ )
159
+ sf_id = store.upsert_paper(rec)
160
+ store.add_identifier(sf_id, "arxiv", "2010.08895")
161
+
162
+ # Search
163
+ papers = store.search_papers("neural operator")
164
+ for p in papers:
165
+ print(f"[{p.relevance}] {p.title}")
166
+
167
+ # Hardware probe
168
+ from hfpapers.hardware import HardwareProbe
169
+ hw = HardwareProbe()
170
+ print(f"Hardware: {hw.summary()}")
171
+ ```
172
+
173
+ ---
174
+
175
+ ## MCP Server
176
+
177
+ hfpapers-clawler ships with a built-in MCP server for AI agent integration:
178
+
179
+ ```bash
180
+ hfpclawer mcp
181
+ ```
182
+
183
+ Register in Hermes Agent `~/.hermes/config.yaml`:
184
+
185
+ ```yaml
186
+ mcp:
187
+ servers:
188
+ hfpapers:
189
+ command: "hfpclawer"
190
+ args: ["mcp", "--port", "8765"]
191
+ ```
192
+
193
+ Available MCP tools: `hfpclawer_search`, `hfpclawer_download`, `hfpclawer_convert`, `hfpclawer_info`, `hfpclawer_list`, `hfpclawer_stats`, `hfpclawer_full`.
194
+
195
+ ---
196
+
197
+ ## Architecture
198
+
199
+ ```
200
+ ┌─ CLI (Typer) ─┐ ┌─ MCP Server ─┐
201
+ └──────┬────────┘ └──────┬───────┘
202
+ └────────┬──────────┘
203
+
204
+ ┌─ Scrapy Layer (Multi-source) ───────────┐
205
+ │ ArxivSearchSpider | OpenReviewSpider │
206
+ │ HFPapersSpider | MultiSourceSpider │
207
+ │ Middleware: UA random, delay, proxy... │
208
+ │ Pipeline: Store→Classify→Export→DL │
209
+ └──────────────────┬──────────────────────┘
210
+
211
+ ┌─ Paper Store (SQLite) ──────────────────┐
212
+ │ papers (Snowflake ID) | identifiers │
213
+ │ crossref_cache | CrossrefClient │
214
+ └─────────────────────────────────────────┘
215
+ ```
216
+
217
+ ---
218
+
219
+ ## Tests
220
+
221
+ ```bash
222
+ pip install -e ".[dev]"
223
+ pytest tests/ -v # Run all tests
224
+ pytest tests/ --cov=hfpapers # With coverage
225
+ ```
226
+
227
+ ---
228
+
229
+ ## License
230
+
231
+ MIT
232
+
233
+ ## Links
234
+
235
+ - [Full Usage Guide](docs/USAGE.md)
236
+ - [Architecture](docs/ARCHITECTURE.md)
237
+ - [Developer Guide](docs/DEVELOPMENT.md)
238
+ - [Paper Store Reference](docs/paper_store.md)
@@ -0,0 +1,192 @@
1
+ <p align="center">
2
+ <a href="README.md">English</a> | <a href="docs/cn/README.zh-CN.md">简体中文</a>
3
+ </p>
4
+
5
+ # hfpapers-clawler
6
+
7
+ > **Naming philosophy**: `claw` (sharp grasp) ≠ `crawl` (creep).
8
+ > `hfpclawer` = **H**ugging**F**ace **P**apers + **claw** + **er**
9
+ > = "A sharp tool that claws HF papers with precision" 🦞
10
+ >
11
+ > Not a crawler — faster, sharper, more precise. Same series: OpenClaw, Hermes Agent ecosystem.
12
+
13
+ A multi-source academic paper clawler for PDE / neural operator / physics-informed ML.
14
+ Built with SQLite paper_store, Crossref cross-validation, anti-crawl Scrapy pipelines, and MCP server.
15
+
16
+ ---
17
+
18
+ ## Quick Install
19
+
20
+ ---
21
+
22
+ ## Quick Install
23
+
24
+ ```bash
25
+ pip install hfpclawer
26
+ ```
27
+
28
+ ### Dependencies
29
+
30
+ - **Core** (auto-installed): pyyaml, requests, beautifulsoup4, typer, etc.
31
+ - **LLM features** (optional): `pip install hfpclawer[llm]` — for `sniff` / `analyze` commands
32
+ - **PDF conversion** (optional): `pip install hfpclawer[pdf]`
33
+ - **Scrapy spiders** (optional): `pip install hfpclawer[scrapy]`
34
+ - **Dev** (testing): `pip install hfpclawer[dev]`
35
+ - **arXiv local search** (optional): `pip install hfpclawer[arxiv]` — requires access to private GitLab repo
36
+
37
+ ### Local Development
38
+
39
+ ```bash
40
+ git clone <your-repo>
41
+ cd hfpapers-clawler
42
+
43
+ # Create virtual environment
44
+ python3 -m venv venv
45
+ source venv/bin/activate
46
+
47
+ # Install in editable mode with dev dependencies
48
+ pip install -e ".[dev]"
49
+
50
+ # Verify
51
+ hfpclawer --help
52
+ ```
53
+
54
+ ### Configuration
55
+
56
+ First run `hfpclawer init` to generate config and env template:
57
+
58
+ ```bash
59
+ hfpclawer init --quick # Quick mode (defaults)
60
+ # or
61
+ hfpclawer init # Interactive wizard
62
+ cp .env.template .env # Fill in API keys
63
+ # Edit config.yaml to customize search queries
64
+ ```
65
+
66
+ Or manually create files (see [docs/USAGE.md](docs/USAGE.md) for full reference):
67
+
68
+ ---
69
+
70
+ ## CLI Commands
71
+
72
+ ```bash
73
+ # Search for new papers
74
+ hfpclawer search # Default 3 pages, threshold 30
75
+ hfpclawer search --max-pages 5 # More pages
76
+ hfpclawer search --dry-run # Show only, don't save
77
+
78
+ # Full pipeline: search → download → convert
79
+ hfpclawer full
80
+
81
+ # SQLite Paper Store operations
82
+ hfpclawer store stats # Storage statistics
83
+ hfpclawer store search # List all papers
84
+ hfpclawer store search --keyword "FNO"
85
+ hfpclawer store verify --aid 2301.11167
86
+
87
+ # Download & convert
88
+ hfpclawer download # Download top-20 PDFs
89
+ hfpclawer convert # PDF → Markdown
90
+
91
+ # MCP Server (for Hermes Agent / OpenCode)
92
+ hfpclawer mcp # Default port :8765
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Python API
98
+
99
+ ```python
100
+ from hfpapers.paper_store import PaperStore, PaperRecord, ensure_paper
101
+
102
+ # Create a store
103
+ store = PaperStore(db_path="/tmp/papers.db")
104
+
105
+ # Add a paper
106
+ rec = PaperRecord(
107
+ title="Fourier Neural Operator",
108
+ abstract="Learning PDE solution operators with Fourier transforms",
109
+ year=2023,
110
+ source="my_app",
111
+ relevance=90,
112
+ )
113
+ sf_id = store.upsert_paper(rec)
114
+ store.add_identifier(sf_id, "arxiv", "2010.08895")
115
+
116
+ # Search
117
+ papers = store.search_papers("neural operator")
118
+ for p in papers:
119
+ print(f"[{p.relevance}] {p.title}")
120
+
121
+ # Hardware probe
122
+ from hfpapers.hardware import HardwareProbe
123
+ hw = HardwareProbe()
124
+ print(f"Hardware: {hw.summary()}")
125
+ ```
126
+
127
+ ---
128
+
129
+ ## MCP Server
130
+
131
+ hfpapers-clawler ships with a built-in MCP server for AI agent integration:
132
+
133
+ ```bash
134
+ hfpclawer mcp
135
+ ```
136
+
137
+ Register in Hermes Agent `~/.hermes/config.yaml`:
138
+
139
+ ```yaml
140
+ mcp:
141
+ servers:
142
+ hfpapers:
143
+ command: "hfpclawer"
144
+ args: ["mcp", "--port", "8765"]
145
+ ```
146
+
147
+ Available MCP tools: `hfpclawer_search`, `hfpclawer_download`, `hfpclawer_convert`, `hfpclawer_info`, `hfpclawer_list`, `hfpclawer_stats`, `hfpclawer_full`.
148
+
149
+ ---
150
+
151
+ ## Architecture
152
+
153
+ ```
154
+ ┌─ CLI (Typer) ─┐ ┌─ MCP Server ─┐
155
+ └──────┬────────┘ └──────┬───────┘
156
+ └────────┬──────────┘
157
+
158
+ ┌─ Scrapy Layer (Multi-source) ───────────┐
159
+ │ ArxivSearchSpider | OpenReviewSpider │
160
+ │ HFPapersSpider | MultiSourceSpider │
161
+ │ Middleware: UA random, delay, proxy... │
162
+ │ Pipeline: Store→Classify→Export→DL │
163
+ └──────────────────┬──────────────────────┘
164
+
165
+ ┌─ Paper Store (SQLite) ──────────────────┐
166
+ │ papers (Snowflake ID) | identifiers │
167
+ │ crossref_cache | CrossrefClient │
168
+ └─────────────────────────────────────────┘
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Tests
174
+
175
+ ```bash
176
+ pip install -e ".[dev]"
177
+ pytest tests/ -v # Run all tests
178
+ pytest tests/ --cov=hfpapers # With coverage
179
+ ```
180
+
181
+ ---
182
+
183
+ ## License
184
+
185
+ MIT
186
+
187
+ ## Links
188
+
189
+ - [Full Usage Guide](docs/USAGE.md)
190
+ - [Architecture](docs/ARCHITECTURE.md)
191
+ - [Developer Guide](docs/DEVELOPMENT.md)
192
+ - [Paper Store Reference](docs/paper_store.md)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """hfpclawer -- Multi-source academic paper crawler for OpenClaw or Hermes Agent"""
4
+
5
+ __version__ = "0.4.8"