diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/404.html b/404.html new file mode 100644 index 000000000..ec61b2465 --- /dev/null +++ b/404.html @@ -0,0 +1,1482 @@ + + + +
+ + + + + + + + + + + + + + +API
+
+
+¶API Client class to communicate with the CRIPT API
+ +src/cript/api/api.py
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 |
|
host
+
+
+ property
+
+
+¶Read only access to the currently connected host.
+The term "host" designates the specific CRIPT instance to which you intend to upload your data.
+For most users, the host will be https://api.criptapp.org
Examples:
+ +schema
+
+
+ property
+
+
+¶Access the CRIPT Database Schema that is associated with this API connection. +The CRIPT Database Schema is used to validate a node's JSON so that it is compatible with the CRIPT API.
+verbose: bool
+
+
+ property
+ writable
+
+
+¶A boolean flag that controls whether verbose logging is enabled or not.
+When verbose
is set to True
, the class will provide additional detailed logging
+to the terminal. This can be useful for debugging and understanding the internal
+workings of the class.
When verbose
is set to False
, the class will only provide essential logging information,
+making the terminal output less cluttered and more user-friendly.
Examples:
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... # turn off the terminal logs
+... api.verbose = False
+
Returns:
+Type | +Description | +
---|---|
+ bool
+ |
+
+
+
+ verbose boolean value + |
+
__init__(host=None, api_token=None, storage_token=None, config_file_path='')
+
+¶Initialize CRIPT API client with host and token. +Additionally, you can use a config.json file and specify the file path.
+api client context manager
+It is necessary to use a with
context manager for the API
Examples:
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... # node creation, api.save(), etc.
+... pass
+
Token Security
+It is highly recommended that you store your API tokens in a safe location and read it into your code +Hard-coding API tokens directly into the code can pose security risks, +as the token might be exposed if the code is shared or stored in a version control system. +Anyone that has access to your tokens can impersonate you on the CRIPT platform
+Another great way to keep sensitive information secure is by using +environment variables. +Sensitive information can be securely stored in environment variables and loaded into the code using +os.getenv().
+ + + +Examples:
+>>> import cript
+>>> import os
+>>> # securely load sensitive data into the script
+>>> cript_host = os.getenv("cript_host")
+>>> cript_api_token = os.getenv("cript_api_token")
+>>> cript_storage_token = os.getenv("cript_storage_token")
+>>> with cript.API(
+... host=cript_host, api_token=cript_api_token, storage_token=cript_storage_token
+... ) as api:
+... pass
+
Alternatively you can configure your system to have an environment variable of
+CRIPT_TOKEN
for the API token and CRIPT_STORAGE_TOKEN
for the storage token, then
+initialize cript.API
api_token
and storage_token
with None
.
The CRIPT Python SDK will try to read the API Token and Storage token from your system's environment variables.
+with cript.API(host=cript_host, api_token=None, storage_token=None) as api:
+ # write your script
+ pass
+
config.json
+
{
+ "host": "https://api.criptapp.org/",
+ "api_token": "I am API token",
+ "storage_token": "I am storage token"
+}
+
Examples:
+my_script.py
>>> from pathlib import Path
+>>> import cript
+>>> # create a file path object of where the config file is
+>>> config_file_path = Path(__file__) / Path('./config.json')
+>>> with cript.API(config_file_path=config_file_path) as api:
+... # node creation, api.save(), etc.
+... pass
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
host |
+
+ (str, None)
+ |
+
+
+
+ CRIPT host for the Python SDK to connect to such as https://api.criptapp.org/ |
+
+ None
+ |
+
api_token |
+
+ (str, None)
+ |
+
+
+
+ CRIPT API Token used to connect to CRIPT and upload all data with the exception to file upload that needs
+a different token.
+You can find your personal token on the cript website at User > Security Settings.
+The user icon is in the top right.
+If |
+
+ None
+ |
+
storage_token |
+
+ Union[str, None]
+ |
+
+
+
+ This token is used to upload local files to CRIPT cloud storage when needed + |
+
+ None
+ |
+
config_file_path |
+
+ Union[str, Path]
+ |
+
+
+
+ the file path to the config.json file where the token and host can be found + |
+
+ ''
+ |
+
host=None
and token=None
+ then the Python SDK will grab the host from the users environment variable of "CRIPT_HOST"
+ and "CRIPT_TOKEN"
Warns:
+Type | +Description | +
---|---|
+ UserWarning
+ |
+
+
+
+ If |
+
Raises:
+Type | +Description | +
---|---|
+ CRIPTConnectionError
+ |
+
+
+
+ If it cannot connect to CRIPT with the provided host and token a CRIPTConnectionError is thrown. + |
+
Returns:
+Type | +Description | +
---|---|
+ None
+ |
+
+
+
+ Instantiate a new CRIPT API object + |
+
src/cript/api/api.py
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 |
|
__str__()
+
+¶States the host of the CRIPT API client
+ + + +Examples:
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... print(api)
+CRIPT API Client - Host URL: 'https://api.criptapp.org/api/v1'
+
Returns:
+Type | +Description | +
---|---|
+ str
+ |
+
+
+
+
+ |
+
src/cript/api/api.py
connect()
+
+¶Connect this API globally as the current active access point.
+It is not necessary to call this function manually if a context manager is used.
+A context manager is preferred where possible.
+Jupyter notebooks are a use case where this connection can be handled manually.
+If this function is called manually, the API.disconnect
function has to be called later.
For manual connection: nested API object are discouraged.
+ +src/cript/api/api.py
delete(node)
+
+¶Simply deletes the desired node from the CRIPT API and writes a log in the terminal that the node has been +successfully deleted.
+ + + +Examples:
+>>> import cript
+>>> my_material_node = cript.Material(
+... name="my component material 1",
+... identifier=[{"amino_acid": "component 1 alternative name"}],
+... )
+>>> api.delete(node=my_material_node)
+
After the node has been successfully deleted, a log is written to the terminal if cript.API.verbose = True
Under the hood, this method actually calls +delete_node_by_uuid +with the node_type and node UUID
+After successfully deleting a node from the API, keep in mind that your local Project node in your script +may still contain outdated data as it has not been synced with the API.
+To ensure you have the latest data, follow these steps:
+cript.API.search()
provided by the SDK.load_nodes_from_json
utility function.Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
node |
+ + | +
+
+
+ The node that you want to delete + |
+ + required + | +
Raises:
+Type | +Description | +
---|---|
+ APIError
+ |
+
+
+
+ If the API responds with anything other than HTTP status 200, then the CRIPT Python SDK raises |
+
Returns:
+Type | +Description | +
---|---|
+ None
+ |
+
+
+
+
+ |
+
src/cript/api/api.py
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 |
|
delete_node_by_uuid(node_type, node_uuid)
+
+¶Simply deletes the desired node from the CRIPT API and writes a log in the terminal that the node has been +successfully deleted.
+ + + +Examples:
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... api.delete_node_by_uuid(
+... node_type="computation_process",
+... node_uuid="2fd3d500-304d-4a06-8628-a79b59344b2f"
+... )
+
node_type in snake case
You can get the node type in snake case
of a node via:
+
You can also call api.delete_node_by_uuid()
with
+
After the node has been successfully deleted, a log is written to the terminal if cript.API.verbose = True
After successfully deleting a node from the API, keep in mind that your local Project node in your script +may still contain outdated data as it has not been synced with the API.
+To ensure you have the latest data, follow these steps:
+cript.API.search()
provided by the SDK.load_nodes_from_json
utility function.Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
node_type |
+
+ str
+ |
+
+
+
+ the type of node that you want to delete in snake case + |
+ + required + | +
node_uuid |
+
+ str
+ |
+
+
+
+ the UUID of the primary node, supporting node, or sub-object +that you want to delete from the API + |
+ + required + | +
Raises:
+Type | +Description | +
---|---|
+ APIError
+ |
+
+
+
+ If the API responds with anything other than HTTP status 200, then the CRIPT Python SDK raises |
+
Returns:
+Type | +Description | +
---|---|
+ None
+ |
+
+
+
+
+ |
+
src/cript/api/api.py
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 |
|
disconnect()
+
+¶Disconnect this API from the active access point.
+It is not necessary to call this function manually if a context manager is used.
+A context manager is preferred where possible.
+Jupyter notebooks are a use case where this connection can be handled manually.
+This function has to be called manually if the API.connect
function has to be called before.
For manual connection: nested API object are discouraged.
+ +src/cript/api/api.py
download_file(file_source, destination_path='.')
+
+¶Download a file from CRIPT Cloud Storage (AWS S3) and save it to the specified path.
+If the object_name
does not starts with http
then the program assumes the file is in AWS S3 storage,
+and attempts to retrieve it via
+boto3 client.
If the object_name
starts with http
then the program knows that
+it is a file stored on the web. The program makes a simple
+GET request to get the file,
+then writes the contents of it to the specified destination.
++Note: The current version of the program is designed to download files from the web in a straightforward +manner. However, please be aware that the program may encounter limitations when dealing with URLs that +require JavaScript or a session to be enabled. In such cases, the download method may fail.
+We acknowledge these limitations and plan to enhance the method in future versions to ensure compatibility +with a wider range of web file URLs. Our goal is to develop a robust solution capable of handling any and +all web file URLs.
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
file_source |
+
+ str
+ |
+
+
+
+
+
|
+ + required + | +
destination_path |
+
+ str
+ |
+
+
+
+ please provide a path with file name of where you would like the file to be saved +on local storage. +++ |
+
+ '.'
+ |
+
Examples:
+>>> from pathlib import Path
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... desktop_path = (Path(__file__).parent / "cript_downloads" / "my_downloaded_file.txt").resolve()
+... my_file = cript.File(
+... name="my file node name",
+... source="https://criptapp.org",
+... type="calibration",
+... extension=".csv",
+... )
+... api.download_file(file_source=my_file.source, destination_path=str(desktop_path))
+
Raises:
+Type | +Description | +
---|---|
+ FileNotFoundError
+ |
+
+
+
+ In case the file could not be found because the file does not exist or the path given is incorrect + |
+
Returns:
+Type | +Description | +
---|---|
+ None
+ |
+
+
+
+ Simply downloads the file + |
+
src/cript/api/api.py
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 |
|
get_vocab_by_category(category)
+
+¶get the CRIPT controlled vocabulary by category
+ + + +Examples:
+>>> import os
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... api.get_vocab_by_category(cript.VocabCategories.MATERIAL_IDENTIFIER_KEY)
+
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
category |
+
+ VocabCategories
+ |
+
+
+
+ category of + |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ List[dict]
+ |
+
+
+
+ list of JSON containing the controlled vocabulary + |
+
src/cript/api/api.py
save(project)
+
+¶This method takes a project node, serializes the class into JSON +and then sends the JSON to be saved to the API. +It takes Project node because everything is connected to the Project node, +and it can be used to send either a POST or PATCH request to API
+ + + +Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
project |
+
+ Project
+ |
+
+
+
+ the Project Node that the user wants to save + |
+ + required + | +
Raises:
+Type | +Description | +
---|---|
+ CRIPTAPISaveError
+ |
+
+
+
+ If the API responds with anything other than an HTTP of |
+
Returns:
+Type | +Description | +
---|---|
+ A set of extra saved node UUIDs.
+ |
+
+
+
+ Just sends a |
+
src/cript/api/api.py
search(node_type, search_mode, value_to_search)
+
+¶This method is used to perform search on the CRIPT platform.
+Essentially creates needed resources and passes it to paginator to get results from API +and display them.
+ + + +Examples:
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
node_type |
+
+ UUIDBaseNode
+ |
+
+
+
+ Type of node that you are searching for. + |
+ + required + | +
search_mode |
+
+ SearchModes
+ |
+
+
+
+ Type of search you want to do. You can search by name, |
+ + required + | +
value_to_search |
+
+ Optional[str]
+ |
+
+
+
+ What you are searching for can be either a value, and if you are only searching for
+a |
+ + required + | +
Returns:
+Type | +Description | +
---|---|
+ Paginator
+ |
+
+
+
+ paginator object for the user to use to flip through pages of search results + |
+
To learn more about working with pagination, please refer to our +paginator object documentation.
+Additionally, you can utilize the utility function
+load_nodes_from_json(node_json)
+to convert API JSON responses into Python SDK nodes.
# Get updated project from API
+my_paginator = api.search(
+ node_type=cript.Project,
+ search_mode=cript.SearchModes.EXACT_NAME,
+ value_to_search="my project name",
+)
+
+# Take specific Project you want from paginator
+my_project_from_api_dict: dict = my_paginator.current_page_results[0]
+
+# Deserialize your Project dict into a Project node
+my_project_node_from_api = cript.load_nodes_from_json(
+ nodes_json=json.dumps(my_project_from_api_dict)
+)
+
src/cript/api/api.py
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 |
|
upload_file(file_path)
+
+¶uploads a file to AWS S3 bucket and returns a URL of the uploaded file in AWS S3 +The URL is has no expiration time limit and is available forever
+original_name_uuid4.extension
document_42926a201a624fdba0fd6271defc9e88.txt
Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
file_path |
+
+ Union[Path, str]
+ |
+
+
+
+ file path as str or Path object. Path Object is recommended + |
+ + required + | +
Examples:
+>>> from pathlib import Path
+>>> import cript
+>>> with cript.API(
+... host="https://api.criptapp.org/",
+... api_token=os.getenv("CRIPT_TOKEN"),
+... storage_token=os.getenv("CRIPT_STORAGE_TOKEN")
+... ) as api:
+... # programmatically create the absolute path of your file, so the program always works correctly
+... my_file_path = (Path(__file__) / Path('../upload_files/my_file.txt')).resolve()
+... my_file_cloud_storage_source = api.upload_file(file_path=my_file_path)
+
We recommend using a Path object for specifying a file path. +Using the Python pathlib library provides platform-agnostic approach +for filesystem operations, ensuring seamless functionality across different operating systems. +Additionally, Path objects offer various built-in methods +for more sophisticated and secure file handling and has a easy to use interface that can make working with it a breeze +and can help reduce errors.
+Other options include using a raw string for relative/absolute file path, +or using the os.path module.
+ + + +Raises:
+Type | +Description | +
---|---|
+ FileNotFoundError
+ |
+
+
+
+ In case the CRIPT Python SDK cannot find the file on your computer because the file does not exist +or the path to it is incorrect it raises +FileNotFoundError + |
+
Returns:
+Name | Type | +Description | +
---|---|---|
object_name |
+ str
+ |
+
+
+
+ object_name of the AWS S3 uploaded file to be put into the File node source attribute + |
+
src/cript/api/api.py
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 |
|
+ Bases: Enum
All available CRIPT controlled vocabulary categories
+Controlled vocabulary categories are used to classify data.
+ + + +Attributes:
+Name | +Type | +Description | +
---|---|---|
ALGORITHM_KEY |
+
+ str
+ |
+
+
+
+ Algorithm key. + |
+
ALGORITHM_TYPE |
+
+ str
+ |
+
+
+
+ Algorithm type. + |
+
BUILDING_BLOCK |
+
+ str
+ |
+
+
+
+ Building block. + |
+
CITATION_TYPE |
+
+ str
+ |
+
+
+
+ Citation type. + |
+
COMPUTATION_TYPE |
+
+ str
+ |
+
+
+
+ Computation type. + |
+
COMPUTATIONAL_FORCEFIELD_KEY |
+
+ str
+ |
+
+
+
+ Computational forcefield key. + |
+
COMPUTATIONAL_PROCESS_PROPERTY_KEY |
+
+ str
+ |
+
+
+
+ Computational process property key. + |
+
COMPUTATIONAL_PROCESS_TYPE |
+
+ str
+ |
+
+
+
+ Computational process type. + |
+
CONDITION_KEY |
+
+ str
+ |
+
+
+
+ Condition key. + |
+
DATA_LICENSE |
+
+ str
+ |
+
+
+
+ Data license. + |
+
DATA_TYPE |
+
+ str
+ |
+
+
+
+ Data type. + |
+
EQUIPMENT_KEY |
+
+ str
+ |
+
+
+
+ Equipment key. + |
+
FILE_TYPE |
+
+ str
+ |
+
+
+
+ File type. + |
+
INGREDIENT_KEYWORD |
+
+ str
+ |
+
+
+
+ Ingredient keyword. + |
+
MATERIAL_IDENTIFIER_KEY |
+
+ str
+ |
+
+
+
+ Material identifier key. + |
+
MATERIAL_KEYWORD |
+
+ str
+ |
+
+
+
+ Material keyword. + |
+
MATERIAL_PROPERTY_KEY |
+
+ str
+ |
+
+
+
+ Material property key. + |
+
PARAMETER_KEY |
+
+ str
+ |
+
+
+
+ Parameter key. + |
+
PROCESS_KEYWORD |
+
+ str
+ |
+
+
+
+ Process keyword. + |
+
PROCESS_PROPERTY_KEY |
+
+ str
+ |
+
+
+
+ Process property key. + |
+
PROCESS_TYPE |
+
+ str
+ |
+
+
+
+ Process type. + |
+
PROPERTY_METHOD |
+
+ str
+ |
+
+
+
+ Property method. + |
+
QUANTITY_KEY |
+
+ str
+ |
+
+
+
+ Quantity key. + |
+
REFERENCE_TYPE |
+
+ str
+ |
+
+
+
+ Reference type. + |
+
SET_TYPE |
+
+ str
+ |
+
+
+
+ Set type. + |
+
UNCERTAINTY_TYPE |
+
+ str
+ |
+
+
+
+ Uncertainty type. + |
+
Examples:
+>>> import cript
+>>> algorithm_vocabulary = api.get_vocab_by_category(
+... cript.VocabCategories.ALGORITHM_KEY
+... )
+
src/cript/api/vocabulary_categories.py
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 |
|
Paginator
+
+
+¶Paginator is used to flip through different pages of data that the API returns when searching.
+++Instead of the user manipulating the URL and parameters, this object handles all of that for them.
+
When conducting any kind of search the API returns pages of data and each page contains 10 results. +This is equivalent to conducting a Google search when Google returns a limited number of links on the first page +and all other results are on the next pages.
+Using the Paginator object, the user can simply and easily flip through the pages of data the API provides.
+Do not create paginator objects
+Please note that you are not required or advised to create a paginator object, and instead the +Python SDK API object will create a paginator for you, return it, and let you simply use it
+Attributes:
+Name | +Type | +Description | +
---|---|---|
current_page_results |
+
+ List[dict]
+ |
+ + + | +
src/cript/api/paginator.py
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 |
|
current_page_number: int
+
+
+ property
+ writable
+
+
+¶get the current page number that you are on.
+Setting the page will take you to that specific page of results
+ + + +Examples:
+ + + + +Returns:
+Type | +Description | +
---|---|
+ current page number: int
+ |
+
+
+
+ the current page number of the data + |
+
__init__(http_headers, api_endpoint, query=None, current_page_number=0)
+
+¶create a paginator
+Parameters:
+Name | +Type | +Description | +Default | +
---|---|---|---|
http_headers |
+
+ dict
+ |
+
+
+
+ get already created http headers from API and just use them in paginator + |
+ + required + | +
api_endpoint |
+
+ str
+ |
+
+
+
+ api endpoint to send the search requests to +it already contains what node the user is looking for + |
+ + required + | +
current_page_number |
+
+ int
+ |
+
+
+
+ page number to start from. Keep track of current page for user to flip back and forth between pages of data + |
+
+ 0
+ |
+
query |
+
+ Optional[str]
+ |
+
+
+
+ the value the user is searching for + |
+
+ None
+ |
+
Returns:
+Type | +Description | +
---|---|
+ None
+ |
+
+
+
+ instantiate a paginator + |
+
src/cript/api/paginator.py
fetch_page_from_api()
+
+¶Raises:
+Type | +Description | +
---|---|
+ InvalidSearchRequest
+ |
+
+
+
+ In case the API responds with an error + |
+
Returns:
+Type | +Description | +
---|---|
+ current page results: List[dict]
+ |
+
+
+
+ makes a request to the API and gets a page of data + |
+
src/cript/api/paginator.py
next_page()
+
+¶flip to the next page of data.
+ + + +Examples:
+ + + +previous_page()
+
+¶flip to the next page of data.
+ + + +Examples:
+ + + +
+ Bases: Enum
Available search modes to use with the CRIPT API search
+ + + +Attributes:
+Name | +Type | +Description | +
---|---|---|
NODE_TYPE |
+
+ str
+ |
+
+
+
+ Search by node type. + |
+
EXACT_NAME |
+
+ str
+ |
+
+
+
+ Search by exact node name. + |
+
CONTAINS_NAME |
+
+ str
+ |
+
+
+
+ Search by node name containing a given string. + |
+
UUID |
+
+ str
+ |
+
+
+
+ Search by node UUID. + |
+
BIGSMILES |
+
+ str
+ |
+
+
+
+ search materials by bigsmiles identifier. + |
+
Examples:
+>>> import cript
+>>> # search by node type
+>>> materials_paginator = api.search(
+... node_type=cript.Material,
+... search_mode=cript.SearchModes.NODE_TYPE,
+... value_to_search=None,
+... )
+
For more details and code examples, +please check the cript.API.search( ) method
+ +src/cript/api/valid_search_modes.py
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Ha=/["'&<>]/;Un.exports=$a;function $a(e){var t=""+e,r=Ha.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i