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 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429
|
# azure-datalake-store
A pure-python interface to the Azure Data-lake Storage Gen 1 system, providing
pythonic file-system and file objects, seamless transition between Windows and
POSIX remote paths, high-performance up- and down-loader.
This software is under active development and not yet recommended for general
use.
*Note:* This library supports ADLS Gen 1. For Gen 2, please see
`azure-storage-file-datalake`, documented
[here](https://docs.microsoft.com/en-us/samples/azure/azure-sdk-for-python/storage-datalake-samples/)
## Installation
Using `pip`:
```
pip install azure-datalake-store
```
Manually (bleeding edge):
* Download the repo from [https://github.com/Azure/azure-data-lake-store-python](https://github.com/Azure/azure-data-lake-store-python)
* install the requirements (`pip install -r dev_requirements.txt`)
* install in develop mode (`python setup.py develop`)
## Auth
Although users can generate and supply their own tokens to the base file-system
class, and there is a password-based function in the `lib` module for
generating tokens, the most convenient way to supply credentials is via
environment parameters. This latter method is the one used by default in
library. The following variables are required:
* azure_tenant_id
* azure_username
* azure_password
* azure_store_name
* azure_url_suffix (optional)
## Pythonic Filesystem
The `AzureDLFileSystem` object is the main API for library usage of this
package. It provides typical file-system operations on the remote azure
store
```
token = lib.auth(tenant_id, username, password)
adl = core.AzureDLFileSystem(store_name, token)
# alternatively, adl = core.AzureDLFileSystem()
# uses environment variables
print(adl.ls()) # list files in the root directory
for item in adl.ls(detail=True):
print(item) # same, but with file details as dictionaries
print(adl.walk('')) # list all files at any directory depth
print('Usage:', adl.du('', deep=True, total=True)) # total bytes usage
adl.mkdir('newdir') # create directory
adl.touch('newdir/newfile') # create empty file
adl.put('remotefile', '/home/myuser/localfile') # upload a local file
```
In addition, the file-system generates file objects that are compatible with
the python file interface, ensuring compatibility with libraries that work on
python files. The recommended way to use this is with a context manager
(otherwise, be sure to call `close()` on the file object).
```
with adl.open('newfile', 'wb') as f:
f.write(b'index,a,b\n')
f.tell() # now at position 9
f.flush() # forces data upstream
f.write(b'0,1,True')
with adl.open('newfile', 'rb') as f:
print(f.readlines())
with adl.open('newfile', 'rb') as f:
df = pd.read_csv(f) # read into pandas.
```
To seamlessly handle remote path representations across all supported platforms,
the main API will take in numerous path types: string, Path/PurePath, and
AzureDLPath. On Windows in particular, you can pass in paths separated by either
forward slashes or backslashes.
```
import pathlib # only >= Python 3.4
from pathlib2 import pathlib # only <= Python 3.3
from azure.datalake.store.core import AzureDLPath
# possible remote paths to use on API
p1 = '\\foo\\bar'
p2 = '/foo/bar'
p3 = pathlib.PurePath('\\foo\\bar')
p4 = pathlib.PureWindowsPath('\\foo\\bar')
p5 = pathlib.PurePath('/foo/bar')
p6 = AzureDLPath('\\foo\\bar')
p7 = AzureDLPath('/foo/bar')
# p1, p3, and p6 only work on Windows
for p in [p1, p2, p3, p4, p5, p6, p7]:
with adl.open(p, 'rb') as f:
print(f.readlines())
```
## Performant up-/down-loading
Classes `ADLUploader` and `ADLDownloader` will chunk large files and send
many files to/from azure using multiple threads. A whole directory tree can
be transferred, files matching a specific glob-pattern or any particular file.
```
# download the whole directory structure using 5 threads, 16MB chunks
ADLDownloader(adl, '', 'my_temp_dir', 5, 2**24)
```
# API
#### class azure.datalake.store.core.AzureDLFileSystem(token=None, per_call_timeout_seconds=60, \*\*kwargs)
Access Azure DataLake Store as if it were a file-system
* **Parameters**
**store_name: str (“”)**
Store name to connect to.
**token: credentials object**
When setting up a new connection, this contains the authorization
credentials (see lib.auth()).
**url_suffix: str (None)**
Domain to send REST requests to. The end-point URL is constructed
using this and the store_name. If None, use default.
**api_version: str (2018-09-01)**
The API version to target with requests. Changing this value will
change the behavior of the requests, and can cause unexpected behavior or
breaking changes. Changes to this value should be undergone with caution.
**per_call_timeout_seconds: float(60)**
This is the timeout for each requests library call.
**kwargs: optional key/values**
See `lib.auth()`; full list: tenant_id, username, password, client_id,
client_secret, resource
### Methods
<!-- !! processed by numpydoc !! -->
#### access(self, path, invalidate_cache=True)
Does such a file/directory exist?
* **Parameters**
**path: str or AzureDLPath**
Path to query
**invalidate_cache: bool**
Whether to invalidate cache
* **Returns**
True or false depending on whether the path exists.
<!-- !! processed by numpydoc !! -->
#### cat(self, path)
Return contents of file
* **Parameters**
**path: str or AzureDLPath**
Path to query
* **Returns**
Contents of file
<!-- !! processed by numpydoc !! -->
#### chmod(self, path, mod)
Change access mode of path
Note this is not recursive.
* **Parameters**
**path: str**
Location to change
**mod: str**
Octal representation of access, e.g., “0777” for public read/write.
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))
<!-- !! processed by numpydoc !! -->
#### chown(self, path, owner=None, group=None)
Change owner and/or owning group
Note this is not recursive.
* **Parameters**
**path: str**
Location to change
**owner: str**
UUID of owning entity
**group: str**
UUID of group
<!-- !! processed by numpydoc !! -->
#### concat(self, outfile, filelist, delete_source=False)
Concatenate a list of files into one new file
* **Parameters**
**outfile: path**
The file which will be concatenated to. If it already exists,
the extra pieces will be appended.
**filelist: list of paths**
Existing adl files to concatenate, in order
**delete_source: bool (False)**
If True, assume that the paths to concatenate exist alone in a
directory, and delete that whole directory when done.
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### connect(self)
Establish connection object.
<!-- !! processed by numpydoc !! -->
#### cp(self, path1, path2)
Not implemented. Copy file between locations on ADL
<!-- !! processed by numpydoc !! -->
#### classmethod current()
Return the most recently created AzureDLFileSystem
<!-- !! processed by numpydoc !! -->
#### df(self, path)
Resource summary of path
* **Parameters**
**path: str**
Path to query
<!-- !! processed by numpydoc !! -->
#### du(self, path, total=False, deep=False, invalidate_cache=True)
Bytes in keys at path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**total: bool**
Return the sum on list
**deep: bool**
Recursively enumerate or just use files under current dir
**invalidate_cache: bool**
Whether to invalidate cache
* **Returns**
List of dict of name:size pairs or total size.
<!-- !! processed by numpydoc !! -->
#### exists(self, path, invalidate_cache=True)
Does such a file/directory exist?
* **Parameters**
**path: str or AzureDLPath**
Path to query
**invalidate_cache: bool**
Whether to invalidate cache
* **Returns**
True or false depending on whether the path exists.
<!-- !! processed by numpydoc !! -->
#### get(self, path, filename)
Stream data from file at path to local filename
* **Parameters**
**path: str or AzureDLPath**
ADL Path to read
**filename: str or Path**
Local file path to write to
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### get_acl_status(self, path)
Gets Access Control List (ACL) entries for the specified file or directory.
* **Parameters**
**path: str**
Location to get the ACL.
<!-- !! processed by numpydoc !! -->
#### glob(self, path, details=False, invalidate_cache=True)
Find files (not directories) by glob-matching.
* **Parameters**
**path: str or AzureDLPath**
Path to query
**details: bool**
Whether to include file details
**invalidate_cache: bool**
Whether to invalidate cache
* **Returns**
List of files
<!-- !! processed by numpydoc !! -->
#### head(self, path, size=1024)
Return first bytes of file
* **Parameters**
**path: str or AzureDLPath**
Path to query
**size: int**
How many bytes to return
* **Returns**
First(size) bytes of file
<!-- !! processed by numpydoc !! -->
#### info(self, path, invalidate_cache=True, expected_error_code=None)
File information for path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**invalidate_cache: bool**
Whether to invalidate cache or not
**expected_error_code: int**
Optionally indicates a specific, expected error code, if any.
* **Returns**
File information
<!-- !! processed by numpydoc !! -->
#### invalidate_cache(self, path=None)
Remove entry from object file-cache
* **Parameters**
**path: str or AzureDLPath**
Remove the path from object file-cache
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### listdir(self, path='', detail=False, invalidate_cache=True)
List all elements under directory specified with path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**detail: bool**
Detailed info or not.
**invalidate_cache: bool**
Whether to invalidate cache or not
* **Returns**
List of elements under directory specified with path
<!-- !! processed by numpydoc !! -->
#### ls(self, path='', detail=False, invalidate_cache=True)
List all elements under directory specified with path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**detail: bool**
Detailed info or not.
**invalidate_cache: bool**
Whether to invalidate cache or not
* **Returns**
List of elements under directory specified with path
<!-- !! processed by numpydoc !! -->
#### merge(self, outfile, filelist, delete_source=False)
Concatenate a list of files into one new file
* **Parameters**
**outfile: path**
The file which will be concatenated to. If it already exists,
the extra pieces will be appended.
**filelist: list of paths**
Existing adl files to concatenate, in order
**delete_source: bool (False)**
If True, assume that the paths to concatenate exist alone in a
directory, and delete that whole directory when done.
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### mkdir(self, path)
Make new directory
* **Parameters**
**path: str or AzureDLPath**
Path to create directory
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### modify_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None)
Modify existing Access Control List (ACL) entries on a file or folder.
If the entry does not exist it is added, otherwise it is updated based on the spec passed in.
No entries are removed by this process (unlike set_acl).
Note: this is by default not recursive, and applies only to the file or folder specified.
* **Parameters**
**path: str**
Location to set the ACL entries on.
**acl_spec: str**
The ACL specification to use in modifying the ACL at the path in the format
‘[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,…’
**recursive: bool**
Specifies whether to modify ACLs recursively or not
<!-- !! processed by numpydoc !! -->
#### mv(self, path1, path2)
Move file between locations on ADL
* **Parameters**
**path1:**
Source Path
**path2:**
Destination path
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### open(self, path, mode='rb', blocksize=33554432, delimiter=None)
Open a file for reading or writing
* **Parameters**
**path: string**
Path of file on ADL
**mode: string**
One of ‘rb’, ‘ab’ or ‘wb’
**blocksize: int**
Size of data-node blocks if reading
**delimiter: byte(s) or None**
For writing delimiter-ended blocks
<!-- !! processed by numpydoc !! -->
#### put(self, filename, path, delimiter=None)
Stream data from local filename to file at path
* **Parameters**
**filename: str or Path**
Local file path to read from
**path: str or AzureDLPath**
ADL Path to write to
**delimiter:**
Optional delimeter for delimiter-ended blocks
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### read_block(self, fn, offset, length, delimiter=None)
Read a block of bytes from an ADL file
Starting at `offset` of the file, read `length` bytes. If
`delimiter` is set then we ensure that the read starts and stops at
delimiter boundaries that follow the locations `offset` and `offset
+ length`. If `offset` is zero then we start at zero. The
bytestring returned WILL include the end delimiter string.
If offset+length is beyond the eof, reads to eof.
* **Parameters**
**fn: string**
Path to filename on ADL
**offset: int**
Byte offset to start read
**length: int**
Number of bytes to read
**delimiter: bytes (optional)**
Ensure reading starts and stops at delimiter bytestring
### Examples
```python
>>> adl.read_block('data/file.csv', 0, 13) # doctest: +SKIP
b'Alice, 100\nBo'
>>> adl.read_block('data/file.csv', 0, 13, delimiter=b'\n') # doctest: +SKIP
b'Alice, 100\nBob, 200\n'
```
Use `length=None` to read to the end of the file.
>>> adl.read_block(‘data/file.csv’, 0, None, delimiter=b’n’) # doctest: +SKIP
b’Alice, 100nBob, 200nCharlie, 300’
<!-- !! processed by numpydoc !! -->
#### remove(self, path, recursive=False)
Remove a file or directory
* **Parameters**
**path: str or AzureDLPath**
The location to remove.
**recursive: bool (True)**
Whether to remove also all entries below, i.e., which are returned
by walk().
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### remove_acl(self, path)
Remove the entire, non default, ACL from the file or folder, including unnamed entries.
Default entries cannot be removed this way, please use remove_default_acl for that.
Note: this is not recursive, and applies only to the file or folder specified.
* **Parameters**
**path: str**
Location to remove the ACL.
<!-- !! processed by numpydoc !! -->
#### remove_acl_entries(self, path, acl_spec, recursive=False, number_of_sub_process=None)
Remove existing, named, Access Control List (ACL) entries on a file or folder.
If the entry does not exist already it is ignored.
Default entries cannot be removed this way, please use remove_default_acl for that.
Unnamed entries cannot be removed in this way, please use remove_acl for that.
Note: this is by default not recursive, and applies only to the file or folder specified.
* **Parameters**
**path: str**
Location to remove the ACL entries.
**acl_spec: str**
The ACL specification to remove from the ACL at the path in the format (note that the permission portion is missing)
‘[default:]user|group|other:[entity id or UPN],[default:]user|group|other:[entity id or UPN],…’
**recursive: bool**
Specifies whether to remove ACLs recursively or not
<!-- !! processed by numpydoc !! -->
#### remove_default_acl(self, path)
Remove the entire default ACL from the folder.
Default entries do not exist on files, if a file
is specified, this operation does nothing.
Note: this is not recursive, and applies only to the folder specified.
* **Parameters**
**path: str**
Location to set the ACL on.
<!-- !! processed by numpydoc !! -->
#### rename(self, path1, path2)
Move file between locations on ADL
* **Parameters**
**path1:**
Source Path
**path2:**
Destination path
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### rm(self, path, recursive=False)
Remove a file or directory
* **Parameters**
**path: str or AzureDLPath**
The location to remove.
**recursive: bool (True)**
Whether to remove also all entries below, i.e., which are returned
by walk().
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### rmdir(self, path)
Remove empty directory
* **Parameters**
**path: str or AzureDLPath**
Directory path to remove
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### set_acl(self, path, acl_spec, recursive=False, number_of_sub_process=None)
Set the Access Control List (ACL) for a file or folder.
Note: this is by default not recursive, and applies only to the file or folder specified.
* **Parameters**
**path: str**
Location to set the ACL on.
**acl_spec: str**
The ACL specification to set on the path in the format
‘[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,[default:]user|group|other:[entity id or UPN]:r|-w|-x|-,…’
**recursive: bool**
Specifies whether to set ACLs recursively or not
<!-- !! processed by numpydoc !! -->
#### set_expiry(self, path, expiry_option, expire_time=None)
Set or remove the expiration time on the specified file.
This operation can only be executed against files.
Note: Folders are not supported.
* **Parameters**
**path: str**
File path to set or remove expiration time
**expire_time: int**
The time that the file will expire, corresponding to the expiry_option that was set
**expiry_option: str**
Indicates the type of expiration to use for the file:
1. NeverExpire: ExpireTime is ignored.
1. RelativeToNow: ExpireTime is an integer in milliseconds representing the expiration date relative to when file expiration is updated.
1. RelativeToCreationDate: ExpireTime is an integer in milliseconds representing the expiration date relative to file creation.
1. Absolute: ExpireTime is an integer in milliseconds, as a Unix timestamp relative to 1/1/1970 00:00:00.
<!-- !! processed by numpydoc !! -->
#### stat(self, path, invalidate_cache=True, expected_error_code=None)
File information for path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**invalidate_cache: bool**
Whether to invalidate cache or not
**expected_error_code: int**
Optionally indicates a specific, expected error code, if any.
* **Returns**
File information
<!-- !! processed by numpydoc !! -->
#### tail(self, path, size=1024)
Return last bytes of file
* **Parameters**
**path: str or AzureDLPath**
Path to query
**size: int**
How many bytes to return
* **Returns**
Last(size) bytes of file
<!-- !! processed by numpydoc !! -->
#### touch(self, path)
Create empty file
* **Parameters**
**path: str or AzureDLPath**
Path of file to create
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### unlink(self, path, recursive=False)
Remove a file or directory
* **Parameters**
**path: str or AzureDLPath**
The location to remove.
**recursive: bool (True)**
Whether to remove also all entries below, i.e., which are returned
by walk().
* **Returns**
None
<!-- !! processed by numpydoc !! -->
#### walk(self, path='', details=False, invalidate_cache=True)
Get all files below given path
* **Parameters**
**path: str or AzureDLPath**
Path to query
**details: bool**
Whether to include file details
**invalidate_cache: bool**
Whether to invalidate cache
* **Returns**
List of files
<!-- !! processed by numpydoc !! -->
#### 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)
Upload local file(s) using chunks and threads
Launches multiple threads for efficient uploading, with chunksize
assigned to each. The path can be a single file, a directory
of files or a glob pattern.
* **Parameters**
**adlfs: ADL filesystem instance**
**rpath: str**
remote path to upload to; if multiple files, this is the dircetory
root to write within
**lpath: str**
local path. Can be single file, directory (in which case, upload
recursively) or glob pattern. Recursive glob patterns using \*\* are
not supported.
**nthreads: int [None]**
Number of threads to use. If None, uses the number of cores.
**chunksize: int [2\*\*28]**
Number of bytes for a chunk. Large files are split into chunks. Files
smaller than this number will always be transferred in a single thread.
**buffersize: int [2\*\*22]**
Number of bytes for internal buffer. This block cannot be bigger than
a chunk and cannot be smaller than a block.
**blocksize: int [2\*\*22]**
Number of bytes for a block. Within each chunk, we write a smaller
block for each API call. This block cannot be bigger than a chunk.
**client: ADLTransferClient [None]**
Set an instance of ADLTransferClient when finer-grained control over
transfer parameters is needed. Ignores nthreads and chunksize
set by constructor.
**run: bool [True]**
Whether to begin executing immediately.
**overwrite: bool [False]**
Whether to forcibly overwrite existing files/directories. If False and
remote path is a directory, will quit regardless if any files would be
overwritten or not. If True, only matching filenames are actually
overwritten.
**progress_callback: callable [None]**
Callback for progress with signature function(current, total) where
current is the number of bytes transfered so far, and total is the
size of the blob, or None if the total size is unknown.
**timeout: int (0)**
Default value 0 means infinite timeout. Otherwise time in seconds before the
process will stop and raise an exception if transfer is still in progress
* **Attributes**
**hash**
### Methods
<!-- !! processed by numpydoc !! -->
#### active(self)
Return whether the uploader is active
<!-- !! processed by numpydoc !! -->
#### static clear_saved()
Remove references to all persisted uploads.
<!-- !! processed by numpydoc !! -->
#### static load()
Load list of persisted transfers from disk, for possible resumption.
* **Returns**
A dictionary of upload instances. The hashes are auto
generated unique. The state of the chunks completed, errored, etc.,
can be seen in the status attribute. Instances can be resumed with
`run()`.
<!-- !! processed by numpydoc !! -->
#### run(self, nthreads=None, monitor=True)
Populate transfer queue and execute downloads
* **Parameters**
**nthreads: int [None]**
Override default nthreads, if given
**monitor: bool [True]**
To watch and wait (block) until completion.
<!-- !! processed by numpydoc !! -->
#### save(self, keep=True)
Persist this upload
Saves a copy of this transfer process in its current state to disk.
This is done automatically for a running transfer, so that as a chunk
is completed, this is reflected. Thus, if a transfer is interrupted,
e.g., by user action, the transfer can be restarted at another time.
All chunks that were not already completed will be restarted at that
time.
See methods `load` to retrieved saved transfers and `run` to
resume a stopped transfer.
* **Parameters**
**keep: bool (True)**
If True, transfer will be saved if some chunks remain to be
completed; the transfer will be sure to be removed otherwise.
<!-- !! processed by numpydoc !! -->
#### successful(self)
Return whether the uploader completed successfully.
It will raise AssertionError if the uploader is active.
<!-- !! processed by numpydoc !! -->
#### 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)
Download remote file(s) using chunks and threads
Launches multiple threads for efficient downloading, with chunksize
assigned to each. The remote path can be a single file, a directory
of files or a glob pattern.
* **Parameters**
**adlfs: ADL filesystem instance**
**rpath: str**
remote path/globstring to use to find remote files. Recursive glob
patterns using \*\* are not supported.
**lpath: str**
local path. If downloading a single file, will write to this specific
file, unless it is an existing directory, in which case a file is
created within it. If downloading multiple files, this is the root
directory to write within. Will create directories as required.
**nthreads: int [None]**
Number of threads to use. If None, uses the number of cores.
**chunksize: int [2\*\*28]**
Number of bytes for a chunk. Large files are split into chunks. Files
smaller than this number will always be transferred in a single thread.
**buffersize: int [2\*\*22]**
Ignored in curret implementation.
Number of bytes for internal buffer. This block cannot be bigger than
a chunk and cannot be smaller than a block.
**blocksize: int [2\*\*22]**
Number of bytes for a block. Within each chunk, we write a smaller
block for each API call. This block cannot be bigger than a chunk.
**client: ADLTransferClient [None]**
Set an instance of ADLTransferClient when finer-grained control over
transfer parameters is needed. Ignores nthreads and chunksize set
by constructor.
**run: bool [True]**
Whether to begin executing immediately.
**overwrite: bool [False]**
Whether to forcibly overwrite existing files/directories. If False and
local path is a directory, will quit regardless if any files would be
overwritten or not. If True, only matching filenames are actually
overwritten.
**progress_callback: callable [None]**
Callback for progress with signature function(current, total) where
current is the number of bytes transfered so far, and total is the
size of the blob, or None if the total size is unknown.
**timeout: int (0)**
Default value 0 means infinite timeout. Otherwise time in seconds before the
process will stop and raise an exception if transfer is still in progress
* **Attributes**
**hash**
### Methods
<!-- !! processed by numpydoc !! -->
#### active(self)
Return whether the downloader is active
<!-- !! processed by numpydoc !! -->
#### static clear_saved()
Remove references to all persisted downloads.
<!-- !! processed by numpydoc !! -->
#### static load()
Load list of persisted transfers from disk, for possible resumption.
* **Returns**
A dictionary of download instances. The hashes are auto-
generated unique. The state of the chunks completed, errored, etc.,
can be seen in the status attribute. Instances can be resumed with
`run()`.
<!-- !! processed by numpydoc !! -->
#### run(self, nthreads=None, monitor=True)
Populate transfer queue and execute downloads
* **Parameters**
**nthreads: int [None]**
Override default nthreads, if given
**monitor: bool [True]**
To watch and wait (block) until completion.
<!-- !! processed by numpydoc !! -->
#### save(self, keep=True)
Persist this download
Saves a copy of this transfer process in its current state to disk.
This is done automatically for a running transfer, so that as a chunk
is completed, this is reflected. Thus, if a transfer is interrupted,
e.g., by user action, the transfer can be restarted at another time.
All chunks that were not already completed will be restarted at that
time.
See methods `load` to retrieved saved transfers and `run` to
resume a stopped transfer.
* **Parameters**
**keep: bool (True)**
If True, transfer will be saved if some chunks remain to be
completed; the transfer will be sure to be removed otherwise.
<!-- !! processed by numpydoc !! -->
#### successful(self)
Return whether the downloader completed successfully.
It will raise AssertionError if the downloader is active.
<!-- !! processed by numpydoc !! -->
#### 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)
User/password authentication
* **Parameters**
**tenant_id: str**
associated with the user’s subscription, or “common”
**username: str**
active directory user
**password: str**
sign-in password
**client_id: str**
the service principal client
**client_secret: str**
the secret associated with the client_id
**resource: str**
resource for auth (e.g., [https://datalake.azure.net/](https://datalake.azure.net/))
**require_2fa: bool**
indicates this authentication attempt requires two-factor authentication
**authority: string**
The full URI of the authentication authority to authenticate against (such as [https://login.microsoftonline.com/](https://login.microsoftonline.com/))
**kwargs: key/values**
Other parameters, for future use
* **Returns**
:type DataLakeCredential :mod: A DataLakeCredential object
<!-- !! processed by numpydoc !! -->
|