Debian Codegraph @

Readme.md

raw
1 # azure-datalake-store
2
3 A pure-python interface to the Azure Data-lake Storage Gen 1 system, providing
4 pythonic file-system and file objects, seamless transition between Windows and
5 POSIX remote paths, high-performance up- and down-loader.
6
7 This software is under active development and not yet recommended for general
8 use.
9
10 *Note:* This library supports ADLS Gen 1. For Gen 2, please see
11 `azure-storage-file-datalake`, documented
12 [here](https://docs.microsoft.com/en-us/samples/azure/azure-sdk-for-python/storage-datalake-samples/)
13
14 ## Installation
15
16 Using `pip`:
17
18 ```
19 pip install azure-datalake-store
20 ```
21
22 Manually (bleeding edge):
23
24 * Download the repo from [https://github.com/Azure/azure-data-lake-store-python](https://github.com/Azure/azure-data-lake-store-python)
25
26 * install the requirements (`pip install -r dev_requirements.txt`)
27
28 * install in develop mode (`python setup.py develop`)
29
30 ## Auth
31
32 Although users can generate and supply their own tokens to the base file-system
33 class, and there is a password-based function in the `lib` module for
34 generating tokens, the most convenient way to supply credentials is via
35 environment parameters. This latter method is the one used by default in
36 library. The following variables are required:
37
38 * azure_tenant_id
39
40 * azure_username
41
42 * azure_password
43
44 * azure_store_name
45
46 * azure_url_suffix (optional)
47
48 ## Pythonic Filesystem
49
50 The `AzureDLFileSystem` object is the main API for library usage of this
51 package. It provides typical file-system operations on the remote azure
52 store
53
54 ```
55 token = lib.auth(tenant_id, username, password)
56 adl = core.AzureDLFileSystem(store_name, token)
57 # alternatively, adl = core.AzureDLFileSystem()
58 # uses environment variables
59
60 print(adl.ls()) # list files in the root directory
61 for item in adl.ls(detail=True):
62 print(item) # same, but with file details as dictionaries
63 print(adl.walk('')) # list all files at any directory depth
64 print('Usage:', adl.du('', deep=True, total=True)) # total bytes usage
65 adl.mkdir('newdir') # create directory
66 adl.touch('newdir/newfile') # create empty file
67 adl.put('remotefile', '/home/myuser/localfile') # upload a local file
68 ```
69
70 In addition, the file-system generates file objects that are compatible with
71 the python file interface, ensuring compatibility with libraries that work on
72 python files. The recommended way to use this is with a context manager
73 (otherwise, be sure to call `close()` on the file object).
74
75 ```
76 with adl.open('newfile', 'wb') as f:
77 f.write(b'index,a,b\n')
78 f.tell() # now at position 9
79 f.flush() # forces data upstream
80 f.write(b'0,1,True')
81
82 with adl.open('newfile', 'rb') as f:
83 print(f.readlines())
84
85 with adl.open('newfile', 'rb') as f:
86 df = pd.read_csv(f) # read into pandas.
87 ```
88
89 To seamlessly handle remote path representations across all supported platforms,
90 the main API will take in numerous path types: string, Path/PurePath, and
91 AzureDLPath. On Windows in particular, you can pass in paths separated by either
92 forward slashes or backslashes.
93
94 ```
95 import pathlib # only >= Python 3.4
96 from pathlib2 import pathlib # only <= Python 3.3
97
98 from azure.datalake.store.core import AzureDLPath
99
100 # possible remote paths to use on API
101 p1 = '\\foo\\bar'
102 p2 = '/foo/bar'
103 p3 = pathlib.PurePath('\\foo\\bar')
104 p4 = pathlib.PureWindowsPath('\\foo\\bar')
105 p5 = pathlib.PurePath('/foo/bar')
106 p6 = AzureDLPath('\\foo\\bar')
107 p7 = AzureDLPath('/foo/bar')
108
109 # p1, p3, and p6 only work on Windows
110 for p in [p1, p2, p3, p4, p5, p6, p7]:
111 with adl.open(p, 'rb') as f:
112 print(f.readlines())
113 ```
114
115 ## Performant up-/down-loading
116
117 Classes `ADLUploader` and `ADLDownloader` will chunk large files and send
118 many files to/from azure using multiple threads. A whole directory tree can
119 be transferred, files matching a specific glob-pattern or any particular file.
120
121 ```
122 # download the whole directory structure using 5 threads, 16MB chunks
123 ADLDownloader(adl, '', 'my_temp_dir', 5, 2**24)
124 ```
125 # API
126
127 #### class azure.datalake.store.core.AzureDLFileSystem(token=None, per_call_timeout_seconds=60, \*\*kwargs)
128 Access Azure DataLake Store as if it were a file-system
129
130
131 * **Parameters**
132
133 **store_name: str (“”)**
134
135 Store name to connect to.
136
137 **token: credentials object**
138
139 When setting up a new connection, this contains the authorization
140 credentials (see lib.auth()).
141
142 **url_suffix: str (None)**
143
144 Domain to send REST requests to. The end-point URL is constructed
145 using this and the store_name. If None, use default.
146
147 **api_version: str (2018-09-01)**
148
149 The API version to target with requests. Changing this value will
150 change the behavior of the requests, and can cause unexpected behavior or
151 breaking changes. Changes to this value should be undergone with caution.
152
153 **per_call_timeout_seconds: float(60)**
154
155 This is the timeout for each requests library call.
156
157 **kwargs: optional key/values**
158
159 See `lib.auth()`; full list: tenant_id, username, password, client_id,
160 client_secret, resource
161
162
163 ### Methods
164
165 <!-- !! processed by numpydoc !! -->
166
167 #### access(self, path, invalidate_cache=True)
168 Does such a file/directory exist?
169
170
171 * **Parameters**
172
173 **path: str or AzureDLPath**
174
175 Path to query
176
177 **invalidate_cache: bool**
178
179 Whether to invalidate cache
180
181
182
183 * **Returns**
184
185 True or false depending on whether the path exists.
186
187
188 <!-- !! processed by numpydoc !! -->
189
190 #### cat(self, path)
191 Return contents of file
192
193
194 * **Parameters**
195
196 **path: str or AzureDLPath**
197
198 Path to query
199
200
201
202 * **Returns**
203
204 Contents of file
205
206
207 <!-- !! processed by numpydoc !! -->
208
209 #### chmod(self, path, mod)
210 Change access mode of path
211
212 Note this is not recursive.
213
214
215 * **Parameters**
216
217 **path: str**
218
219 Location to change
220
221 **mod: str**
222
223 Octal representation of access, e.g., “0777” for public read/write.
224 See [docs]([http://hadoop.apache.org/docs/r2.4.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Permission](http://hadoop.apache.org/docs/r2.4.1/hadoop-project-dist/hadoop-hdfs/WebHDFS.html#Permission))
225
226
227 <!-- !! processed by numpydoc !! -->
228
229 #### chown(self, path, owner=None, group=None)
230 Change owner and/or owning group
231
232 Note this is not recursive.
233
234
235 * **Parameters**
236
237 **path: str**
238
239 Location to change
240
241 **owner: str**
242
243 UUID of owning entity
244
245 **group: str**
246
247 UUID of group
248
249
250 <!-- !! processed by numpydoc !! -->
251
252 #### concat(self, outfile, filelist, delete_source=False)
253 Concatenate a list of files into one new file
254
255
256 * **Parameters**
257
258 **outfile: path**
259
260 The file which will be concatenated to. If it already exists,
261 the extra pieces will be appended.
262
263 **filelist: list of paths**
264
265 Existing adl files to concatenate, in order
266
267 **delete_source: bool (False)**
268
269 If True, assume that the paths to concatenate exist alone in a
270 directory, and delete that whole directory when done.
271
272
273
274 * **Returns**
275
276 None
277
278
279 <!-- !! processed by numpydoc !! -->
280
281 #### connect(self)
282 Establish connection object.
283
284 <!-- !! processed by numpydoc !! -->
285
286 #### cp(self, path1, path2)
287 Not implemented. Copy file between locations on ADL
288
289 <!-- !! processed by numpydoc !! -->
290
291 #### classmethod current()
292 Return the most recently created AzureDLFileSystem
293
294 <!-- !! processed by numpydoc !! -->
295
296 #### df(self, path)
297 Resource summary of path
298
299
300 * **Parameters**
301
302 **path: str**
303
304 Path to query
305
306
307 <!-- !! processed by numpydoc !! -->
308
309 #### du(self, path, total=False, deep=False, invalidate_cache=True)
310 Bytes in keys at path
311
312
313 * **Parameters**
314
315 **path: str or AzureDLPath**
316
317 Path to query
318
319 **total: bool**
320
321 Return the sum on list
322
323 **deep: bool**
324
325 Recursively enumerate or just use files under current dir
326
327 **invalidate_cache: bool**
328
329 Whether to invalidate cache
330
331
332
333 * **Returns**
334
335 List of dict of name:size pairs or total size.
336
337
338 <!-- !! processed by numpydoc !! -->
339
340 #### exists(self, path, invalidate_cache=True)
341 Does such a file/directory exist?
342
343
344 * **Parameters**
345
346 **path: str or AzureDLPath**
347
348 Path to query
349
350 **invalidate_cache: bool**
351
352 Whether to invalidate cache
353
354
355
356 * **Returns**
357
358 True or false depending on whether the path exists.
359
360
361 <!-- !! processed by numpydoc !! -->
362
363 #### get(self, path, filename)
364 Stream data from file at path to local filename
365
366
367 * **Parameters**
368
369 **path: str or AzureDLPath**
370
371 ADL Path to read
372
373 **filename: str or Path**
374
375 Local file path to write to
376
377
378
379 * **Returns**
380
381 None
382
383
384 <!-- !! processed by numpydoc !! -->
385
386 #### get_acl_status(self, path)
387 Gets Access Control List (ACL) entries for the specified file or directory.
388
389
390 * **Parameters**
391
392 **path: str**
393
394 Location to get the ACL.
395
396
397 <!-- !! processed by numpydoc !! -->
398
399 #### glob(self, path, details=False, invalidate_cache=True)
400 Find files (not directories) by glob-matching.
401
402
403 * **Parameters**
404
405 **path: str or AzureDLPath**
406
407 Path to query
408
409 **details: bool**
410
411 Whether to include file details
412
413 **invalidate_cache: bool**
414
415 Whether to invalidate cache
416
417
418
419 * **Returns**
420
421 List of files
422
423
424 <!-- !! processed by numpydoc !! -->
425
426 #### head(self, path, size=1024)
427 Return first bytes of file
428
429
430 * **Parameters**
431
432 **path: str or AzureDLPath**
433
434 Path to query
435
436 **size: int**
437
438 How many bytes to return
439
440
441
442 * **Returns**
443
444 First(size) bytes of file
445
446
447 <!-- !! processed by numpydoc !! -->
448
449 #### info(self, path, invalidate_cache=True, expected_error_code=None)
450 File information for path
451
452
453 * **Parameters**
454
455 **path: str or AzureDLPath**
456
457 Path to query
458
459 **invalidate_cache: bool**
460
461 Whether to invalidate cache or not
462
463 **expected_error_code: int**
464
465 Optionally indicates a specific, expected error code, if any.
466
467
468
469 * **Returns**
470
471 File information
472
473
474 <!-- !! processed by numpydoc !! -->
475
476 #### invalidate_cache(self, path=None)
477 Remove entry from object file-cache
478
479
480 * **Parameters**
481
482 **path: str or AzureDLPath**
483
484 Remove the path from object file-cache
485
486
487
488 * **Returns**
489
490 None
491
492
493 <!-- !! processed by numpydoc !! -->
494
495 #### listdir(self, path='', detail=False, invalidate_cache=True)
496 List all elements under directory specified with path
497
498
499 * **Parameters**
500
501 **path: str or AzureDLPath**
502
503 Path to query
504
505 **detail: bool**
506
507 Detailed info or not.
508
509 **invalidate_cache: bool**
510
511 Whether to invalidate cache or not
512
513
514
515 * **Returns**
516
517 List of elements under directory specified with path
518
519
520 <!-- !! processed by numpydoc !! -->
521
522 #### ls(self, path='', detail=False, invalidate_cache=True)
523 List all elements under directory specified with path
524
525
526 * **Parameters**
527
528 **path: str or AzureDLPath**
529
530 Path to query
531
532 **detail: bool**
533
534 Detailed info or not.
535
536 **invalidate_cache: bool**
537
538 Whether to invalidate cache or not
539
540
541
542 * **Returns**
543
544 List of elements under directory specified with path
545
546
547 <!-- !! processed by numpydoc !! -->
548
549 #### merge(self, outfile, filelist, delete_source=False)
550 Concatenate a list of files into one new file
551
552
553 * **Parameters**
554
555 **outfile: path**
556
557 The file which will be concatenated to. If it already exists,
558 the extra pieces will be appended.
559
560 **filelist: list of paths**
561
562 Existing adl files to concatenate, in order
563
564 **delete_source: bool (False)**
565
566 If True, assume that the paths to concatenate exist alone in a
567 directory, and delete that whole directory when done.
568
569
570
571 * **Returns**
572
573 None
574
575
576 <!-- !! processed by numpydoc !! -->
577
578 #### mkdir(self, path)
579 Make new directory
580
581
582 * **Parameters**
583
584 **path: str or AzureDLPath**
585
586 Path to create directory
587
588
589
590 * **Returns**
591
592 None
593
594
595 <!-- !! processed by numpydoc !! -->
596
597 #### modify_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None)
598 Modify existing Access Control List (ACL) entries on a file or folder.
599 If the entry does not exist it is added, otherwise it is updated based on the spec passed in.
600 No entries are removed by this process (unlike set_acl).
601
602 Note: this is by default not recursive, and applies only to the file or folder specified.
603
604
605 * **Parameters**
606
607 **path: str**
608
609 Location to set the ACL entries on.
610
611 **acl_spec: str**
612
613 The ACL specification to use in modifying the ACL at the path in the format
614 ‘[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,…’
615
616 **recursive: bool**
617
618 Specifies whether to modify ACLs recursively or not
619
620
621 <!-- !! processed by numpydoc !! -->
622
623 #### mv(self, path1, path2)
624 Move file between locations on ADL
625
626
627 * **Parameters**
628
629 **path1:**
630
631 Source Path
632
633 **path2:**
634
635 Destination path
636
637
638
639 * **Returns**
640
641 None
642
643
644 <!-- !! processed by numpydoc !! -->
645
646 #### open(self, path, mode='rb', blocksize=33554432, delimiter=None)
647 Open a file for reading or writing
648
649
650 * **Parameters**
651
652 **path: string**
653
654 Path of file on ADL
655
656 **mode: string**
657
658 One of ‘rb’, ‘ab’ or ‘wb’
659
660 **blocksize: int**
661
662 Size of data-node blocks if reading
663
664 **delimiter: byte(s) or None**
665
666 For writing delimiter-ended blocks
667
668
669 <!-- !! processed by numpydoc !! -->
670
671 #### put(self, filename, path, delimiter=None)
672 Stream data from local filename to file at path
673
674
675 * **Parameters**
676
677 **filename: str or Path**
678
679 Local file path to read from
680
681 **path: str or AzureDLPath**
682
683 ADL Path to write to
684
685 **delimiter:**
686
687 Optional delimeter for delimiter-ended blocks
688
689
690
691 * **Returns**
692
693 None
694
695
696 <!-- !! processed by numpydoc !! -->
697
698 #### read_block(self, fn, offset, length, delimiter=None)
699 Read a block of bytes from an ADL file
700
701 Starting at `offset` of the file, read `length` bytes. If
702 `delimiter` is set then we ensure that the read starts and stops at
703 delimiter boundaries that follow the locations `offset` and `offset
704 + length`. If `offset` is zero then we start at zero. The
705 bytestring returned WILL include the end delimiter string.
706
707 If offset+length is beyond the eof, reads to eof.
708
709
710 * **Parameters**
711
712 **fn: string**
713
714 Path to filename on ADL
715
716 **offset: int**
717
718 Byte offset to start read
719
720 **length: int**
721
722 Number of bytes to read
723
724 **delimiter: bytes (optional)**
725
726 Ensure reading starts and stops at delimiter bytestring
727
728
729 ### Examples
730
731 ```python
732 >>> adl.read_block('data/file.csv', 0, 13) # doctest: +SKIP
733 b'Alice, 100\nBo'
734 >>> adl.read_block('data/file.csv', 0, 13, delimiter=b'\n') # doctest: +SKIP
735 b'Alice, 100\nBob, 200\n'
736 ```
737
738 Use `length=None` to read to the end of the file.
739 >>> adl.read_block(‘data/file.csv’, 0, None, delimiter=b’n’) # doctest: +SKIP
740 b’Alice, 100nBob, 200nCharlie, 300’
741
742 <!-- !! processed by numpydoc !! -->
743
744 #### remove(self, path, recursive=False)
745 Remove a file or directory
746
747
748 * **Parameters**
749
750 **path: str or AzureDLPath**
751
752 The location to remove.
753
754 **recursive: bool (True)**
755
756 Whether to remove also all entries below, i.e., which are returned
757 by walk().
758
759
760
761 * **Returns**
762
763 None
764
765
766 <!-- !! processed by numpydoc !! -->
767
768 #### remove_acl(self, path)
769 Remove the entire, non default, ACL from the file or folder, including unnamed entries.
770 Default entries cannot be removed this way, please use remove_default_acl for that.
771
772 Note: this is not recursive, and applies only to the file or folder specified.
773
774
775 * **Parameters**
776
777 **path: str**
778
779 Location to remove the ACL.
780
781
782 <!-- !! processed by numpydoc !! -->
783
784 #### remove_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None)
785 Remove existing, named, Access Control List (ACL) entries on a file or folder.
786 If the entry does not exist already it is ignored.
787 Default entries cannot be removed this way, please use remove_default_acl for that.
788 Unnamed entries cannot be removed in this way, please use remove_acl for that.
789
790 Note: this is by default not recursive, and applies only to the file or folder specified.
791
792
793 * **Parameters**
794
795 **path: str**
796
797 Location to remove the ACL entries.
798
799 **acl_spec: str**
800
801 The ACL specification to remove from the ACL at the path in the format (note that the permission portion is missing)
802 ‘[default:]user|group|other:[entity id or UPN],[default:]user|group|other:[entity id or UPN],…’
803
804 **recursive: bool**
805
806 Specifies whether to remove ACLs recursively or not
807
808
809 <!-- !! processed by numpydoc !! -->
810
811 #### remove_default_acl(self, path)
812 Remove the entire default ACL from the folder.
813 Default entries do not exist on files, if a file
814 is specified, this operation does nothing.
815
816 Note: this is not recursive, and applies only to the folder specified.
817
818
819 * **Parameters**
820
821 **path: str**
822
823 Location to set the ACL on.
824
825
826 <!-- !! processed by numpydoc !! -->
827
828 #### rename(self, path1, path2)
829 Move file between locations on ADL
830
831
832 * **Parameters**
833
834 **path1:**
835
836 Source Path
837
838 **path2:**
839
840 Destination path
841
842
843
844 * **Returns**
845
846 None
847
848
849 <!-- !! processed by numpydoc !! -->
850
851 #### rm(self, path, recursive=False)
852 Remove a file or directory
853
854
855 * **Parameters**
856
857 **path: str or AzureDLPath**
858
859 The location to remove.
860
861 **recursive: bool (True)**
862
863 Whether to remove also all entries below, i.e., which are returned
864 by walk().
865
866
867
868 * **Returns**
869
870 None
871
872
873 <!-- !! processed by numpydoc !! -->
874
875 #### rmdir(self, path)
876 Remove empty directory
877
878
879 * **Parameters**
880
881 **path: str or AzureDLPath**
882
883 Directory path to remove
884
885
886
887 * **Returns**
888
889 None
890
891
892 <!-- !! processed by numpydoc !! -->
893
894 #### set_acl(self, path, acl_spec, recursive=False, number_of_sub_process=None)
895 Set the Access Control List (ACL) for a file or folder.
896
897 Note: this is by default not recursive, and applies only to the file or folder specified.
898
899
900 * **Parameters**
901
902 **path: str**
903
904 Location to set the ACL on.
905
906 **acl_spec: str**
907
908 The ACL specification to set on the path in the format
909 ‘[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,…’
910
911 **recursive: bool**
912
913 Specifies whether to set ACLs recursively or not
914
915
916 <!-- !! processed by numpydoc !! -->
917
918 #### set_expiry(self, path, expiry_option, expire_time=None)
919 Set or remove the expiration time on the specified file.
920 This operation can only be executed against files.
921
922 Note: Folders are not supported.
923
924
925 * **Parameters**
926
927 **path: str**
928
929 File path to set or remove expiration time
930
931 **expire_time: int**
932
933 The time that the file will expire, corresponding to the expiry_option that was set
934
935 **expiry_option: str**
936
937 Indicates the type of expiration to use for the file:
938
939 1. NeverExpire: ExpireTime is ignored.
940
941 1. RelativeToNow: ExpireTime is an integer in milliseconds representing the expiration date relative to when file expiration is updated.
942
943 1. RelativeToCreationDate: ExpireTime is an integer in milliseconds representing the expiration date relative to file creation.
944
945 1. Absolute: ExpireTime is an integer in milliseconds, as a Unix timestamp relative to 1/1/1970 00:00:00.
946
947
948 <!-- !! processed by numpydoc !! -->
949
950 #### stat(self, path, invalidate_cache=True, expected_error_code=None)
951 File information for path
952
953
954 * **Parameters**
955
956 **path: str or AzureDLPath**
957
958 Path to query
959
960 **invalidate_cache: bool**
961
962 Whether to invalidate cache or not
963
964 **expected_error_code: int**
965
966 Optionally indicates a specific, expected error code, if any.
967
968
969
970 * **Returns**
971
972 File information
973
974
975 <!-- !! processed by numpydoc !! -->
976
977 #### tail(self, path, size=1024)
978 Return last bytes of file
979
980
981 * **Parameters**
982
983 **path: str or AzureDLPath**
984
985 Path to query
986
987 **size: int**
988
989 How many bytes to return
990
991
992
993 * **Returns**
994
995 Last(size) bytes of file
996
997
998 <!-- !! processed by numpydoc !! -->
999
1000 #### touch(self, path)
1001 Create empty file
1002
1003
1004 * **Parameters**
1005
1006 **path: str or AzureDLPath**
1007
1008 Path of file to create
1009
1010
1011
1012 * **Returns**
1013
1014 None
1015
1016
1017 <!-- !! processed by numpydoc !! -->
1018
1019 #### unlink(self, path, recursive=False)
1020 Remove a file or directory
1021
1022
1023 * **Parameters**
1024
1025 **path: str or AzureDLPath**
1026
1027 The location to remove.
1028
1029 **recursive: bool (True)**
1030
1031 Whether to remove also all entries below, i.e., which are returned
1032 by walk().
1033
1034
1035
1036 * **Returns**
1037
1038 None
1039
1040
1041 <!-- !! processed by numpydoc !! -->
1042
1043 #### walk(self, path='', details=False, invalidate_cache=True)
1044 Get all files below given path
1045
1046
1047 * **Parameters**
1048
1049 **path: str or AzureDLPath**
1050
1051 Path to query
1052
1053 **details: bool**
1054
1055 Whether to include file details
1056
1057 **invalidate_cache: bool**
1058
1059 Whether to invalidate cache
1060
1061
1062
1063 * **Returns**
1064
1065 List of files
1066
1067
1068 <!-- !! processed by numpydoc !! -->
1069
1070 #### class azure.datalake.store.multithread.ADLUploader(adlfs, rpath, lpath, nthreads=None, chunksize=268435456, buffersize=4194304, blocksize=4194304, client=None, run=True, overwrite=False, verbose=False, progress_callback=None, timeout=0)
1071 Upload local file(s) using chunks and threads
1072
1073 Launches multiple threads for efficient uploading, with chunksize
1074 assigned to each. The path can be a single file, a directory
1075 of files or a glob pattern.
1076
1077
1078 * **Parameters**
1079
1080 **adlfs: ADL filesystem instance**
1081
1082 **rpath: str**
1083
1084 remote path to upload to; if multiple files, this is the dircetory
1085 root to write within
1086
1087 **lpath: str**
1088
1089 local path. Can be single file, directory (in which case, upload
1090 recursively) or glob pattern. Recursive glob patterns using \*\* are
1091 not supported.
1092
1093 **nthreads: int [None]**
1094
1095 Number of threads to use. If None, uses the number of cores.
1096
1097 **chunksize: int [2\*\*28]**
1098
1099 Number of bytes for a chunk. Large files are split into chunks. Files
1100 smaller than this number will always be transferred in a single thread.
1101
1102 **buffersize: int [2\*\*22]**
1103
1104 Number of bytes for internal buffer. This block cannot be bigger than
1105 a chunk and cannot be smaller than a block.
1106
1107 **blocksize: int [2\*\*22]**
1108
1109 Number of bytes for a block. Within each chunk, we write a smaller
1110 block for each API call. This block cannot be bigger than a chunk.
1111
1112 **client: ADLTransferClient [None]**
1113
1114 Set an instance of ADLTransferClient when finer-grained control over
1115 transfer parameters is needed. Ignores nthreads and chunksize
1116 set by constructor.
1117
1118 **run: bool [True]**
1119
1120 Whether to begin executing immediately.
1121
1122 **overwrite: bool [False]**
1123
1124 Whether to forcibly overwrite existing files/directories. If False and
1125 remote path is a directory, will quit regardless if any files would be
1126 overwritten or not. If True, only matching filenames are actually
1127 overwritten.
1128
1129 **progress_callback: callable [None]**
1130
1131 Callback for progress with signature function(current, total) where
1132 current is the number of bytes transfered so far, and total is the
1133 size of the blob, or None if the total size is unknown.
1134
1135 **timeout: int (0)**
1136
1137 Default value 0 means infinite timeout. Otherwise time in seconds before the
1138 process will stop and raise an exception if transfer is still in progress
1139
1140
1141
1142 * **Attributes**
1143
1144 **hash**
1145
1146
1147 ### Methods
1148
1149 <!-- !! processed by numpydoc !! -->
1150
1151 #### active(self)
1152 Return whether the uploader is active
1153
1154 <!-- !! processed by numpydoc !! -->
1155
1156 #### static clear_saved()
1157 Remove references to all persisted uploads.
1158
1159 <!-- !! processed by numpydoc !! -->
1160
1161 #### static load()
1162 Load list of persisted transfers from disk, for possible resumption.
1163
1164
1165 * **Returns**
1166
1167 A dictionary of upload instances. The hashes are auto
1168
1169 generated unique. The state of the chunks completed, errored, etc.,
1170 can be seen in the status attribute. Instances can be resumed with
1171 `run()`.
1172
1173
1174 <!-- !! processed by numpydoc !! -->
1175
1176 #### run(self, nthreads=None, monitor=True)
1177 Populate transfer queue and execute downloads
1178
1179
1180 * **Parameters**
1181
1182 **nthreads: int [None]**
1183
1184 Override default nthreads, if given
1185
1186 **monitor: bool [True]**
1187
1188 To watch and wait (block) until completion.
1189
1190
1191 <!-- !! processed by numpydoc !! -->
1192
1193 #### save(self, keep=True)
1194 Persist this upload
1195
1196 Saves a copy of this transfer process in its current state to disk.
1197 This is done automatically for a running transfer, so that as a chunk
1198 is completed, this is reflected. Thus, if a transfer is interrupted,
1199 e.g., by user action, the transfer can be restarted at another time.
1200 All chunks that were not already completed will be restarted at that
1201 time.
1202
1203 See methods `load` to retrieved saved transfers and `run` to
1204 resume a stopped transfer.
1205
1206
1207 * **Parameters**
1208
1209 **keep: bool (True)**
1210
1211 If True, transfer will be saved if some chunks remain to be
1212 completed; the transfer will be sure to be removed otherwise.
1213
1214
1215 <!-- !! processed by numpydoc !! -->
1216
1217 #### successful(self)
1218 Return whether the uploader completed successfully.
1219
1220 It will raise AssertionError if the uploader is active.
1221
1222 <!-- !! processed by numpydoc !! -->
1223
1224 #### class azure.datalake.store.multithread.ADLDownloader(adlfs, rpath, lpath, nthreads=None, chunksize=268435456, buffersize=4194304, blocksize=4194304, client=None, run=True, overwrite=False, verbose=False, progress_callback=None, timeout=0)
1225 Download remote file(s) using chunks and threads
1226
1227 Launches multiple threads for efficient downloading, with chunksize
1228 assigned to each. The remote path can be a single file, a directory
1229 of files or a glob pattern.
1230
1231
1232 * **Parameters**
1233
1234 **adlfs: ADL filesystem instance**
1235
1236 **rpath: str**
1237
1238 remote path/globstring to use to find remote files. Recursive glob
1239 patterns using \*\* are not supported.
1240
1241 **lpath: str**
1242
1243 local path. If downloading a single file, will write to this specific
1244 file, unless it is an existing directory, in which case a file is
1245 created within it. If downloading multiple files, this is the root
1246 directory to write within. Will create directories as required.
1247
1248 **nthreads: int [None]**
1249
1250 Number of threads to use. If None, uses the number of cores.
1251
1252 **chunksize: int [2\*\*28]**
1253
1254 Number of bytes for a chunk. Large files are split into chunks. Files
1255 smaller than this number will always be transferred in a single thread.
1256
1257 **buffersize: int [2\*\*22]**
1258
1259 Ignored in curret implementation.
1260 Number of bytes for internal buffer. This block cannot be bigger than
1261 a chunk and cannot be smaller than a block.
1262
1263 **blocksize: int [2\*\*22]**
1264
1265 Number of bytes for a block. Within each chunk, we write a smaller
1266 block for each API call. This block cannot be bigger than a chunk.
1267
1268 **client: ADLTransferClient [None]**
1269
1270 Set an instance of ADLTransferClient when finer-grained control over
1271 transfer parameters is needed. Ignores nthreads and chunksize set
1272 by constructor.
1273
1274 **run: bool [True]**
1275
1276 Whether to begin executing immediately.
1277
1278 **overwrite: bool [False]**
1279
1280 Whether to forcibly overwrite existing files/directories. If False and
1281 local path is a directory, will quit regardless if any files would be
1282 overwritten or not. If True, only matching filenames are actually
1283 overwritten.
1284
1285 **progress_callback: callable [None]**
1286
1287 Callback for progress with signature function(current, total) where
1288 current is the number of bytes transfered so far, and total is the
1289 size of the blob, or None if the total size is unknown.
1290
1291 **timeout: int (0)**
1292
1293 Default value 0 means infinite timeout. Otherwise time in seconds before the
1294 process will stop and raise an exception if transfer is still in progress
1295
1296
1297
1298 * **Attributes**
1299
1300 **hash**
1301
1302
1303 ### Methods
1304
1305 <!-- !! processed by numpydoc !! -->
1306
1307 #### active(self)
1308 Return whether the downloader is active
1309
1310 <!-- !! processed by numpydoc !! -->
1311
1312 #### static clear_saved()
1313 Remove references to all persisted downloads.
1314
1315 <!-- !! processed by numpydoc !! -->
1316
1317 #### static load()
1318 Load list of persisted transfers from disk, for possible resumption.
1319
1320
1321 * **Returns**
1322
1323 A dictionary of download instances. The hashes are auto-
1324
1325 generated unique. The state of the chunks completed, errored, etc.,
1326 can be seen in the status attribute. Instances can be resumed with
1327 `run()`.
1328
1329
1330 <!-- !! processed by numpydoc !! -->
1331
1332 #### run(self, nthreads=None, monitor=True)
1333 Populate transfer queue and execute downloads
1334
1335
1336 * **Parameters**
1337
1338 **nthreads: int [None]**
1339
1340 Override default nthreads, if given
1341
1342 **monitor: bool [True]**
1343
1344 To watch and wait (block) until completion.
1345
1346
1347 <!-- !! processed by numpydoc !! -->
1348
1349 #### save(self, keep=True)
1350 Persist this download
1351
1352 Saves a copy of this transfer process in its current state to disk.
1353 This is done automatically for a running transfer, so that as a chunk
1354 is completed, this is reflected. Thus, if a transfer is interrupted,
1355 e.g., by user action, the transfer can be restarted at another time.
1356 All chunks that were not already completed will be restarted at that
1357 time.
1358
1359 See methods `load` to retrieved saved transfers and `run` to
1360 resume a stopped transfer.
1361
1362
1363 * **Parameters**
1364
1365 **keep: bool (True)**
1366
1367 If True, transfer will be saved if some chunks remain to be
1368 completed; the transfer will be sure to be removed otherwise.
1369
1370
1371 <!-- !! processed by numpydoc !! -->
1372
1373 #### successful(self)
1374 Return whether the downloader completed successfully.
1375
1376 It will raise AssertionError if the downloader is active.
1377
1378 <!-- !! processed by numpydoc !! -->
1379
1380 #### azure.datalake.store.lib.auth(tenant_id=None, username=None, password=None, client_id='', client_secret=None, resource='https://datalake.azure.net/', require_2fa=False, authority=None, retry_policy=None, \*\*kwargs)
1381 User/password authentication
1382
1383
1384 * **Parameters**
1385
1386 **tenant_id: str**
1387
1388 associated with the user’s subscription, or “common”
1389
1390 **username: str**
1391
1392 active directory user
1393
1394 **password: str**
1395
1396 sign-in password
1397
1398 **client_id: str**
1399
1400 the service principal client
1401
1402 **client_secret: str**
1403
1404 the secret associated with the client_id
1405
1406 **resource: str**
1407
1408 resource for auth (e.g., [https://datalake.azure.net/](https://datalake.azure.net/))
1409
1410 **require_2fa: bool**
1411
1412 indicates this authentication attempt requires two-factor authentication
1413
1414 **authority: string**
1415
1416 The full URI of the authentication authority to authenticate against (such as [https://login.microsoftonline.com/](https://login.microsoftonline.com/))
1417
1418 **kwargs: key/values**
1419
1420 Other parameters, for future use
1421
1422
1423
1424 * **Returns**
1425
1426 :type DataLakeCredential :mod: A DataLakeCredential object
1427
1428
1429 <!-- !! processed by numpydoc !! -->