1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
|
%global _empty_manifest_terminate_build 0
Name: python-impira
Version: 0.1.14
Release: 1
Summary: Official Impira Python SDK
License: MIT License
URL: https://github.com/impira/impira-python
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/52/f8/1ef5cd55e4ddab1e13e28b18232910c869afe100743584dd929f3123a9b5/impira-0.1.14.tar.gz
BuildArch: noarch
Requires: python3-dateutil
Requires: python3-pydantic
Requires: python3-requests
Requires: python3-boto3
Requires: python3-commonmark
Requires: python3-enum-tools[sphinx]
Requires: python3-myst-parser
Requires: python3-sphinx
Requires: python3-textract-trp
Requires: python3-boto3
Requires: python3-textract-trp
Requires: python3-myst-parser
Requires: python3-sphinx
Requires: python3-commonmark
Requires: python3-enum-tools[sphinx]
%description
# Impira Python SDK and CLI
Impira enables you to get everything you need from your PDFs, scanned documents, images, and more — with the help of machine learning. This API allows you to access Impira programatically through Python and the command line.
**NOTE: This SDK is currently under active development and is likely to break backwards compatibility between point releases. We will update this disclaimer when this changes.**
## Full documentation
Below is an abbreviated set of documentation to help you get started. You can visit the full documentation by visiting the [Impira SDK docs](https://impira.github.io/impira-python/index.html).
## Requirements
This SDK is tested with Python 3.7.4+ on Mac OS X and Linux systems. We have users using Windows as well; however, this scenario is not tested automatically. Please reach out if you run into any issues on Windows or another platform.
## Installation
You can install the Impira Python SDK, CLI, and its dependencies directly through pip:
```bash
$ pip install 'impira[cli]'
```
To install _just_ the SDK and its dependencies use:
``` bash
$ pip install impira
```
### Development mode
If you would like to install the SDK and CLI to develop locally, you can run the following:
```bash
$ git clone git@github.com:impira/impira-python.git
$ cd impira-python
$ make develop
```
This will create a virtualenv locally and install the library to it in a manner that automatically updates as you change the source code.
## CLI overview
See [CLI Commands](https://impira.github.io/impira-python/commands.html) in the docs.
## SDK overview
The Impira Python SDK includes utilities to upload and label files, insert and update data, and query data. The core abstraction is the `Impira` object which represents an authenticated connection to your organization. The SDK makes heavy use of the [pydantic](https://pydantic-docs.helpmanual.io/) library to automatically build up and validate function arugments.
### Authenticating
To connect to an org, you simply instantiate the `Impira` object with your organization's name and API token. You can find your organization's name in the URL you visit to access Impira. For example, when you login, if the URL is `https://app.impira.com/o/acme-corp-1a23/collections`, then your organization's name is `acme-corp-1a23`. For instructions on obtaining an API token, please visit the [Impira docs](https://www.impira.com/documentation/impira-read-api#toc-creating-an-api-token). For security reasons, we highly recommend storing both the organization name and API key in configuration or environment variables, not directly in the code itself. For the purpose of these examples, we will use the environment variables `IMPIRA_ORG_NAME` and `IMPIRA_API_KEY`.
```python
from impira import Impira
import os
impira_api = Impira(os.environ["IMPIRA_ORG_NAME"], os.environ["IMPIRA_API_KEY"])
```
When you instantiate the Impira API, it will automatically issue a `ping` request to validate your credentials and raise an `InvalidRequest` exception if it fails. You can disable this behavior by passing `ping=False` to the constructor.
### Referencing a collection
Many function calls in the API reference a `collection_id` parameter. This id can be found by navigating to a collection in the application, and copying the identifier after `fc`. For example, for a collection at a URL like `https://app.impira.com/o/acme-corp-1a23/fc/07b71143a26b7163`, the `collection_id` is `07b71143a26b7163`.
### Uploading
To upload one or more files, you must provide at a minimum a name and path (either local or a URL) for each file. The specification is defined in the `FilePath` type. You can also optionally specify a `collection_id` or `None` to upload the file globally (to "All files").
```python
# Upload a file on your local machine
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "/Users/me/Desktop/foo.pdf"}
])
# Upload multiple files by specifying their URLs
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "http://website.com/foo.pdf"},
{"name": "bar.pdf", "path": "http://website.com/bar.pdf"},
])
```
The `uids` variable is a list with a `uid` for each file. A file's `uid` is its unique identifier throughout the system. A file that belongs to more than one collection will have the same `uid` in each. You can also optionally specify your own `uid` while uploading a file. If two files have the same `uid`, the system will automatically replace the former with the latter, effectively versioning the file. For more information on uploading files, visit the [Upload API docs](https://www.impira.com/documentation/impira-write-api).
### Polling for results
Impira's API is asynchronous, meaning that uploading files and retrieving predictions from them occur in two separate API requests. While there are many [advanced ways to query for data using IQL](https://www.impira.com/documentation/iql-for-advanced-queries), the SDK offers a simple `poll_for_results()` method that allows you to wait for results to be available for your uploads. Using the `uids` returned from `upload_files()` (as demonstrated above), you can simply run something like
```python
for row in impira_api.poll_for_results(collection_id, uids):
print(row)
```
to retrieve each prediction. Note that `poll_for_results()` returns a generator, so you must iterate through its output to retrieve each result.
### Running IQL queries
You can run arbitrary IQL queries through the API by simply invoking the `query()` method. The response is exactly the same format as [the read API](https://www.impira.com/documentation/impira-read-api) and the SDK also supports poll mode (by passing the `mode="poll"` argument). For example,
```python
response = impira_api.query(
"@`file_collections::%s`[uid] highest:Uploaded limit:10" % (collection_id)
)
last_10_uids = [row["uid"] for row in response["data"]]
```
will retrieve the `uid` of each of the last 10 files uploaded to the collection. For more information on how to construct IQL queries, see the [IQL docs](https://www.impira.com/documentation/iql-for-advanced-queries).
## Examples
The examples directory contains end-to-end working examples for how to use the SDK.
* `upload_files.py` walks through uploading a file, either locally or through a URL, and then waiting for its results.
* `upload_and_split_files.py` walks through uploading a file, either locally or through a URL, remove all pages after page 5 and splitting the remaining pages, and then waiting for its results.
* `download_all_collections_query.py` creates an IQL query that queries all data across all collections
## License
[MIT License](LICENSE). Copyright 2021 Impira Inc.
%package -n python3-impira
Summary: Official Impira Python SDK
Provides: python-impira
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-impira
# Impira Python SDK and CLI
Impira enables you to get everything you need from your PDFs, scanned documents, images, and more — with the help of machine learning. This API allows you to access Impira programatically through Python and the command line.
**NOTE: This SDK is currently under active development and is likely to break backwards compatibility between point releases. We will update this disclaimer when this changes.**
## Full documentation
Below is an abbreviated set of documentation to help you get started. You can visit the full documentation by visiting the [Impira SDK docs](https://impira.github.io/impira-python/index.html).
## Requirements
This SDK is tested with Python 3.7.4+ on Mac OS X and Linux systems. We have users using Windows as well; however, this scenario is not tested automatically. Please reach out if you run into any issues on Windows or another platform.
## Installation
You can install the Impira Python SDK, CLI, and its dependencies directly through pip:
```bash
$ pip install 'impira[cli]'
```
To install _just_ the SDK and its dependencies use:
``` bash
$ pip install impira
```
### Development mode
If you would like to install the SDK and CLI to develop locally, you can run the following:
```bash
$ git clone git@github.com:impira/impira-python.git
$ cd impira-python
$ make develop
```
This will create a virtualenv locally and install the library to it in a manner that automatically updates as you change the source code.
## CLI overview
See [CLI Commands](https://impira.github.io/impira-python/commands.html) in the docs.
## SDK overview
The Impira Python SDK includes utilities to upload and label files, insert and update data, and query data. The core abstraction is the `Impira` object which represents an authenticated connection to your organization. The SDK makes heavy use of the [pydantic](https://pydantic-docs.helpmanual.io/) library to automatically build up and validate function arugments.
### Authenticating
To connect to an org, you simply instantiate the `Impira` object with your organization's name and API token. You can find your organization's name in the URL you visit to access Impira. For example, when you login, if the URL is `https://app.impira.com/o/acme-corp-1a23/collections`, then your organization's name is `acme-corp-1a23`. For instructions on obtaining an API token, please visit the [Impira docs](https://www.impira.com/documentation/impira-read-api#toc-creating-an-api-token). For security reasons, we highly recommend storing both the organization name and API key in configuration or environment variables, not directly in the code itself. For the purpose of these examples, we will use the environment variables `IMPIRA_ORG_NAME` and `IMPIRA_API_KEY`.
```python
from impira import Impira
import os
impira_api = Impira(os.environ["IMPIRA_ORG_NAME"], os.environ["IMPIRA_API_KEY"])
```
When you instantiate the Impira API, it will automatically issue a `ping` request to validate your credentials and raise an `InvalidRequest` exception if it fails. You can disable this behavior by passing `ping=False` to the constructor.
### Referencing a collection
Many function calls in the API reference a `collection_id` parameter. This id can be found by navigating to a collection in the application, and copying the identifier after `fc`. For example, for a collection at a URL like `https://app.impira.com/o/acme-corp-1a23/fc/07b71143a26b7163`, the `collection_id` is `07b71143a26b7163`.
### Uploading
To upload one or more files, you must provide at a minimum a name and path (either local or a URL) for each file. The specification is defined in the `FilePath` type. You can also optionally specify a `collection_id` or `None` to upload the file globally (to "All files").
```python
# Upload a file on your local machine
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "/Users/me/Desktop/foo.pdf"}
])
# Upload multiple files by specifying their URLs
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "http://website.com/foo.pdf"},
{"name": "bar.pdf", "path": "http://website.com/bar.pdf"},
])
```
The `uids` variable is a list with a `uid` for each file. A file's `uid` is its unique identifier throughout the system. A file that belongs to more than one collection will have the same `uid` in each. You can also optionally specify your own `uid` while uploading a file. If two files have the same `uid`, the system will automatically replace the former with the latter, effectively versioning the file. For more information on uploading files, visit the [Upload API docs](https://www.impira.com/documentation/impira-write-api).
### Polling for results
Impira's API is asynchronous, meaning that uploading files and retrieving predictions from them occur in two separate API requests. While there are many [advanced ways to query for data using IQL](https://www.impira.com/documentation/iql-for-advanced-queries), the SDK offers a simple `poll_for_results()` method that allows you to wait for results to be available for your uploads. Using the `uids` returned from `upload_files()` (as demonstrated above), you can simply run something like
```python
for row in impira_api.poll_for_results(collection_id, uids):
print(row)
```
to retrieve each prediction. Note that `poll_for_results()` returns a generator, so you must iterate through its output to retrieve each result.
### Running IQL queries
You can run arbitrary IQL queries through the API by simply invoking the `query()` method. The response is exactly the same format as [the read API](https://www.impira.com/documentation/impira-read-api) and the SDK also supports poll mode (by passing the `mode="poll"` argument). For example,
```python
response = impira_api.query(
"@`file_collections::%s`[uid] highest:Uploaded limit:10" % (collection_id)
)
last_10_uids = [row["uid"] for row in response["data"]]
```
will retrieve the `uid` of each of the last 10 files uploaded to the collection. For more information on how to construct IQL queries, see the [IQL docs](https://www.impira.com/documentation/iql-for-advanced-queries).
## Examples
The examples directory contains end-to-end working examples for how to use the SDK.
* `upload_files.py` walks through uploading a file, either locally or through a URL, and then waiting for its results.
* `upload_and_split_files.py` walks through uploading a file, either locally or through a URL, remove all pages after page 5 and splitting the remaining pages, and then waiting for its results.
* `download_all_collections_query.py` creates an IQL query that queries all data across all collections
## License
[MIT License](LICENSE). Copyright 2021 Impira Inc.
%package help
Summary: Development documents and examples for impira
Provides: python3-impira-doc
%description help
# Impira Python SDK and CLI
Impira enables you to get everything you need from your PDFs, scanned documents, images, and more — with the help of machine learning. This API allows you to access Impira programatically through Python and the command line.
**NOTE: This SDK is currently under active development and is likely to break backwards compatibility between point releases. We will update this disclaimer when this changes.**
## Full documentation
Below is an abbreviated set of documentation to help you get started. You can visit the full documentation by visiting the [Impira SDK docs](https://impira.github.io/impira-python/index.html).
## Requirements
This SDK is tested with Python 3.7.4+ on Mac OS X and Linux systems. We have users using Windows as well; however, this scenario is not tested automatically. Please reach out if you run into any issues on Windows or another platform.
## Installation
You can install the Impira Python SDK, CLI, and its dependencies directly through pip:
```bash
$ pip install 'impira[cli]'
```
To install _just_ the SDK and its dependencies use:
``` bash
$ pip install impira
```
### Development mode
If you would like to install the SDK and CLI to develop locally, you can run the following:
```bash
$ git clone git@github.com:impira/impira-python.git
$ cd impira-python
$ make develop
```
This will create a virtualenv locally and install the library to it in a manner that automatically updates as you change the source code.
## CLI overview
See [CLI Commands](https://impira.github.io/impira-python/commands.html) in the docs.
## SDK overview
The Impira Python SDK includes utilities to upload and label files, insert and update data, and query data. The core abstraction is the `Impira` object which represents an authenticated connection to your organization. The SDK makes heavy use of the [pydantic](https://pydantic-docs.helpmanual.io/) library to automatically build up and validate function arugments.
### Authenticating
To connect to an org, you simply instantiate the `Impira` object with your organization's name and API token. You can find your organization's name in the URL you visit to access Impira. For example, when you login, if the URL is `https://app.impira.com/o/acme-corp-1a23/collections`, then your organization's name is `acme-corp-1a23`. For instructions on obtaining an API token, please visit the [Impira docs](https://www.impira.com/documentation/impira-read-api#toc-creating-an-api-token). For security reasons, we highly recommend storing both the organization name and API key in configuration or environment variables, not directly in the code itself. For the purpose of these examples, we will use the environment variables `IMPIRA_ORG_NAME` and `IMPIRA_API_KEY`.
```python
from impira import Impira
import os
impira_api = Impira(os.environ["IMPIRA_ORG_NAME"], os.environ["IMPIRA_API_KEY"])
```
When you instantiate the Impira API, it will automatically issue a `ping` request to validate your credentials and raise an `InvalidRequest` exception if it fails. You can disable this behavior by passing `ping=False` to the constructor.
### Referencing a collection
Many function calls in the API reference a `collection_id` parameter. This id can be found by navigating to a collection in the application, and copying the identifier after `fc`. For example, for a collection at a URL like `https://app.impira.com/o/acme-corp-1a23/fc/07b71143a26b7163`, the `collection_id` is `07b71143a26b7163`.
### Uploading
To upload one or more files, you must provide at a minimum a name and path (either local or a URL) for each file. The specification is defined in the `FilePath` type. You can also optionally specify a `collection_id` or `None` to upload the file globally (to "All files").
```python
# Upload a file on your local machine
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "/Users/me/Desktop/foo.pdf"}
])
# Upload multiple files by specifying their URLs
uids = impira_api.upload_files(collection_id, [
{"name": "foo.pdf", "path": "http://website.com/foo.pdf"},
{"name": "bar.pdf", "path": "http://website.com/bar.pdf"},
])
```
The `uids` variable is a list with a `uid` for each file. A file's `uid` is its unique identifier throughout the system. A file that belongs to more than one collection will have the same `uid` in each. You can also optionally specify your own `uid` while uploading a file. If two files have the same `uid`, the system will automatically replace the former with the latter, effectively versioning the file. For more information on uploading files, visit the [Upload API docs](https://www.impira.com/documentation/impira-write-api).
### Polling for results
Impira's API is asynchronous, meaning that uploading files and retrieving predictions from them occur in two separate API requests. While there are many [advanced ways to query for data using IQL](https://www.impira.com/documentation/iql-for-advanced-queries), the SDK offers a simple `poll_for_results()` method that allows you to wait for results to be available for your uploads. Using the `uids` returned from `upload_files()` (as demonstrated above), you can simply run something like
```python
for row in impira_api.poll_for_results(collection_id, uids):
print(row)
```
to retrieve each prediction. Note that `poll_for_results()` returns a generator, so you must iterate through its output to retrieve each result.
### Running IQL queries
You can run arbitrary IQL queries through the API by simply invoking the `query()` method. The response is exactly the same format as [the read API](https://www.impira.com/documentation/impira-read-api) and the SDK also supports poll mode (by passing the `mode="poll"` argument). For example,
```python
response = impira_api.query(
"@`file_collections::%s`[uid] highest:Uploaded limit:10" % (collection_id)
)
last_10_uids = [row["uid"] for row in response["data"]]
```
will retrieve the `uid` of each of the last 10 files uploaded to the collection. For more information on how to construct IQL queries, see the [IQL docs](https://www.impira.com/documentation/iql-for-advanced-queries).
## Examples
The examples directory contains end-to-end working examples for how to use the SDK.
* `upload_files.py` walks through uploading a file, either locally or through a URL, and then waiting for its results.
* `upload_and_split_files.py` walks through uploading a file, either locally or through a URL, remove all pages after page 5 and splitting the remaining pages, and then waiting for its results.
* `download_all_collections_query.py` creates an IQL query that queries all data across all collections
## License
[MIT License](LICENSE). Copyright 2021 Impira Inc.
%prep
%autosetup -n impira-0.1.14
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-impira -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.14-1
- Package Spec generated
|