openaleph-client 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.
- openaleph_client-1.0.1/LICENSE +22 -0
- openaleph_client-1.0.1/PKG-INFO +165 -0
- openaleph_client-1.0.1/README.md +116 -0
- openaleph_client-1.0.1/openaleph/__init__.py +0 -0
- openaleph_client-1.0.1/openaleph/api.py +525 -0
- openaleph_client-1.0.1/openaleph/cli.py +411 -0
- openaleph_client-1.0.1/openaleph/crawldir.py +238 -0
- openaleph_client-1.0.1/openaleph/errors.py +22 -0
- openaleph_client-1.0.1/openaleph/fetchdir.py +77 -0
- openaleph_client-1.0.1/openaleph/settings.py +13 -0
- openaleph_client-1.0.1/openaleph/util.py +20 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/PKG-INFO +165 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/SOURCES.txt +17 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/dependency_links.txt +1 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/entry_points.txt +2 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/requires.txt +13 -0
- openaleph_client-1.0.1/openaleph_client.egg-info/top_level.txt +1 -0
- openaleph_client-1.0.1/pyproject.toml +44 -0
- openaleph_client-1.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-2020: Journalism Development Network, Inc.
|
|
4
|
+
Copyright (c) 2025: Data and Research Center - DARC
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openaleph-client
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Python client for the OpenAleph data API
|
|
5
|
+
Author-email: Data and Research Center - DARC <hi@dataresearchcenter.org>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2018-2020: Journalism Development Network, Inc.
|
|
9
|
+
Copyright (c) 2025: Data and Research Center - DARC
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Repository, https://github.com/dataresearchcenter/opal-client
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Requires-Python: >=3.7
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
License-File: LICENSE
|
|
36
|
+
Requires-Dist: banal>=1.0.1
|
|
37
|
+
Requires-Dist: pyyaml
|
|
38
|
+
Requires-Dist: requests>=2.21.0
|
|
39
|
+
Requires-Dist: requests_toolbelt>=0.9.1
|
|
40
|
+
Requires-Dist: click>=7.0
|
|
41
|
+
Provides-Extra: dev
|
|
42
|
+
Requires-Dist: mypy; extra == "dev"
|
|
43
|
+
Requires-Dist: wheel; extra == "dev"
|
|
44
|
+
Requires-Dist: pytest; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-mock>=1.10.0; extra == "dev"
|
|
46
|
+
Requires-Dist: types-requests; extra == "dev"
|
|
47
|
+
Requires-Dist: types-setuptools; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# OpenAleph
|
|
51
|
+
|
|
52
|
+
Python client for the OpenAleph data API.
|
|
53
|
+
|
|
54
|
+
## Installation
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install openaleph
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Command-Line Interface
|
|
61
|
+
|
|
62
|
+
_All commands share the same global options:_
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
openaleph --host URL --api-key KEY [--retries N] <command> [options]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `--host` OpenAleph API host URL (default from `OPAL_HOST` env var)
|
|
69
|
+
- `--api-key` API key for authentication (default from `OPAL_API_KEY` env var)
|
|
70
|
+
- `--retries` Number of retry attempts on server failure (default: 5)
|
|
71
|
+
|
|
72
|
+
### `crawldir`
|
|
73
|
+
|
|
74
|
+
Recursively upload the contents of a folder to a collection, with optional pause/resume:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
openaleph crawldir -f <foreign-id> [--resume] [--parallel N] [--noindex] [--casefile] [-l LANG] <path>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- `-f, --foreign-id` Foreign-ID of the target collection (required)
|
|
81
|
+
- `--resume` Resume from an existing state database; omit to start fresh (this will delete the state file!)
|
|
82
|
+
- `-p, --parallel N` Number of parallel upload threads (default: 1)
|
|
83
|
+
- `-i, --noindex` Skip indexing on ingest
|
|
84
|
+
- `--casefile` Treat files as case files
|
|
85
|
+
- `-l, --language LANG` Language hints (ISO 639; repeatable)
|
|
86
|
+
|
|
87
|
+
### `fetchdir`
|
|
88
|
+
|
|
89
|
+
Download all entities in a collection (or a single entity) into a folder tree:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
openaleph fetchdir -f <foreign-id> [-e <entity-id>] [-p <path>] [--overwrite]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Other commands
|
|
96
|
+
|
|
97
|
+
- `reingest` Re-ingest all documents in a collection
|
|
98
|
+
- `reindex` Re-index all entities in a collection
|
|
99
|
+
- `delete` Delete a collection and its contents
|
|
100
|
+
- `flush` Delete all contents of a collection
|
|
101
|
+
- `write-entity` Index a single entity from stdin
|
|
102
|
+
- `write-entities` Bulk-index entities from stdin
|
|
103
|
+
- `stream-entities` Stream entities to stdout
|
|
104
|
+
- `entitysets` List entity sets
|
|
105
|
+
- `entitysetitems` List items in an entity set
|
|
106
|
+
- `make-list` Create a new list entity set
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## State Persistence
|
|
111
|
+
|
|
112
|
+
When running **crawldir**, OpenAleph maintains a small SQLite database file in your crawl root:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
<crawl-root>/.openaleph_crawl_state.db
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- **Purpose**: track which files have already been successfully uploaded.
|
|
119
|
+
- **Resume support**:
|
|
120
|
+
- Passing `--resume` skips any files recorded in this DB.
|
|
121
|
+
- Omitting `--resume` deletes any existing state DB and starts fresh.
|
|
122
|
+
- **Thread-safe**: uploads are recorded under a lock to support parallel threads.
|
|
123
|
+
- **Update datasets later**: The db file stays in the directory, allowing you to update your local repository at any time and only sync the new files to OpenAleph.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Ignore File
|
|
128
|
+
|
|
129
|
+
You can create a file named:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
<crawl-root>/.openalephignore
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
and list glob patterns for any files or directories you want to skip entirely:
|
|
136
|
+
|
|
137
|
+
```text
|
|
138
|
+
# Skip hidden files
|
|
139
|
+
.*
|
|
140
|
+
|
|
141
|
+
# Common junk
|
|
142
|
+
.DS_Store
|
|
143
|
+
Thumbs.db
|
|
144
|
+
|
|
145
|
+
# Temporary directories
|
|
146
|
+
tmp/
|
|
147
|
+
build/
|
|
148
|
+
|
|
149
|
+
# Log files
|
|
150
|
+
*.log
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- Patterns are matched against the **relative path** of each file or folder.
|
|
154
|
+
- A pattern ending in `/` only matches directories (and their contents).
|
|
155
|
+
- Blank lines and lines beginning with `#` are ignored.
|
|
156
|
+
- Anything matched here is never enqueued or uploaded.
|
|
157
|
+
- the `.openalephignore` file itself is ignored by default, and so is the state file
|
|
158
|
+
|
|
159
|
+
## Final Report
|
|
160
|
+
|
|
161
|
+
After a crawl completes, OpenAleph will print a summary to the console. If any failures occurred, by default a file is written to:
|
|
162
|
+
|
|
163
|
+
`<crawl-root>/.openaleph-failed.txt`
|
|
164
|
+
|
|
165
|
+
It contains one relative path per line for each file that could not be uploaded permanently. You can inspect this file to retry or investigate failures.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# OpenAleph
|
|
2
|
+
|
|
3
|
+
Python client for the OpenAleph data API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install openaleph
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Command-Line Interface
|
|
12
|
+
|
|
13
|
+
_All commands share the same global options:_
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
openaleph --host URL --api-key KEY [--retries N] <command> [options]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
- `--host` OpenAleph API host URL (default from `OPAL_HOST` env var)
|
|
20
|
+
- `--api-key` API key for authentication (default from `OPAL_API_KEY` env var)
|
|
21
|
+
- `--retries` Number of retry attempts on server failure (default: 5)
|
|
22
|
+
|
|
23
|
+
### `crawldir`
|
|
24
|
+
|
|
25
|
+
Recursively upload the contents of a folder to a collection, with optional pause/resume:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
openaleph crawldir -f <foreign-id> [--resume] [--parallel N] [--noindex] [--casefile] [-l LANG] <path>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `-f, --foreign-id` Foreign-ID of the target collection (required)
|
|
32
|
+
- `--resume` Resume from an existing state database; omit to start fresh (this will delete the state file!)
|
|
33
|
+
- `-p, --parallel N` Number of parallel upload threads (default: 1)
|
|
34
|
+
- `-i, --noindex` Skip indexing on ingest
|
|
35
|
+
- `--casefile` Treat files as case files
|
|
36
|
+
- `-l, --language LANG` Language hints (ISO 639; repeatable)
|
|
37
|
+
|
|
38
|
+
### `fetchdir`
|
|
39
|
+
|
|
40
|
+
Download all entities in a collection (or a single entity) into a folder tree:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
openaleph fetchdir -f <foreign-id> [-e <entity-id>] [-p <path>] [--overwrite]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Other commands
|
|
47
|
+
|
|
48
|
+
- `reingest` Re-ingest all documents in a collection
|
|
49
|
+
- `reindex` Re-index all entities in a collection
|
|
50
|
+
- `delete` Delete a collection and its contents
|
|
51
|
+
- `flush` Delete all contents of a collection
|
|
52
|
+
- `write-entity` Index a single entity from stdin
|
|
53
|
+
- `write-entities` Bulk-index entities from stdin
|
|
54
|
+
- `stream-entities` Stream entities to stdout
|
|
55
|
+
- `entitysets` List entity sets
|
|
56
|
+
- `entitysetitems` List items in an entity set
|
|
57
|
+
- `make-list` Create a new list entity set
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## State Persistence
|
|
62
|
+
|
|
63
|
+
When running **crawldir**, OpenAleph maintains a small SQLite database file in your crawl root:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
<crawl-root>/.openaleph_crawl_state.db
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **Purpose**: track which files have already been successfully uploaded.
|
|
70
|
+
- **Resume support**:
|
|
71
|
+
- Passing `--resume` skips any files recorded in this DB.
|
|
72
|
+
- Omitting `--resume` deletes any existing state DB and starts fresh.
|
|
73
|
+
- **Thread-safe**: uploads are recorded under a lock to support parallel threads.
|
|
74
|
+
- **Update datasets later**: The db file stays in the directory, allowing you to update your local repository at any time and only sync the new files to OpenAleph.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Ignore File
|
|
79
|
+
|
|
80
|
+
You can create a file named:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
<crawl-root>/.openalephignore
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
and list glob patterns for any files or directories you want to skip entirely:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
# Skip hidden files
|
|
90
|
+
.*
|
|
91
|
+
|
|
92
|
+
# Common junk
|
|
93
|
+
.DS_Store
|
|
94
|
+
Thumbs.db
|
|
95
|
+
|
|
96
|
+
# Temporary directories
|
|
97
|
+
tmp/
|
|
98
|
+
build/
|
|
99
|
+
|
|
100
|
+
# Log files
|
|
101
|
+
*.log
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- Patterns are matched against the **relative path** of each file or folder.
|
|
105
|
+
- A pattern ending in `/` only matches directories (and their contents).
|
|
106
|
+
- Blank lines and lines beginning with `#` are ignored.
|
|
107
|
+
- Anything matched here is never enqueued or uploaded.
|
|
108
|
+
- the `.openalephignore` file itself is ignored by default, and so is the state file
|
|
109
|
+
|
|
110
|
+
## Final Report
|
|
111
|
+
|
|
112
|
+
After a crawl completes, OpenAleph will print a summary to the console. If any failures occurred, by default a file is written to:
|
|
113
|
+
|
|
114
|
+
`<crawl-root>/.openaleph-failed.txt`
|
|
115
|
+
|
|
116
|
+
It contains one relative path per line for each file that could not be uploaded permanently. You can inspect this file to retry or investigate failures.
|
|
File without changes
|