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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
|
%global _empty_manifest_terminate_build 0
Name: python-boss-ingest
Version: 0.12.0
Release: 1
Summary: Ingest client for the Boss
License: Apache 2.0
URL: https://github.com/jhuapl-boss/ingest-client
Source0: https://mirrors.aliyun.com/pypi/web/packages/28/1e/e4057f92142b44976b70b5b08904e78498eb5aa7a0c1b97354aea50eb3dd/boss-ingest-0.12.0.tar.gz
BuildArch: noarch
Requires: python3-mock
Requires: python3-jsonschema
Requires: python3-requests
Requires: python3-responses
Requires: python3-urllib3
Requires: python3-boto3
Requires: python3-moto
Requires: python3-Pillow
Requires: python3-numpy
Requires: python3-intern
Requires: python3-six
%description
# Boss Ingest Client
A Python command line application for performing distributed ingest of data into the Boss
[](https://docs.theboss.io/)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
[](https://codeclimate.com/github/jhuapl-boss/ingest-client)
[](https://coveralls.io/github/jhuapl-boss/ingest-client?branch=master)
[](https://circleci.com/gh/jhuapl-boss/ingest-client/tree/master)
## Overview
The ingest client application lets users move data from local storage into the Boss, quickly and reliably. It supports Python 3.6 and later. It uses a JSON configuration file to define ingest jobs, and a plugin system to support any local file organization.
Two types of ingest are supported:
- Tile based
- Volumetric
### Tile Based Ingests
This ingest type uploads data in 2D image tiles. It supports many different formats, but it is not as efficient as volumetric ingests.
### Volumetric Ingests
This type of ingest uploads data in the Boss' native storage format. 3D cuboids, that are 512, 512, 16, in x, y, z, respectively, are uploaded by the ingest client.
## Installation
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install the ingest client
```
pip install boss-ingest
```
If you get errors installing Pillow, it is most likely because you do not have all of Pillow's dependencies installed. Check out the "Installing Pillow Dependencies" section below for help.
## Configuring Credentials
You must provide the ingest client with your Boss API token so it can make authenticated requests on your behalf.
Also remember that you must have write permissions to the resource (`collection`, `experiment`, and `channel`) where data is to be written, as specified in the ingest job configuration file. If you created the resources you will automatically have access.
There are three ways to provide your API token to the ingest client. The ingest client will try to use the first token it finds in the following order:
1. **Via command line arguments**
- You can directly pass your token to the ingest client when starting it from the command line. See the *Usage* section below.
2. **Via the intern environment variables**
- The ingest client can also reuse environment variables used to configure _intern_ to set your API token
```
export INTERN_TOKEN=<you_token_here>
```
3. **Via the intern configuration file**
- If you have already installed [intern](https://github.com/jhuapl-boss/intern) and added your API token to its configuration file, the ingest client will automatically load the token
## Usage
The ingest client is installed as a system script and can be called from the command line directly as `boss-ingest`.
An ingest job is the act of uploading a dataset or sub-region of a dataset to the Boss. You do not need to upload an entire dataset at once if desired, and can specify in both space and time what data is to be written.
There are three primary operations you can perform with the ingest client: Create, Join, and Cancel an ingest job
- **Creating a NEW Ingest Job**
- Populate an ingest job configuration file to specify the correct plugins for your data, the Boss resource to use, the extent of the dataset to be ingested, and the tile size.
- Refer to the [Creating Configuration Files](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Ingest-Job-Configuration-Files) wiki page for more detail on how to do this. Also, a helper script to create the Boss resources necessary for an ingest is found [here](https://github.com/jhuapl-boss/ingest-client/tree/master/ingestclient/bin/prep_ingest.py).
- Assuming you have created a configuration file, simply call the ingest client
```
boss-ingest <absolute_path_to_config_file>
```
- After creating the new Ingest Job, the client will print the ingest job ID and it will be also logged.
_Remember this ID if you wish to restart the client or run the client on additional nodes for increased throughput_
- You have **14 days** to complete uploading the data for this ingest job before the upload work queue automatically gets purged
- **Joining an EXISTING Ingest Job**
- You can join an existing ingest job and start uploading data any time after it has been created. This can be useful if the client has crashed, or if you want to run the client on additional nodes in parallel.
```
boss-ingest <absolute_path_to_config_file> --job-id <ingest_job_id>
```
or
```
boss-ingest <absolute_path_to_config_file> -j <ingest_job_id>
```
- **Cancelling an Ingest Job**
- Sometimes you may want to stop an ingest job. You can do this by "cancelling" it. Currently this will delete all tiles that have been uploaded but not ingested into the Boss yet. Any data that made its way through the ingest pipeline will remain. Also temporary queues will be purged and deleted.
```
boss-ingest --cancel --job-id <ingest_job_id>
```
or
```
boss-ingest -c -j <ingest_job_id>
```
If you are working with the non-production Boss instance (api.theboss.io), then you can provide a configuration file specifying the desired host as the commands shown above will default to the production Boss environment.
```
boss-ingest <absolute_path_to_config_file> -c -j <ingest_job_id>
```
- **Completing an Ingest Job**
- The ingest client now automatically "completes" an ingest job when the upload queue has been completely processed. This operation will ensure that all data has made it into the Boss, clean up temporary resources that have been provisioned by the Boss, and update the status of the ingest job. Note, it can take 5-60 seconds to finish completing a job.
If you do **not** want the client to automatically compete the job for you, you can add a flag to disable this functionality, as shown below
```
boss-ingest <absolute_path_to_config_file> --manual-complete
```
or
```
boss-ingest <absolute_path_to_config_file> -m
```
- **Multiprocessing**
- You can choose to have multiple upload engines start in parallel processes by setting the `-p` argument as outlined in the example below. (Default number of upload processes = 1)
```
boss-ingest <absolute_path_to_config_file> --processes_nb <number_of_processes>
```
or
```
boss-ingest <absolute_path_to_config_file> -p <number_of_processes>
```
- If you are using multiple parallel client processes, you may choose to optionally pass a `--ramp_seconds`/`-r` flag with a number of seconds to delay in between creating processes. This is helpful when the source of ingest data needs time to scale (e.g. google cloud storage buckets, or a load-balanced web server).
- **Logging**
- You can choose where to write the log file by specifying and absolute file path suing the -l parameter. If omitted, data is logged in `~/.boss-ingest`
```
boss-ingest <absolute_path_to_config_file> --log-file <absolute_filename>
```
or
```
boss-ingest <absolute_path_to_config_file> -l <absolute_filename>
```
- You can also control the logging level. By default it is set to `WARNING`, although some important information is forced to always log. The `INFO` level and lower result in very large log files and is not recommended for anything besides development and debug.
```
boss-ingest <absolute_path_to_config_file> --log-level <critical|error|warning|info|debug>
```
or
```
boss-ingest <absolute_path_to_config_file> -v <critical|error|warning|info|debug>
```
## Plugins
To handle the many different ways users can organize and store data, "plugins" are used to perform two operations. The first (Path Processor) is responsible for taking user specified parameters and tile indices provided from the upload task queue to generate an absolute file path to the correct data file associated with the image tile. The second (Tile Processor) is responsible for taking user specified parameters, tile indices, and generated file path to generate a file handle containing the image data. This handle is then used to upload the image tile.
The [ingest client wiki](https://github.com/jhuapl-boss/ingest-client/wiki) on GitHub provides more detailed information on on how to [create plugins](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Custom-Plugins) and which plugins come [pre-installed](https://github.com/jhuapl-boss/ingest-client/wiki/Plugins).
If you develop your own plugins, you simply need to make sure they are on your `PYTHONPATH` before calling `boss-ingest`
```
export PYTHONPATH=$PYTHONPATH:/<path_to_modules>
```
## Installing Pillow Dependencies
The ingest client uses [Pillow](http://pillow.readthedocs.io/en/latest/installation.html) to handle image files. There are several dependencies you may need to install before you can run `pip install Pillow`. Pillow is installed automatically when you run `pip install boss-ingest`, so these external dependencies must already be installed for that command to successfully complete.
- OSX
Install jpeg and tiff libraries using [Homebrew](http://brew.sh/index.html)
```
brew install libjpeg
brew install libtiff
```
Sometimes you may also need to install zlib development packages from XCode
```
xcode-select --install
```
- Linux (Ubuntu)
```
sudo apt-get install libjpeg-dev libtiff5-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjpeg-dev
```
- Windows - Untested
## Installation for Development
- `mkdir` and `cd` to a directory of your choice
- Clone the ingest client
```
git clone https://github.com/jhuapl-boss/ingest-client.git
```
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install Python dependencies
```
cd ./ingest-client
pip install -r requirements.txt
```
- An additional token configuration method via the token.json file is available if you've cloned the ingest-client repository locally
- Create a token.json file in the root directory of the repo
```
vi ./token.json
```
- Get your API token. This can be done by visiting the [Boss Management Console](https://api.theboss.io). After logging in, click on your username in the top right corner, then "API Token".
- Copy your API token to the token.json file that looks like this:
```
{
"token": "<insert_token_here>",
"host": "api.theboss.io"
}
```
## Testing
The nose2 library is used to run unit tests. From the `ingest-client` directory simply invoke nose2.
```
nose2
```
We use continuous integration to automatically run tests as well. Future work will expand on testing and add more complex integration testing.
## Legal
Use or redistribution of the Boss system in source and/or binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code or binary forms must adhere to the terms and conditions of any applicable software licenses.
2. End-user documentation or notices, whether included as part of a redistribution or disseminated as part of a legal or scientific disclosure (e.g. publication) or advertisement, must include the following acknowledgement: The Boss software system was designed and developed by the Johns Hopkins University Applied Physics Laboratory (JHU/APL).
3. The names "The Boss", "JHU/APL", "Johns Hopkins University", "Applied Physics Laboratory", "MICrONS", or "IARPA" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact BossAdmin@jhuapl.edu.
4. This source code and library is distributed in the hope that it will be useful, but is provided without any warranty of any kind.
## License
If not otherwise marked, all code in this repository falls under the license granted in LICENSE.md.
%package -n python3-boss-ingest
Summary: Ingest client for the Boss
Provides: python-boss-ingest
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-boss-ingest
# Boss Ingest Client
A Python command line application for performing distributed ingest of data into the Boss
[](https://docs.theboss.io/)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
[](https://codeclimate.com/github/jhuapl-boss/ingest-client)
[](https://coveralls.io/github/jhuapl-boss/ingest-client?branch=master)
[](https://circleci.com/gh/jhuapl-boss/ingest-client/tree/master)
## Overview
The ingest client application lets users move data from local storage into the Boss, quickly and reliably. It supports Python 3.6 and later. It uses a JSON configuration file to define ingest jobs, and a plugin system to support any local file organization.
Two types of ingest are supported:
- Tile based
- Volumetric
### Tile Based Ingests
This ingest type uploads data in 2D image tiles. It supports many different formats, but it is not as efficient as volumetric ingests.
### Volumetric Ingests
This type of ingest uploads data in the Boss' native storage format. 3D cuboids, that are 512, 512, 16, in x, y, z, respectively, are uploaded by the ingest client.
## Installation
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install the ingest client
```
pip install boss-ingest
```
If you get errors installing Pillow, it is most likely because you do not have all of Pillow's dependencies installed. Check out the "Installing Pillow Dependencies" section below for help.
## Configuring Credentials
You must provide the ingest client with your Boss API token so it can make authenticated requests on your behalf.
Also remember that you must have write permissions to the resource (`collection`, `experiment`, and `channel`) where data is to be written, as specified in the ingest job configuration file. If you created the resources you will automatically have access.
There are three ways to provide your API token to the ingest client. The ingest client will try to use the first token it finds in the following order:
1. **Via command line arguments**
- You can directly pass your token to the ingest client when starting it from the command line. See the *Usage* section below.
2. **Via the intern environment variables**
- The ingest client can also reuse environment variables used to configure _intern_ to set your API token
```
export INTERN_TOKEN=<you_token_here>
```
3. **Via the intern configuration file**
- If you have already installed [intern](https://github.com/jhuapl-boss/intern) and added your API token to its configuration file, the ingest client will automatically load the token
## Usage
The ingest client is installed as a system script and can be called from the command line directly as `boss-ingest`.
An ingest job is the act of uploading a dataset or sub-region of a dataset to the Boss. You do not need to upload an entire dataset at once if desired, and can specify in both space and time what data is to be written.
There are three primary operations you can perform with the ingest client: Create, Join, and Cancel an ingest job
- **Creating a NEW Ingest Job**
- Populate an ingest job configuration file to specify the correct plugins for your data, the Boss resource to use, the extent of the dataset to be ingested, and the tile size.
- Refer to the [Creating Configuration Files](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Ingest-Job-Configuration-Files) wiki page for more detail on how to do this. Also, a helper script to create the Boss resources necessary for an ingest is found [here](https://github.com/jhuapl-boss/ingest-client/tree/master/ingestclient/bin/prep_ingest.py).
- Assuming you have created a configuration file, simply call the ingest client
```
boss-ingest <absolute_path_to_config_file>
```
- After creating the new Ingest Job, the client will print the ingest job ID and it will be also logged.
_Remember this ID if you wish to restart the client or run the client on additional nodes for increased throughput_
- You have **14 days** to complete uploading the data for this ingest job before the upload work queue automatically gets purged
- **Joining an EXISTING Ingest Job**
- You can join an existing ingest job and start uploading data any time after it has been created. This can be useful if the client has crashed, or if you want to run the client on additional nodes in parallel.
```
boss-ingest <absolute_path_to_config_file> --job-id <ingest_job_id>
```
or
```
boss-ingest <absolute_path_to_config_file> -j <ingest_job_id>
```
- **Cancelling an Ingest Job**
- Sometimes you may want to stop an ingest job. You can do this by "cancelling" it. Currently this will delete all tiles that have been uploaded but not ingested into the Boss yet. Any data that made its way through the ingest pipeline will remain. Also temporary queues will be purged and deleted.
```
boss-ingest --cancel --job-id <ingest_job_id>
```
or
```
boss-ingest -c -j <ingest_job_id>
```
If you are working with the non-production Boss instance (api.theboss.io), then you can provide a configuration file specifying the desired host as the commands shown above will default to the production Boss environment.
```
boss-ingest <absolute_path_to_config_file> -c -j <ingest_job_id>
```
- **Completing an Ingest Job**
- The ingest client now automatically "completes" an ingest job when the upload queue has been completely processed. This operation will ensure that all data has made it into the Boss, clean up temporary resources that have been provisioned by the Boss, and update the status of the ingest job. Note, it can take 5-60 seconds to finish completing a job.
If you do **not** want the client to automatically compete the job for you, you can add a flag to disable this functionality, as shown below
```
boss-ingest <absolute_path_to_config_file> --manual-complete
```
or
```
boss-ingest <absolute_path_to_config_file> -m
```
- **Multiprocessing**
- You can choose to have multiple upload engines start in parallel processes by setting the `-p` argument as outlined in the example below. (Default number of upload processes = 1)
```
boss-ingest <absolute_path_to_config_file> --processes_nb <number_of_processes>
```
or
```
boss-ingest <absolute_path_to_config_file> -p <number_of_processes>
```
- If you are using multiple parallel client processes, you may choose to optionally pass a `--ramp_seconds`/`-r` flag with a number of seconds to delay in between creating processes. This is helpful when the source of ingest data needs time to scale (e.g. google cloud storage buckets, or a load-balanced web server).
- **Logging**
- You can choose where to write the log file by specifying and absolute file path suing the -l parameter. If omitted, data is logged in `~/.boss-ingest`
```
boss-ingest <absolute_path_to_config_file> --log-file <absolute_filename>
```
or
```
boss-ingest <absolute_path_to_config_file> -l <absolute_filename>
```
- You can also control the logging level. By default it is set to `WARNING`, although some important information is forced to always log. The `INFO` level and lower result in very large log files and is not recommended for anything besides development and debug.
```
boss-ingest <absolute_path_to_config_file> --log-level <critical|error|warning|info|debug>
```
or
```
boss-ingest <absolute_path_to_config_file> -v <critical|error|warning|info|debug>
```
## Plugins
To handle the many different ways users can organize and store data, "plugins" are used to perform two operations. The first (Path Processor) is responsible for taking user specified parameters and tile indices provided from the upload task queue to generate an absolute file path to the correct data file associated with the image tile. The second (Tile Processor) is responsible for taking user specified parameters, tile indices, and generated file path to generate a file handle containing the image data. This handle is then used to upload the image tile.
The [ingest client wiki](https://github.com/jhuapl-boss/ingest-client/wiki) on GitHub provides more detailed information on on how to [create plugins](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Custom-Plugins) and which plugins come [pre-installed](https://github.com/jhuapl-boss/ingest-client/wiki/Plugins).
If you develop your own plugins, you simply need to make sure they are on your `PYTHONPATH` before calling `boss-ingest`
```
export PYTHONPATH=$PYTHONPATH:/<path_to_modules>
```
## Installing Pillow Dependencies
The ingest client uses [Pillow](http://pillow.readthedocs.io/en/latest/installation.html) to handle image files. There are several dependencies you may need to install before you can run `pip install Pillow`. Pillow is installed automatically when you run `pip install boss-ingest`, so these external dependencies must already be installed for that command to successfully complete.
- OSX
Install jpeg and tiff libraries using [Homebrew](http://brew.sh/index.html)
```
brew install libjpeg
brew install libtiff
```
Sometimes you may also need to install zlib development packages from XCode
```
xcode-select --install
```
- Linux (Ubuntu)
```
sudo apt-get install libjpeg-dev libtiff5-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjpeg-dev
```
- Windows - Untested
## Installation for Development
- `mkdir` and `cd` to a directory of your choice
- Clone the ingest client
```
git clone https://github.com/jhuapl-boss/ingest-client.git
```
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install Python dependencies
```
cd ./ingest-client
pip install -r requirements.txt
```
- An additional token configuration method via the token.json file is available if you've cloned the ingest-client repository locally
- Create a token.json file in the root directory of the repo
```
vi ./token.json
```
- Get your API token. This can be done by visiting the [Boss Management Console](https://api.theboss.io). After logging in, click on your username in the top right corner, then "API Token".
- Copy your API token to the token.json file that looks like this:
```
{
"token": "<insert_token_here>",
"host": "api.theboss.io"
}
```
## Testing
The nose2 library is used to run unit tests. From the `ingest-client` directory simply invoke nose2.
```
nose2
```
We use continuous integration to automatically run tests as well. Future work will expand on testing and add more complex integration testing.
## Legal
Use or redistribution of the Boss system in source and/or binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code or binary forms must adhere to the terms and conditions of any applicable software licenses.
2. End-user documentation or notices, whether included as part of a redistribution or disseminated as part of a legal or scientific disclosure (e.g. publication) or advertisement, must include the following acknowledgement: The Boss software system was designed and developed by the Johns Hopkins University Applied Physics Laboratory (JHU/APL).
3. The names "The Boss", "JHU/APL", "Johns Hopkins University", "Applied Physics Laboratory", "MICrONS", or "IARPA" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact BossAdmin@jhuapl.edu.
4. This source code and library is distributed in the hope that it will be useful, but is provided without any warranty of any kind.
## License
If not otherwise marked, all code in this repository falls under the license granted in LICENSE.md.
%package help
Summary: Development documents and examples for boss-ingest
Provides: python3-boss-ingest-doc
%description help
# Boss Ingest Client
A Python command line application for performing distributed ingest of data into the Boss
[](https://docs.theboss.io/)
[](http://www.apache.org/licenses/LICENSE-2.0.html)
[](https://codeclimate.com/github/jhuapl-boss/ingest-client)
[](https://coveralls.io/github/jhuapl-boss/ingest-client?branch=master)
[](https://circleci.com/gh/jhuapl-boss/ingest-client/tree/master)
## Overview
The ingest client application lets users move data from local storage into the Boss, quickly and reliably. It supports Python 3.6 and later. It uses a JSON configuration file to define ingest jobs, and a plugin system to support any local file organization.
Two types of ingest are supported:
- Tile based
- Volumetric
### Tile Based Ingests
This ingest type uploads data in 2D image tiles. It supports many different formats, but it is not as efficient as volumetric ingests.
### Volumetric Ingests
This type of ingest uploads data in the Boss' native storage format. 3D cuboids, that are 512, 512, 16, in x, y, z, respectively, are uploaded by the ingest client.
## Installation
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install the ingest client
```
pip install boss-ingest
```
If you get errors installing Pillow, it is most likely because you do not have all of Pillow's dependencies installed. Check out the "Installing Pillow Dependencies" section below for help.
## Configuring Credentials
You must provide the ingest client with your Boss API token so it can make authenticated requests on your behalf.
Also remember that you must have write permissions to the resource (`collection`, `experiment`, and `channel`) where data is to be written, as specified in the ingest job configuration file. If you created the resources you will automatically have access.
There are three ways to provide your API token to the ingest client. The ingest client will try to use the first token it finds in the following order:
1. **Via command line arguments**
- You can directly pass your token to the ingest client when starting it from the command line. See the *Usage* section below.
2. **Via the intern environment variables**
- The ingest client can also reuse environment variables used to configure _intern_ to set your API token
```
export INTERN_TOKEN=<you_token_here>
```
3. **Via the intern configuration file**
- If you have already installed [intern](https://github.com/jhuapl-boss/intern) and added your API token to its configuration file, the ingest client will automatically load the token
## Usage
The ingest client is installed as a system script and can be called from the command line directly as `boss-ingest`.
An ingest job is the act of uploading a dataset or sub-region of a dataset to the Boss. You do not need to upload an entire dataset at once if desired, and can specify in both space and time what data is to be written.
There are three primary operations you can perform with the ingest client: Create, Join, and Cancel an ingest job
- **Creating a NEW Ingest Job**
- Populate an ingest job configuration file to specify the correct plugins for your data, the Boss resource to use, the extent of the dataset to be ingested, and the tile size.
- Refer to the [Creating Configuration Files](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Ingest-Job-Configuration-Files) wiki page for more detail on how to do this. Also, a helper script to create the Boss resources necessary for an ingest is found [here](https://github.com/jhuapl-boss/ingest-client/tree/master/ingestclient/bin/prep_ingest.py).
- Assuming you have created a configuration file, simply call the ingest client
```
boss-ingest <absolute_path_to_config_file>
```
- After creating the new Ingest Job, the client will print the ingest job ID and it will be also logged.
_Remember this ID if you wish to restart the client or run the client on additional nodes for increased throughput_
- You have **14 days** to complete uploading the data for this ingest job before the upload work queue automatically gets purged
- **Joining an EXISTING Ingest Job**
- You can join an existing ingest job and start uploading data any time after it has been created. This can be useful if the client has crashed, or if you want to run the client on additional nodes in parallel.
```
boss-ingest <absolute_path_to_config_file> --job-id <ingest_job_id>
```
or
```
boss-ingest <absolute_path_to_config_file> -j <ingest_job_id>
```
- **Cancelling an Ingest Job**
- Sometimes you may want to stop an ingest job. You can do this by "cancelling" it. Currently this will delete all tiles that have been uploaded but not ingested into the Boss yet. Any data that made its way through the ingest pipeline will remain. Also temporary queues will be purged and deleted.
```
boss-ingest --cancel --job-id <ingest_job_id>
```
or
```
boss-ingest -c -j <ingest_job_id>
```
If you are working with the non-production Boss instance (api.theboss.io), then you can provide a configuration file specifying the desired host as the commands shown above will default to the production Boss environment.
```
boss-ingest <absolute_path_to_config_file> -c -j <ingest_job_id>
```
- **Completing an Ingest Job**
- The ingest client now automatically "completes" an ingest job when the upload queue has been completely processed. This operation will ensure that all data has made it into the Boss, clean up temporary resources that have been provisioned by the Boss, and update the status of the ingest job. Note, it can take 5-60 seconds to finish completing a job.
If you do **not** want the client to automatically compete the job for you, you can add a flag to disable this functionality, as shown below
```
boss-ingest <absolute_path_to_config_file> --manual-complete
```
or
```
boss-ingest <absolute_path_to_config_file> -m
```
- **Multiprocessing**
- You can choose to have multiple upload engines start in parallel processes by setting the `-p` argument as outlined in the example below. (Default number of upload processes = 1)
```
boss-ingest <absolute_path_to_config_file> --processes_nb <number_of_processes>
```
or
```
boss-ingest <absolute_path_to_config_file> -p <number_of_processes>
```
- If you are using multiple parallel client processes, you may choose to optionally pass a `--ramp_seconds`/`-r` flag with a number of seconds to delay in between creating processes. This is helpful when the source of ingest data needs time to scale (e.g. google cloud storage buckets, or a load-balanced web server).
- **Logging**
- You can choose where to write the log file by specifying and absolute file path suing the -l parameter. If omitted, data is logged in `~/.boss-ingest`
```
boss-ingest <absolute_path_to_config_file> --log-file <absolute_filename>
```
or
```
boss-ingest <absolute_path_to_config_file> -l <absolute_filename>
```
- You can also control the logging level. By default it is set to `WARNING`, although some important information is forced to always log. The `INFO` level and lower result in very large log files and is not recommended for anything besides development and debug.
```
boss-ingest <absolute_path_to_config_file> --log-level <critical|error|warning|info|debug>
```
or
```
boss-ingest <absolute_path_to_config_file> -v <critical|error|warning|info|debug>
```
## Plugins
To handle the many different ways users can organize and store data, "plugins" are used to perform two operations. The first (Path Processor) is responsible for taking user specified parameters and tile indices provided from the upload task queue to generate an absolute file path to the correct data file associated with the image tile. The second (Tile Processor) is responsible for taking user specified parameters, tile indices, and generated file path to generate a file handle containing the image data. This handle is then used to upload the image tile.
The [ingest client wiki](https://github.com/jhuapl-boss/ingest-client/wiki) on GitHub provides more detailed information on on how to [create plugins](https://github.com/jhuapl-boss/ingest-client/wiki/Creating-Custom-Plugins) and which plugins come [pre-installed](https://github.com/jhuapl-boss/ingest-client/wiki/Plugins).
If you develop your own plugins, you simply need to make sure they are on your `PYTHONPATH` before calling `boss-ingest`
```
export PYTHONPATH=$PYTHONPATH:/<path_to_modules>
```
## Installing Pillow Dependencies
The ingest client uses [Pillow](http://pillow.readthedocs.io/en/latest/installation.html) to handle image files. There are several dependencies you may need to install before you can run `pip install Pillow`. Pillow is installed automatically when you run `pip install boss-ingest`, so these external dependencies must already be installed for that command to successfully complete.
- OSX
Install jpeg and tiff libraries using [Homebrew](http://brew.sh/index.html)
```
brew install libjpeg
brew install libtiff
```
Sometimes you may also need to install zlib development packages from XCode
```
xcode-select --install
```
- Linux (Ubuntu)
```
sudo apt-get install libjpeg-dev libtiff5-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjpeg-dev
```
- Windows - Untested
## Installation for Development
- `mkdir` and `cd` to a directory of your choice
- Clone the ingest client
```
git clone https://github.com/jhuapl-boss/ingest-client.git
```
- Use virtualenv to isolate the ingest client from your system Python installation
- Using [virtualenv](https://virtualenv.pypa.io/en/stable/):
```
virtualenv ingest-env
. ingest-env/bin/activate
```
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
```
mkvirtualenv ingest-env
```
- Install Python dependencies
```
cd ./ingest-client
pip install -r requirements.txt
```
- An additional token configuration method via the token.json file is available if you've cloned the ingest-client repository locally
- Create a token.json file in the root directory of the repo
```
vi ./token.json
```
- Get your API token. This can be done by visiting the [Boss Management Console](https://api.theboss.io). After logging in, click on your username in the top right corner, then "API Token".
- Copy your API token to the token.json file that looks like this:
```
{
"token": "<insert_token_here>",
"host": "api.theboss.io"
}
```
## Testing
The nose2 library is used to run unit tests. From the `ingest-client` directory simply invoke nose2.
```
nose2
```
We use continuous integration to automatically run tests as well. Future work will expand on testing and add more complex integration testing.
## Legal
Use or redistribution of the Boss system in source and/or binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code or binary forms must adhere to the terms and conditions of any applicable software licenses.
2. End-user documentation or notices, whether included as part of a redistribution or disseminated as part of a legal or scientific disclosure (e.g. publication) or advertisement, must include the following acknowledgement: The Boss software system was designed and developed by the Johns Hopkins University Applied Physics Laboratory (JHU/APL).
3. The names "The Boss", "JHU/APL", "Johns Hopkins University", "Applied Physics Laboratory", "MICrONS", or "IARPA" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact BossAdmin@jhuapl.edu.
4. This source code and library is distributed in the hope that it will be useful, but is provided without any warranty of any kind.
## License
If not otherwise marked, all code in this repository falls under the license granted in LICENSE.md.
%prep
%autosetup -n boss-ingest-0.12.0
%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-boss-ingest -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 0.12.0-1
- Package Spec generated
|