How to use get_default method in autotest

Best Python code snippet using autotest_python

SyncRules.py

Source:SyncRules.py Github

copy

Full Screen

...13 * @return list14 '''15 def describeSyncRulesObjInfo(self, body):16 17 url = '{0}/active/rule/sync_obj_info'.format(config.get_default('default_api_host'))18 19 res = https._post(url, body, self.auth)20 return res2122 '''23 * 增量失败DML统计24 * 25 * @param dict $body 参数详见 API 手册26 * @return list27 '''28 def describeSyncRulesDML(self, body):29 30 url = '{0}/active/rule/incre_dml_summary'.format(config.get_default('default_api_host'))31 32 res = https._post(url, body, self.auth)33 return res3435 '''36 * 新建-准备-获取代理状态37 * 38 * @return list39 '''40 def describeSyncRulesProxyStatus(self, body):41 42 url = '{0}/active/rule/proxy_status'.format(config.get_default('default_api_host'))43 44 res = https._get(url, None, self.auth)45 return res4647 '''48 * 新建49 * 50 * @param dict $body 参数详见 API 手册51 * @return list52 '''53 def createSyncRules(self, body):54 55 url = '{0}/active/rule'.format(config.get_default('default_api_host'))56 57 res = https._post(url, body, self.auth)58 return res5960 '''61 * 修改62 * 63 * @param dict $body 参数详见 API 手册64 * @return list65 '''66 def modifySyncRules(self, body):67 68 url = '{0}/active/rule'.format(config.get_default('default_api_host'))69 70 res = https._put(url, body, self.auth)71 return res7273 '''74 * 已同步的对象75 * 76 * @param dict $body 参数详见 API 手册77 * @return list78 '''79 def describeSyncRulesHasSync(self, body):80 81 url = '{0}/active/rule/sync_obj'.format(config.get_default('default_api_host'))82 83 res = https._post(url, body, self.auth)84 return res8586 '''87 * 失败的对象88 * 89 * @param dict $body 参数详见 API 手册90 * @return list91 '''92 def describeSyncRulesFailObj(self, body):93 94 url = '{0}/active/rule/fail_obj'.format(config.get_default('default_api_host'))95 96 res = https._post(url, body, self.auth)97 return res9899 '''100 * 装载信息流量图101 * 102 * @param dict $body 参数详见 API 手册103 * @return list104 '''105 def describeSyncRulesLoadInfo(self, body):106 107 url = '{0}/active/rule/load_info'.format(config.get_default('default_api_host'))108 109 res = https._post(url, body, self.auth)110 return res111112 '''113 * 删除114 * 115 * @param dict $body 参数详见 API 手册116 * @return list117 '''118 def deleteSyncRules(self, body):119 120 url = '{0}/active/rule'.format(config.get_default('default_api_host'))121 122 res = https._delete(url, body, self.auth)123 return res124125 '''126 * 列表127 * 128 * @param dict $body 参数详见 API 手册129 * @return list130 '''131 def listSyncRules(self, body):132 133 url = '{0}/active/rule'.format(config.get_default('default_api_host'))134 135 res = https._get(url, body, self.auth)136 return res137138 '''139 * 操作同步规则140 * 141 * @param dict $body 参数详见 API 手册142 * @return list143 '''144 def operateSyncRules(self, body):145 146 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))147 148 res = https._post(url, body, self.auth)149 return res150151 '''152 * 状态153 * 154 * @param dict $body 参数详见 API 手册155 * @return list156 '''157 def listSyncRulesStatus(self, body):158 159 url = '{0}/active/rule/status'.format(config.get_default('default_api_host'))160 161 res = https._get(url, body, self.auth)162 return res163164 '''165 * 流量图166 * 167 * @param dict $body 参数详见 API 手册168 * @return list169 '''170 def describeSyncRulesMrtg(self, body):171 172 url = '{0}/active/rule/mrtg'.format(config.get_default('default_api_host'))173 174 res = https._post(url, body, self.auth)175 return res176177 '''178 * 增量失败ddl179 * 180 * @param dict $body 参数详见 API 手册181 * @return list182 '''183 def describeSyncRulesIncreDdl(self, body):184 185 url = '{0}/active/rule/incre_ddl'.format(config.get_default('default_api_host'))186 187 res = https._post(url, body, self.auth)188 return res189190 '''191 * 获取单个192 * 193 * @body['uuid'] String 必填 节点uuid194 * @param dict $body 参数详见 API 手册195 * @return list196 '''197 def describeSyncRules(self, body, uuid):198 if uuid is None:199 exit()200 url = '{0}/active/rule/{1}'.format(config.get_default('default_api_host'), uuid)201 202 res = https._get(url, body, self.auth)203 return res204205 '''206 * 列表207 * 208 * @param dict $body 参数详见 API 手册209 * @return list210 '''211 def listObjCmp(self, body):212 213 url = '{0}/active/obj_cmp'.format(config.get_default('default_api_host'))214 215 res = https._get(url, body, self.auth)216 return res217218 '''219 * 新建220 * 221 * @param dict $body 参数详见 API 手册222 * @return list223 '''224 def createObjCmp(self, body):225 226 url = '{0}/active/obj_cmp'.format(config.get_default('default_api_host'))227 228 res = https._post(url, body, self.auth)229 return res230231 '''232 * 删除233 * 234 * @param dict $body 参数详见 API 手册235 * @return list236 '''237 def deleteObjCmp(self, body):238 239 url = '{0}/active/obj_cmp'.format(config.get_default('default_api_host'))240 241 res = https._delete(url, body, self.auth)242 return res243244 '''245 * 获取单个246 * 247 * @body['uuid'] String 必填 节点uuid248 * @return list249 '''250 def describeObjCmp(self, body, uuid):251 if uuid is None:252 exit()253 url = '{0}/active/obj_cmp/{1}'.format(config.get_default('default_api_host'), uuid)254 255 res = https._get(url, None, self.auth)256 return res257258 '''259 * 比较结果时间列表260 * 261 * @param dict $body 参数详见 API 手册262 * @return list263 '''264 def listObjCmpResultTimeList(self, body):265 266 url = '{0}/active/obj_cmp/result_time_list'.format(config.get_default('default_api_host'))267 268 res = https._get(url, body, self.auth)269 return res270271 '''272 * 比较任务结果273 * 274 * @param dict $body 参数详见 API 手册275 * @return list276 '''277 def describeObjCmpResult(self, body):278 279 url = '{0}/active/obj_cmp/result'.format(config.get_default('default_api_host'))280 281 res = https._get(url, body, self.auth)282 return res283284 '''285 * 获取对象比较状态286 * 287 * @param dict $body 参数详见 API 手册288 * @return list289 '''290 def listObjCmpStatus(self, body):291 292 url = '{0}/active/obj_cmp/status'.format(config.get_default('default_api_host'))293 294 res = https._post(url, body, self.auth)295 return res296297 '''298 * 比较结果的删除299 * 300 * @param dict $body 参数详见 API 手册301 * @return list302 '''303 def describeObjCmpResultTimeList(self, body):304 305 url = '{0}/active/obj_cmp/result_time_list'.format(config.get_default('default_api_host'))306 307 res = https._delete(url, body, self.auth)308 return res309310 '''311 * 比较结果详细信息312 * 313 * @param dict $body 参数详见 API 手册314 * @return list315 '''316 def listObjCmpCmpInfo(self, body):317 318 url = '{0}/active/obj_cmp/cmp_info'.format(config.get_default('default_api_host'))319 320 res = https._get(url, body, self.auth)321 return res322323 '''324 * 新建325 * 326 * @param dict $body 参数详见 API 手册327 * @return list328 '''329 def createObjFix(self, body):330 331 url = '{0}/active/obj_fix'.format(config.get_default('default_api_host'))332 333 res = https._post(url, body, self.auth)334 return res335336 '''337 * 获取单个338 * 339 * @body['uuid'] String 必填 节点uuid340 * @param dict $body 参数详见 API 手册341 * @return list342 '''343 def describeObjFix(self, body, uuid):344 if uuid is None:345 exit()346 url = '{0}/active/obj_fix/{1}'.format(config.get_default('default_api_host'), uuid)347 348 res = https._get(url, body, self.auth)349 return res350351 '''352 * 删除353 * 354 * @param dict $body 参数详见 API 手册355 * @return list356 '''357 def deleteObjFix(self, body):358 359 url = '{0}/active/obj_fix'.format(config.get_default('default_api_host'))360 361 res = https._delete(url, body, self.auth)362 return res363364 '''365 * 列表366 * 367 * @param dict $body 参数详见 API 手册368 * @return list369 '''370 def listObjFix(self, body):371 372 url = '{0}/active/obj_fix'.format(config.get_default('default_api_host'))373 374 res = https._get(url, body, self.auth)375 return res376377 '''378 * 对象修复-操作379 * 380 * @param dict $body 参数详见 API 手册381 * @return list382 '''383 def operateObjFix(self, body):384 385 url = '{0}/active/obj_fix/operate'.format(config.get_default('default_api_host'))386 387 res = https._post(url, body, self.auth)388 return res389390 '''391 * 修复结果392 * 393 * @param dict $body 参数详见 API 手册394 * @return list395 '''396 def describeObjFixResult(self, body):397 398 url = '{0}/active/obj_fix/result'.format(config.get_default('default_api_host'))399 400 res = https._get(url, body, self.auth)401 return res402403 '''404 * -获取状态405 * 406 * @param dict $body 参数详见 API 手册407 * @return list408 '''409 def listObjFixStatus(self, body):410 411 url = '{0}/active/obj_fix/status'.format(config.get_default('default_api_host'))412 413 res = https._post(url, body, self.auth)414 return res415416 '''417 * 新建418 * 419 * @param dict $body 参数详见 API 手册420 * @return list421 '''422 def createTbCmp(self, body):423 424 url = '{0}/active/tb_cmp'.format(config.get_default('default_api_host'))425 426 res = https._post(url, body, self.auth)427 return res428429 '''430 * 获取单个431 * 432 * @body['uuid'] String 必填 节点uuid433 * @param dict $body 参数详见 API 手册434 * @return list435 '''436 def describeTbCmp(self, body, uuid):437 if uuid is None:438 exit()439 url = '{0}/active/tb_cmp/{1}'.format(config.get_default('default_api_host'), uuid)440 441 res = https._get(url, body, self.auth)442 return res443444 '''445 * 删除446 * 447 * @param dict $body 参数详见 API 手册448 * @return list449 '''450 def deleteTbCmp(self, body):451 452 url = '{0}/active/tb_cmp'.format(config.get_default('default_api_host'))453 454 res = https._delete(url, body, self.auth)455 return res456457 '''458 * 列表459 * 460 * @param dict $body 参数详见 API 手册461 * @return list462 '''463 def listTbCmp(self, body):464 465 url = '{0}/active/tb_cmp'.format(config.get_default('default_api_host'))466 467 res = https._get(url, body, self.auth)468 return res469470 '''471 * 状态接口472 * 473 * @param dict $body 参数详见 API 手册474 * @return list475 '''476 def listTbCmpStatus(self, body):477 478 url = '{0}/active/tb_cmp/status'.format(config.get_default('default_api_host'))479 480 res = https._get(url, body, self.auth)481 return res482483 '''484 * 历史结果(查看表比较时间结果集)485 * 486 * @param dict $body 参数详见 API 手册487 * @return list488 '''489 def listTbCmpResultTimeList(self, body):490 491 url = '{0}/active/tb_cmp/result_time_list'.format(config.get_default('default_api_host'))492 493 res = https._get(url, body, self.auth)494 return res495496 '''497 * 表比较-操作498 * 499 * @param dict $body 参数详见 API 手册500 * @return list501 '''502 def operateTbCmp(self, body):503 504 url = '{0}/active/tb_cmp/operate'.format(config.get_default('default_api_host'))505 506 res = https._post(url, body, self.auth)507 return res508509 '''510 * 比较结果的删除511 * 512 * @param dict $body 参数详见 API 手册513 * @return list514 '''515 def describeTbCmpResuluTimeList(self, body):516 517 url = '{0}/active/tb_cmp/result_time_list'.format(config.get_default('default_api_host'))518 519 res = https._delete(url, body, self.auth)520 return res521522 '''523 * 比较任务结果524 * 525 * @param dict $body 参数详见 API 手册526 * @return list527 '''528 def describeTbCmpResult(self, body):529 530 url = '{0}/active/tb_cmp/result'.format(config.get_default('default_api_host'))531 532 res = https._get(url, body, self.auth)533 return res534535 '''536 * 错误信息537 * 538 * @param dict $body 参数详见 API 手册539 * @return list540 '''541 def describeTbCmpErrorMsg(self, body):542 543 url = '{0}/active/tb_cmp/error_msg'.format(config.get_default('default_api_host'))544 545 res = https._get(url, body, self.auth)546 return res547548 '''549 * 比较结果550 * 551 * @param dict $body 参数详见 API 手册552 * @return list553 '''554 def describeTbCmpCmpResult(self, body):555 556 url = '{0}/active/tb_cmp/cmp_result'.format(config.get_default('default_api_host'))557 558 res = https._get(url, body, self.auth)559 return res560561 '''562 * 新建563 * 564 * @param dict $body 参数详见 API 手册565 * @return list566 '''567 def createBkTakeover(self, body):568 569 url = '{0}/active/bk_takeover'.format(config.get_default('default_api_host'))570 571 res = https._post(url, body, self.auth)572 return res573574 '''575 * 查看576 * 577 * @body['uuid'] String 必填 节点uuid578 * @return list579 '''580 def describeBkTakeover(self, body, uuid):581 if uuid is None:582 exit()583 url = '{0}/active/bk_takeover/{1}'.format(config.get_default('default_api_host'), uuid)584 585 res = https._get(url, None, self.auth)586 return res587588 '''589 * 删除590 * 591 * @param dict $body 参数详见 API 手册592 * @return list593 '''594 def deleteBkTakeover(self, body):595 596 url = '{0}/active/bk_takeover'.format(config.get_default('default_api_host'))597 598 res = https._delete(url, body, self.auth)599 return res600601 '''602 * 接管结果603 * 604 * @param dict $body 参数详见 API 手册605 * @return list606 '''607 def describeBkTakeoverResult(self, body):608 609 url = '{0}/active/bk_takeover/result'.format(config.get_default('default_api_host'))610 611 res = https._get(url, body, self.auth)612 return res613614 '''615 * 备机接管-操作616 * 617 * @param dict $body 参数详见 API 手册618 * @return list619 '''620 def operateBkTakeover(self, body):621 622 url = '{0}/active/bk_takeover/operate'.format(config.get_default('default_api_host'))623 624 res = https._post(url, body, self.auth)625 return res626627 '''628 * 获取状态629 * 630 * @param dict $body 参数详见 API 手册631 * @return list632 '''633 def listBkTakeoverStatus(self, body):634 635 url = '{0}/active/bk_takeover/status'.format(config.get_default('default_api_host'))636 637 res = https._post(url, body, self.auth)638 return res639640 '''641 * 备端接管列表642 * 643 * @return list644 '''645 def listBkTakeover(self, ):646 647 url = '{0}/active/bk_takeover'.format(config.get_default('default_api_host'))648 649 res = https._get(url, None, self.auth)650 return res651652 '''653 * 新建654 * 655 * @param dict $body 参数详见 API 手册656 * @return list657 '''658 def createReverse(self, body):659 660 url = '{0}/active/reverse'.format(config.get_default('default_api_host'))661 662 res = https._post(url, body, self.auth)663 return res664665 '''666 * 删除667 * 668 * @param dict $body 参数详见 API 手册669 * @return list670 '''671 def deleteReverse(self, body):672 673 url = '{0}/active/reverse'.format(config.get_default('default_api_host'))674 675 res = https._delete(url, body, self.auth)676 return res677678 '''679 * 获取单个规则信息680 * 681 * @param dict $body 参数详见 API 手册682 * @return list683 '''684 def describeReverse(self, body):685 686 url = '{0}/active/reverse/rule_single'.format(config.get_default('default_api_host'))687 688 res = https._get(url, body, self.auth)689 return res690691 '''692 * 获取列表693 * 694 * @param dict $body 参数详见 API 手册695 * @return list696 '''697 def listReverse(self, body):698 699 url = '{0}/active/reverse'.format(config.get_default('default_api_host'))700 701 res = https._get(url, body, self.auth)702 return res703704 '''705 * 状态706 * 707 * @param dict $body 参数详见 API 手册708 * @return list709 '''710 def listReverseStatus(self, body):711 712 url = '{0}/active/reverse/status'.format(config.get_default('default_api_host'))713 714 res = https._get(url, body, self.auth)715 return res716717 '''718 * 停止719 * 720 * @param dict $body 参数详见 API 手册721 * @return list722 '''723 def stopReverse(self, body):724 725 url = '{0}/active/reverse/stop'.format(config.get_default('default_api_host'))726 727 res = https._post(url, body, self.auth)728 return res729730 '''731 * 重启反向任务732 * 733 * @param dict $body 参数详见 API 手册734 * @return list735 '''736 def restartReverse(self, body):737 738 url = '{0}/active/reverse/restart'.format(config.get_default('default_api_host'))739 740 res = https._post(url, body, self.auth)741 return res742743 '''744 * 查看745 * 746 * @param dict $body 参数详见 API 手册747 * @return list748 '''749 def describeSingleReverse(self, body):750 751 url = '{0}/active/reverse'.format(config.get_default('default_api_host'))752 753 res = https._put(url, body, self.auth)754 return res755756 '''757 * 选择用户758 * 759 * @param dict $body 参数详见 API 手册760 * @return list761 '''762 def describeRuleSelectUser(self, body):763 764 url = '{0}/active/rule/select_user'.format(config.get_default('default_api_host'))765 766 res = https._post(url, body, self.auth)767 return res768769 '''770 * 获取数据库表字段771 * 772 * @param dict $body 参数详见 API 手册773 * @return list774 '''775 def describeRuleZStructure(self, body):776 777 url = '{0}/active/rule/z_structure'.format(config.get_default('default_api_host'))778 779 res = https._post(url, body, self.auth)780 return res781782 '''783 * 日志784 * 785 * @param dict $body 参数详见 API 手册786 * @return list787 '''788 def listRuleLog(self, body):789 790 url = '{0}/active/rule/log'.format(config.get_default('default_api_host'))791 792 res = https._post(url, body, self.auth)793 return res794795 '''796 * 表修复797 * 798 * @param dict $body 参数详见 API 手册799 * @return list800 '''801 def describeRuleTableFix(self, body):802 803 url = '{0}/active/rule/table_fix'.format(config.get_default('default_api_host'))804 805 res = https._post(url, body, self.auth)806 return res807808 '''809 * 已同步表810 * 811 * @param dict $body 参数详见 API 手册812 * @return list813 '''814 def listRuleSyncTable(self, body):815 816 url = '{0}/active/rule/sync_table'.format(config.get_default('default_api_host'))817 818 res = https._post(url, body, self.auth)819 return res820821 '''822 * 增量失败dml823 * 824 * @param dict $body 参数详见 API 手册825 * @return list826 '''827 def listRuleIncreDml(self, body):828 829 url = '{0}/active/rule/incre_dml'.format(config.get_default('default_api_host'))830 831 res = https._post(url, body, self.auth)832 return res833834 '''835 * 获取残留规则836 * 837 * @return list838 '''839 def describeRuleGetFalseRule(self, body):840 841 url = '{0}/active/rule/get_false_rule'.format(config.get_default('default_api_host'))842 843 res = https._get(url, None, self.auth)844 return res845846 '''847 * 获取scn号848 * 849 * @param dict $body 参数详见 API 手册850 * @return list851 '''852 def describeRuleGetScn(self, body):853 854 url = '{0}/active/rule/get_scn'.format(config.get_default('default_api_host'))855 856 res = https._get(url, body, self.auth)857 return res858859 '''860 * 装载统计报表861 * 862 * @param dict $body 参数详见 API 手册863 * @return list864 '''865 def listRuleLoadReport(self, body):866 867 url = '{0}/active/rule/load_report'.format(config.get_default('default_api_host'))868 869 res = https._post(url, body, self.auth)870 return res871872 '''873 * 装载延迟统计报表874 * 875 * @param dict $body 参数详见 API 手册876 * @return list877 '''878 def listRuleLoadDelayReport(self, body):879 880 url = '{0}/active/rule/load_delay_report'.format(config.get_default('default_api_host'))881 882 res = https._post(url, body, self.auth)883 return res884885 '''886 * 数据库预检887 * 888 * @param dict $body 参数详见 API 手册889 * @return list890 '''891 def describeRuleDbCheck(self, body):892 893 url = '{0}/active/rule/db_check'.format(config.get_default('default_api_host'))894 895 res = https._post(url, body, self.auth)896 return res897898 '''899 * 同步规则 - 操作 继续900 * 901 * @param dict $body 参数详见 API 手册902 * @return list903 '''904 def resumeSyncRules(self, body):905906 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))907908 res = https._post(url, body, self.auth)909 return res910911 '''912 * 同步规则 - 操作 停止913 * 914 * @param dict $body 参数详见 API 手册915 * @return list916 '''917 def stopSyncRules(self, body):918919 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))920921 res = https._post(url, body, self.auth)922 return res923924 '''925 * 同步规则 - 操作 重启926 * 927 * @param dict $body 参数详见 API 手册928 * @return list929 '''930 def restartSyncRules(self, body):931932 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))933934 res = https._post(url, body, self.auth)935 return res936937 '''938 * 同步规则 - 操作 开始日志解析939 * 940 * @param dict $body 参数详见 API 手册941 * @return list942 '''943 def startAnalysisSyncRules(self, body):944945 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))946947 res = https._post(url, body, self.auth)948 return res949950 '''951 * 同步规则 - 操作 停止日志解析952 * 953 * @param dict $body 参数详见 API 手册954 * @return list955 '''956 def stopAnalysisSyncRules(self, body):957958 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))959960 res = https._post(url, body, self.auth)961 return res962963 '''964 * 同步规则 - 操作 重新日志解析965 * 966 * @param dict $body 参数详见 API 手册967 * @return list968 '''969 def resetAnalysisSyncRules(self, body):970971 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))972973 res = https._post(url, body, self.auth)974 return res975976 '''977 * 同步规则 - 停止规则并停止日志解析978 * 979 * @param dict $body 参数详见 API 手册980 * @return list981 '''982 def stopAndStopanalysisSyncRules(self, body):983984 url = '{0}/active/rule/operate'.format(config.get_default('default_api_host'))985986 res = https._post(url, body, self.auth)987 return res988989 '''990 * 对象修复-操作 重启991 * 992 * @param dict $body 参数详见 API 手册993 * @return list994 '''995 def restartObjFix(self, body):996997 url = '{0}/active/obj_fix/operate'.format(config.get_default('default_api_host'))998999 res = https._post(url, body, self.auth)1000 return res10011002 '''1003 * 对象修复-操作 停止1004 * 1005 * @param dict $body 参数详见 API 手册1006 * @return list1007 '''1008 def stopObjFix(self, body):10091010 url = '{0}/active/obj_fix/operate'.format(config.get_default('default_api_host'))10111012 res = https._post(url, body, self.auth)1013 return res10141015 '''1016 * 表比较-操作 停止1017 * 1018 * @param dict $body 参数详见 API 手册1019 * @return list1020 '''1021 def stopTbCmp(self, body):10221023 url = '{0}/active/tb_cmp/operate'.format(config.get_default('default_api_host'))10241025 res = https._post(url, body, self.auth)1026 return res10271028 '''1029 * 表比较-操作 重启1030 * 1031 * @param dict $body 参数详见 API 手册1032 * @return list1033 '''1034 def restartTbCmp(self, body):10351036 url = '{0}/active/tb_cmp/operate'.format(config.get_default('default_api_host'))10371038 res = https._post(url, body, self.auth)1039 return res10401041 '''1042 * 备机接管-操作 停止1043 * 1044 * @param dict $body 参数详见 API 手册1045 * @return list1046 '''1047 def stopBkTakeover(self, body):10481049 url = '{0}/active/bk_takeover/operate'.format(config.get_default('default_api_host'))10501051 res = https._post(url, body, self.auth)1052 return res10531054 '''1055 * 备机接管-操作 重启1056 * 1057 * @param dict $body 参数详见 API 手册1058 * @return list1059 '''1060 def restartBkTakeover(self, body):10611062 url = '{0}/active/bk_takeover/operate'.format(config.get_default('default_api_host'))10631064 res = https._post(url, body, self.auth)1065 return res10661067 '''1068 * 日志下载1069 * 1070 * @param dict $body 参数详见 API 手册1071 * @return list1072 '''1073 def downloadLog(self, body):10741075 url = '{0}/active/rule/log_download'.format(config.get_default('default_api_host'))10761077 res = https._get(url, body, self.auth)1078 return res ...

Full Screen

Full Screen

Storage.py

Source:Storage.py Github

copy

Full Screen

...9 * @param dict $body 参数详见 API 手册10 * @return list11 '''12 def createStorageConfig(self, body):13 url = '{0}/storage'.format(config.get_default('default_api_host'))14 res = https._post(url, body, self.auth)15 return res16 '''17 * 修改18 * 19 * @body['uuid'] String 必填 节点uuid20 * @param dict $body 参数详见 API 手册21 * @return list22 '''23 def modifyStorageConfig(self, body):24 url = '{0}/storage/{1}'.format(config.get_default('default_api_host'), body['uuid'])25 del body['uuid']26 res = https._put(url, body, self.auth)27 return res28 '''29 * 获取单个30 * 31 * @body['uuid'] String 必填 节点uuid32 * @return list33 '''34 def describeStorageConfig(self, body):35 if body is None or 'uuid' not in body: exit()36 url = '{0}/storage/{1}'.format(config.get_default('default_api_host'), body['uuid'])37 res = https._get(url, None, self.auth)38 return res39 '''40 * 获取列表41 * 42 * @return list43 '''44 def listStorageConfig(self, ):45 url = '{0}/storage'.format(config.get_default('default_api_host'))46 res = https._get(url, None, self.auth)47 return res48 '''49 * 删除50 * 51 * @param dict $body 参数详见 API 手册52 * @return list53 '''54 def deleteStorageConfig(self, body):55 url = '{0}/storage'.format(config.get_default('default_api_host'))56 res = https._delete(url, body, self.auth)57 return res58 '''59 * 容量信息60 * 61 * @param dict $body 参数详见 API 手册62 * @return list63 '''64 def listStorageInfo(self, body):65 url = '{0}/ /storage/info'.format(config.get_default('default_api_host'))66 res = https._get(url, body, self.auth)67 return res68 '''69 * 获取可用节点列表70 * 71 * @return list72 '''73 def listAvailableNode(self, ):74 url = '{0}/storage/node'.format(config.get_default('default_api_host'))75 res = https._get(url, None, self.auth)76 return res77 '''78 * ---------------------79 * 80 * @return list81 '''82 '''83 * 获取列表84 * 85 * @param dict $body 参数详见 API 手册86 * @return list87 '''88 def listDevice(self, body):89 url = '{0}/storage/dev'.format(config.get_default('default_api_host'))90 res = https._get(url, body, self.auth)91 return res92 '''93 * 获取可用列表94 * 95 * @param dict $body 参数详见 API 手册96 * @return list97 '''98 def listAvailableDevice(self, body):99 url = '{0}/storage/available_dev'.format(config.get_default('default_api_host'))100 res = https._get(url, body, self.auth)101 return res102 '''103 * ---------------------104 * 105 * @return list106 '''107 '''108 * 创建109 * 110 * @param dict $body 参数详见 API 手册111 * @return list112 '''113 def createPool(self, body):114 url = '{0}/storage/pool'.format(config.get_default('default_api_host'))115 res = https._post(url, body, self.auth)116 return res117 '''118 * 扩展119 * 120 * @param dict $body 参数详见 API 手册121 * @return list122 '''123 def expandPool(self, body):124 url = '{0}/storage/pool'.format(config.get_default('default_api_host'))125 res = https._put(url, body, self.auth)126 return res127 '''128 * 删除129 * 130 * @param dict $body 参数详见 API 手册131 * @return list132 '''133 def deletePool(self, body):134 url = '{0}/storage/pool'.format(config.get_default('default_api_host'))135 res = https._delete(url, body, self.auth)136 return res137 '''138 * 获取139 * 140 * @param dict $body 参数详见 API 手册141 * @return list142 '''143 def listPool(self, body):144 url = '{0}/storage/pool'.format(config.get_default('default_api_host'))145 res = https._get(url, body, self.auth)146 return res147 '''148 * 获取信息149 * 150 * @param dict $body 参数详见 API 手册151 * @return list152 '''153 def listPoolInfo(self, body):154 url = '{0}/storage/pool/info'.format(config.get_default('default_api_host'))155 res = https._get(url, body, self.auth)156 return res157 '''158 * ---------------------159 * 160 * @return list161 '''162 '''163 * 创建164 * 165 * @param dict $body 参数详见 API 手册166 * @return list167 '''168 def createFs(self, body):169 url = '{0}/storage/file_system'.format(config.get_default('default_api_host'))170 res = https._post(url, body, self.auth)171 return res172 '''173 * 删除174 * 175 * @param dict $body 参数详见 API 手册176 * @return list177 '''178 def deleteFs(self, body):179 url = '{0}/storage/file_system'.format(config.get_default('default_api_host'))180 res = https._delete(url, body, self.auth)181 return res182 '''183 * 获取184 * 185 * @param dict $body 参数详见 API 手册186 * @return list187 '''188 def listFs(self, body):189 url = '{0}/storage/file_system'.format(config.get_default('default_api_host'))190 res = https._get(url, body, self.auth)191 return res192 '''193 * 创建194 * 195 * @param dict $body 参数详见 API 手册196 * @return list197 '''198 def createFsSnapshot(self, body):199 url = '{0}/storage/file_system/snap'.format(config.get_default('default_api_host'))200 res = https._post(url, body, self.auth)201 return res202 '''203 * 删除204 * 205 * @param dict $body 参数详见 API 手册206 * @return list207 '''208 def deleteFsSnapshot(self, body):209 url = '{0}/storage/file_system/snap'.format(config.get_default('default_api_host'))210 res = https._delete(url, body, self.auth)211 return res212 '''213 * 获取214 * 215 * @param dict $body 参数详见 API 手册216 * @return list217 '''218 def listFsSnapshot(self, body):219 url = '{0}/storage/file_system/snap'.format(config.get_default('default_api_host'))220 res = https._get(url, body, self.auth)221 return res222 '''223 * 创建224 * 225 * @param dict $body 参数详见 API 手册226 * @return list227 '''228 def createFsCloneSnapshot(self, body):229 url = '{0}/storage/file_system/snap/clone'.format(config.get_default('default_api_host'))230 res = https._post(url, body, self.auth)231 return res232 '''233 * 删除234 * 235 * @param dict $body 参数详见 API 手册236 * @return list237 '''238 def deleteFsCloneSnapshot(self, body):239 url = '{0}/storage/file_system/snap/clone'.format(config.get_default('default_api_host'))240 res = https._delete(url, body, self.auth)241 return res242 '''243 * 列表244 * 245 * @param dict $body 参数详见 API 手册246 * @return list247 '''248 def listFsCloneSnapshot(self, body):249 url = '{0}/storage/file_system/snap/clone'.format(config.get_default('default_api_host'))250 res = https._get(url, body, self.auth)251 return res252 '''253 * ---------------------254 * 255 * @return list256 '''257 '''258 * 创建259 * 260 * @param dict $body 参数详见 API 手册261 * @return list262 '''263 def createVolume(self, body):264 url = '{0}/storage/volume'.format(config.get_default('default_api_host'))265 res = https._post(url, body, self.auth)266 return res267 '''268 * 删除269 * 270 * @param dict $body 参数详见 API 手册271 * @return list272 '''273 def deleteVolume(self, body):274 url = '{0}/storage/volume'.format(config.get_default('default_api_host'))275 res = https._delete(url, body, self.auth)276 return res277 '''278 * 获取279 * 280 * @param dict $body 参数详见 API 手册281 * @return list282 '''283 def listVolume(self, body):284 url = '{0}/storage/volume'.format(config.get_default('default_api_host'))285 res = https._get(url, body, self.auth)286 return res287 '''288 * 创建289 * 290 * @param dict $body 参数详见 API 手册291 * @return list292 '''293 def createVolumeSnapshot(self, body):294 url = '{0}/storage/volume/snap'.format(config.get_default('default_api_host'))295 res = https._post(url, body, self.auth)296 return res297 '''298 * 删除299 * 300 * @param dict $body 参数详见 API 手册301 * @return list302 '''303 def deleteVolumeSnapshot(self, body):304 url = '{0}/storage/volume/snap'.format(config.get_default('default_api_host'))305 res = https._delete(url, body, self.auth)306 return res307 '''308 * 获取309 * 310 * @param dict $body 参数详见 API 手册311 * @return list312 '''313 def listVolumeSnapshot(self, body):314 url = '{0}/storage/volume/snap'.format(config.get_default('default_api_host'))315 res = https._get(url, body, self.auth)316 return res317 '''318 * 创建319 * 320 * @param dict $body 参数详见 API 手册321 * @return list322 '''323 def createVolumeCloneSnapshot(self, body):324 url = '{0}/storage/volume/snap/clone'.format(config.get_default('default_api_host'))325 res = https._post(url, body, self.auth)326 return res327 '''328 * 删除329 * 330 * @param dict $body 参数详见 API 手册331 * @return list332 '''333 def deleteVolumeCloneSnapshot(self, body):334 url = '{0}/storage/volume/snap/clone'.format(config.get_default('default_api_host'))335 res = https._delete(url, body, self.auth)336 return res337 '''338 * 列表339 * 340 * @param dict $body 参数详见 API 手册341 * @return list342 '''343 def listVolumeCloneSnapshot(self, body):344 url = '{0}/storage/volume/snap/clone'.format(config.get_default('default_api_host'))345 res = https._get(url, body, self.auth)346 return res347 '''348 * ---------------------349 * 350 * @return list351 '''352 '''353 * 创建354 * 355 * @return list356 '''357 def create(self, ):358 url = '{0}/storage/vmdk'.format(config.get_default('default_api_host'))359 res = https._post(url, None, self.auth)360 return res361 '''362 * 删除363 * 364 * @return list365 '''366 def delete(self, ):367 url = '{0}/storage/vmdk'.format(config.get_default('default_api_host'))368 res = https._delete(url, None, self.auth)369 return res370 '''371 * --------------------- 存储区域网络(SAN)管理372 * 373 * @return list374 '''375 '''376 * 创建377 * 378 * @param dict $body 参数详见 API 手册379 * @return list380 '''381 def createBackStore(self, body):382 url = '{0}/storage/backstore'.format(config.get_default('default_api_host'))383 res = https._post(url, body, self.auth)384 return res385 '''386 * 删除387 * 388 * @param dict $body 参数详见 API 手册389 * @return list390 '''391 def deleteBackStore(self, body):392 url = '{0}/storage/backstore'.format(config.get_default('default_api_host'))393 res = https._delete(url, body, self.auth)394 return res395 '''396 * 获取信息397 * 398 * @param dict $body 参数详见 API 手册399 * @return list400 '''401 def listBackStore(self, body):402 url = '{0}/storage/backstore/info'.format(config.get_default('default_api_host'))403 res = https._get(url, body, self.auth)404 return res405 '''406 * 分配给ISCSI发起者407 * 408 * @param dict $body 参数详见 API 手册409 * @return list410 '''411 def createAssignBackStore(self, body):412 url = '{0}/storage/backstore/assign'.format(config.get_default('default_api_host'))413 res = https._post(url, body, self.auth)414 return res415 '''416 * 查看被分配给哪些ISCSI发起者417 * 418 * @param dict $body 参数详见 API 手册419 * @return list420 '''421 def listAssignBackStore(self, body):422 url = '{0}/storage/backstore/assign'.format(config.get_default('default_api_host'))423 res = https._get(url, body, self.auth)424 return res425 '''426 * 获取可创建 块 的 盘 的 路径427 * 428 * @param dict $body 参数详见 API 手册429 * @return list430 '''431 def listBackStoreAvailablePath(self, body):432 url = '{0}/storage/backstore/available_path'.format(config.get_default('default_api_host'))433 res = https._get(url, body, self.auth)434 return res435 '''436 * 获取版本信息437 * 438 * @param dict $body 参数详见 API 手册439 * @return list440 '''441 def describeIscsiVersion(self, body):442 url = '{0}/storage/iscsi/version'.format(config.get_default('default_api_host'))443 res = https._get(url, body, self.auth)444 return res445 '''446 * 获取发现权限447 * 448 * @param dict $body 参数详见 API 手册449 * @return list450 '''451 def describeIscsiAuth(self, body):452 url = '{0}/storage/iscsi/auth'.format(config.get_default('default_api_host'))453 res = https._get(url, body, self.auth)454 return res455 '''456 * 设置发现权限457 * 458 * @param dict $body 参数详见 API 手册459 * @return list460 '''461 def createIscsiDiscoverAuth(self, body):462 url = '{0}/storage/iscsi/auth'.format(config.get_default('default_api_host'))463 res = https._post(url, body, self.auth)464 return res465 '''466 * 取消发现权限467 * 468 * @param dict $body 参数详见 API 手册469 * @return list470 '''471 def deleteIscsiDiscoverAuth(self, body):472 url = '{0}/storage/iscsi/auth'.format(config.get_default('default_api_host'))473 res = https._delete(url, body, self.auth)474 return res475 '''476 * 全局参数设置:自动添加 ISCSI目标端 门户477 * 478 * @param dict $body 参数详见 API 手册479 * @return list480 '''481 def createAutoAddPortal(self, body):482 url = '{0}/storage/iscsi/auto_add_portal'.format(config.get_default('default_api_host'))483 res = https._post(url, body, self.auth)484 return res485 '''486 * 全局参数设置:自动添加 单元逻辑号映射487 * 488 * @param dict $body 参数详见 API 手册489 * @return list490 '''491 def createAutoAddLun(self, body):492 url = '{0}/storage/iscsi/auto_add_luns'.format(config.get_default('default_api_host'))493 res = https._post(url, body, self.auth)494 return res495 '''496 * 获取全局参数:自动添加ISCSI目标端 门户497 * 498 * @param dict $body 参数详见 API 手册499 * @return list500 '''501 def describeAutoAddPortal(self, body):502 url = '{0}/storage/iscsi/auto_add_portal'.format(config.get_default('default_api_host'))503 res = https._get(url, body, self.auth)504 return res505 '''506 * 获取全局参数:自动添加单元逻辑映射507 * 508 * @param dict $body 参数详见 API 手册509 * @return list510 '''511 def describeAutoAddLun(self, body):512 url = '{0}/storage/iscsi/auto_add_luns'.format(config.get_default('default_api_host'))513 res = https._get(url, body, self.auth)514 return res515 '''516 * 获取状态517 * 518 * @param dict $body 参数详见 API 手册519 * @return list520 '''521 def describeIscsiTargetStatus(self, body):522 url = '{0}/storage/target/status'.format(config.get_default('default_api_host'))523 res = https._get(url, body, self.auth)524 return res525 '''526 * 获取信息527 * 528 * @param dict $body 参数详见 API 手册529 * @return list530 '''531 def listIscsiTarget(self, body):532 url = '{0}/storage/target/info'.format(config.get_default('default_api_host'))533 res = https._get(url, body, self.auth)534 return res535 '''536 * 添加537 * 538 * @param dict $body 参数详见 API 手册539 * @return list540 '''541 def createIscsiTarget(self, body):542 url = '{0}/storage/target'.format(config.get_default('default_api_host'))543 res = https._post(url, body, self.auth)544 return res545 '''546 * 删除547 * 548 * @param dict $body 参数详见 API 手册549 * @return list550 '''551 def deleteIscsiTarget(self, body):552 url = '{0}/storage/target'.format(config.get_default('default_api_host'))553 res = https._delete(url, body, self.auth)554 return res555 '''556 * 添加557 * 558 * @param dict $body 参数详见 API 手册559 * @return list560 '''561 def createIscsiInitiator(self, body):562 url = '{0}/storage/initiator'.format(config.get_default('default_api_host'))563 res = https._post(url, body, self.auth)564 return res565 '''566 * 删除567 * 568 * @param dict $body 参数详见 API 手册569 * @return list570 '''571 def deleteIscsiInitiator(self, body):572 url = '{0}/storage/initiator'.format(config.get_default('default_api_host'))573 res = https._delete(url, body, self.auth)574 return res575 '''576 * 设置连接权限577 * 578 * @param dict $body 参数详见 API 手册579 * @return list580 '''581 def createIscsiInitiatorConnectAuth(self, body):582 url = '{0}/storage/initiator/auth'.format(config.get_default('default_api_host'))583 res = https._post(url, body, self.auth)584 return res585 '''586 * 添加 逻辑单元号(LUN)587 * 588 * @param dict $body 参数详见 API 手册589 * @return list590 '''591 def createIscsiInitiatorLun(self, body):592 url = '{0}/storage/initiator/lun'.format(config.get_default('default_api_host'))593 res = https._post(url, body, self.auth)594 return res595 '''596 * 删除 逻辑单元号(LUN)597 * 598 * @param dict $body 参数详见 API 手册599 * @return list600 '''601 def deleteIscsiInitiatorLun(self, body):602 url = '{0}/storage/initiator/lun'.format(config.get_default('default_api_host'))603 res = https._delete(url, body, self.auth)604 return res605 '''606 * 发现目标端607 * 608 * @param dict $body 参数详见 API 手册609 * @return list610 '''611 def createIscsiInitiatorDiscoverTarget(self, body):612 url = '{0}/storage/initiator/discover'.format(config.get_default('default_api_host'))613 res = https._post(url, body, self.auth)614 return res615 '''616 * 连接目标端617 * 618 * @param dict $body 参数详见 API 手册619 * @return list620 '''621 def createIscsiInitiatorConnectTarget(self, body):622 url = '{0}/storage/initiator/connect'.format(config.get_default('default_api_host'))623 res = https._post(url, body, self.auth)624 return res625 '''626 * 断开目标段连接627 * 628 * @param dict $body 参数详见 API 手册629 * @return list630 '''631 def deleteIscsiInitiatorConnectTarget(self, body):632 url = '{0}/storage/initiator/connect'.format(config.get_default('default_api_host'))633 res = https._delete(url, body, self.auth)634 return res635 '''636 * 获取发现门户列表637 * 638 * @param dict $body 参数详见 API 手册639 * @return list640 '''641 def listIscsiInitiatorPortal(self, body):642 url = '{0}/storage/initiator/portal'.format(config.get_default('default_api_host'))643 res = https._get(url, body, self.auth)644 return res645 '''646 * 删除发现门户647 * 648 * @param dict $body 参数详见 API 手册649 * @return list650 '''651 def deleteIscsiInitiatorPortal(self, body):652 url = '{0}/storage/initiator/portal'.format(config.get_default('default_api_host'))653 res = https._delete(url, body, self.auth)654 return res655 '''656 * 获取信息657 * 658 * @param dict $body 参数详见 API 手册659 * @return list660 '''661 def listTpg(self, body):662 url = '{0}/storage/tpg/info'.format(config.get_default('default_api_host'))663 res = https._get(url, body, self.auth)664 return res665 '''666 * 添加667 * 668 * @param dict $body 参数详见 API 手册669 * @return list670 '''671 def createTpg(self, body):672 url = '{0}/storage/tpg'.format(config.get_default('default_api_host'))673 res = https._post(url, body, self.auth)674 return res675 '''676 * 删除677 * 678 * @param dict $body 参数详见 API 手册679 * @return list680 '''681 def deleteTpg(self, body):682 url = '{0}/storage/tpg'.format(config.get_default('default_api_host'))683 res = https._delete(url, body, self.auth)684 return res685 '''686 * 设置连接权限687 * 688 * @param dict $body 参数详见 API 手册689 * @return list690 '''691 def createTpgConnectAuth(self, body):692 url = '{0}/storage/tpg/auth'.format(config.get_default('default_api_host'))693 res = https._post(url, body, self.auth)694 return res695 '''696 * 取消连接权限697 * 698 * @param dict $body 参数详见 API 手册699 * @return list700 '''701 def deleteTpgConnectAuth(self, body):702 url = '{0}/storage/tpg/auth'.format(config.get_default('default_api_host'))703 res = https._delete(url, body, self.auth)704 return res705 '''706 * 添加 逻辑单元(LUN)707 * 708 * @param dict $body 参数详见 API 手册709 * @return list710 '''711 def createTpgLun(self, body):712 url = '{0}/storage/tpg/lun'.format(config.get_default('default_api_host'))713 res = https._post(url, body, self.auth)714 return res715 '''716 * 是否开启连接权限717 * 718 * @param dict $body 参数详见 API 手册719 * @return list720 '''721 def describeTpgConnectAuth(self, body):722 url = '{0}/storage/tpg/auth'.format(config.get_default('default_api_host'))723 res = https._get(url, body, self.auth)724 return res725 '''726 * 删除 逻辑单元号(LUN)727 * 728 * @param dict $body 参数详见 API 手册729 * @return list730 '''731 def deleteTpgLun(self, body):732 url = '{0}/storage/tpg/lun'.format(config.get_default('default_api_host'))733 res = https._delete(url, body, self.auth)734 return res735 '''736 * 添加 门户(Portal)737 * 738 * @param dict $body 参数详见 API 手册739 * @return list740 '''741 def createTpgPortal(self, body):742 url = '{0}/storage/tpg/portal'.format(config.get_default('default_api_host'))743 res = https._post(url, body, self.auth)744 return res745 '''746 * 删除 门户(Portal)747 * 748 * @param dict $body 参数详见 API 手册749 * @return list750 '''751 def deleteTpgPortal(self, body):752 url = '{0}/storage/tpg/portal'.format(config.get_default('default_api_host'))753 res = https._delete(url, body, self.auth)...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...9 def __init__(self, **kwargs):10 # Transformation configurations.11 #12 # Initial permutation.13 self.first_perm = misc.get_default(kwargs, 'first_perm')14 # Initial linear mapping.15 self.first_do_linear_map = misc.get_default(16 kwargs, 'first_do_linear_map', False)17 self.first_init_mat_params = misc.get_default(18 kwargs, 'first_init_mat_params')19 self.first_init_b = misc.get_default(kwargs, 'first_init_b')20 self.first_trainable_A = misc.get_default(21 kwargs, 'first_trainable_A', False)22 self.first_trainable_b = misc.get_default(23 kwargs, 'first_trainable_b', False)24 # Subsequent linear mappings.25 self.init_mat_params = misc.get_default(kwargs, 'init_mat_params')26 self.init_b = misc.get_default(kwargs, 'init_b')27 self.trainable_A = misc.get_default(kwargs, 'trainable_A', True)28 self.trainable_b = misc.get_default(kwargs, 'trainable_b', True)29 self.mat_func = misc.get_default(kwargs, 'mat_func', trans.get_LU_map)30 # RNN transformation parameters.31 self.trans_state_size = misc.get_default(32 kwargs, 'trans_state_size', 16)33 self.trans_alpha = misc.get_default(kwargs, 'trans_alpha', None)34 self.trans_state_activation = misc.get_default(35 kwargs, 'trans_state_activation', tf.nn.relu36 )37 # RNN coupling parameters.38 self.rnn_coupling_params = misc.get_default(39 kwargs, 'rnn_coupling_params', {'nunits': 256, 'num_layers': 1})40 self.rnn_coupling_type = misc.get_default(kwargs, 'rnn_coupling_type',41 cells.GRUCell)42 self.rnn_coupling_class = self.rnn_coupling_type(43 **self.rnn_coupling_params)44 # Image tiling arguments.45 self.tile_hw = misc.get_default(kwargs, 'tile_hw', 28)46 self.tile_chans = misc.get_default(kwargs, 'tile_chans', 1)47 # Additive transformation parameters.48 self.add_hidden_sizes = misc.get_default(49 kwargs, 'add_hidden_sizes', [256]*2)50 self.add_irange = misc.get_default(51 kwargs, 'add_irange', None)52 self.add_output_irange = misc.get_default(53 kwargs, 'add_output_irange', None)54 # Rescaling transformation parameters.55 self.rescale_init_constant = misc.get_default(56 kwargs, 'rescale_init_constant', 1.0)57 self.trans_funcs = misc.get_default(kwargs, 'trans_funcs')58 # Conditional transformation parameters.59 self.do_init_cond_trans = misc.get_default(60 kwargs, 'do_init_cond_trans', False)61 self.do_final_cond_trans = misc.get_default(62 kwargs, 'do_final_cond_trans', False)63 self.cond_hidden_sizes = misc.get_default(64 kwargs, 'cond_hidden_sizes', [256]*2)65 self.cond_irange = misc.get_default(66 kwargs, 'cond_irange', None)67 self.cond_output_irange = misc.get_default(68 kwargs, 'cond_output_irange', 1e-6)69 # Leaky ReLU parameters70 self.relu_alpha = misc.get_default(71 kwargs, 'relu_alpha', None)72 # Make list of transformation functions.73 #74 # Do an initial permuation and linear transformation.75 self.first_transformations = []76 if self.first_perm is not None:77 self.first_transformations += [78 lambda x: trans.permute(x, self.first_perm)79 ]80 if self.first_do_linear_map:81 self.first_transformations += [82 lambda x: trans.linear_map(83 x,84 init_mat_params=self.first_init_mat_params,85 init_b=self.first_init_b,86 mat_func=self.mat_func,87 trainable_A=self.first_trainable_A,88 trainable_b=self.first_trainable_b89 )90 ]91 # TODO: untracked transformations should still work.92 # Make the default arguments for the various transformations.93 self.transform_arguments = {94 trans.linear_map: {95 'init_mat_params': self.init_mat_params,96 'init_b': self.init_b,97 'mat_func': self.mat_func,98 'trainable_A': self.trainable_A,99 'trainable_b': self.trainable_b},100 trans.additive_coupling: {101 'hidden_sizes': self.add_hidden_sizes,102 'irange': self.add_irange,103 'output_irange': self.add_output_irange},104 trans.rescale: {105 'init_constant': self.rescale_init_constant},106 trans.simple_rnn_transform: {107 'state_size': self.trans_state_size,108 'alpha': self.trans_alpha,109 'state_activation': self.trans_state_activation},110 trans.rnn_coupling: {111 'rnn_class': self.rnn_coupling_class},112 trans.negate: {},113 trans.reverse: {},114 trans.log_rescale: {},115 trans.shift: {},116 trans.leaky_transformation: {117 'alpha': self.relu_alpha},118 }119 # Likelihood parameters.120 #121 self.ncomps = misc.get_default(kwargs, 'ncomps', 40)122 self.nparams = 3*self.ncomps123 self.base_distribution = misc.get_default(124 kwargs, 'base_distribution', 'gaussian')125 self.likefunc = misc.get_default(126 kwargs, 'likefunc', likes.mixture_likelihoods)127 self.param_nlayers = misc.get_default(kwargs, 'param_nlayers')128 # Conditional density parameters.129 # TODO: Add options to use conditioning information at fc and/or130 # autoregressive levels.131 #132 self.nhidparams = misc.get_default(kwargs, 'nhidparams', self.nparams)133 # Independent model.134 self.single_marginal = misc.get_default(kwargs, 'single_marginal',135 False)136 self.standard = misc.get_default(kwargs, 'standard', False)137 # Conditional model.138 self.cond_tied_model = misc.get_default(kwargs, 'cond_tied_model', True)139 # RNN Model.140 self.rnn_params = misc.get_default(141 kwargs, 'rnn_params', {'nunits': 256, 'num_layers': 1})142 self.rnn_type = misc.get_default(kwargs, 'rnn_type', cells.GRUCell)143 self.rnn_class = self.rnn_type(**self.rnn_params)144 # Conditional model arguments.145 self.conditional_argument = {146 conds.independent_model: {'single_marginal': self.single_marginal,147 'standard': self.standard},148 conds.cond_model: {'tied_model': self.cond_tied_model},149 conds.rnn_model: {'rnn_class': self.rnn_class}150 }151 # Orderless methods that get all covariates as inputs.152 self.orderless_models = set([]) # TODO: remove153 # Make conditional function.154 self.cond_func = misc.get_default(kwargs, 'cond_func', conds.rnn_model)155 self.orderless = self.cond_func in self.orderless_models # TODO: remove156 self.conditional_model = lambda x, f, c: self.cond_func(157 x, self.nhidparams, param_func=f, conditioning=c,158 **self.conditional_argument[self.cond_func]159 )160 self.hidden_activation = misc.get_default(161 kwargs, 'hidden_activation', tf.nn.relu)162 self.cond_param_irange = misc.get_default(163 kwargs, 'cond_param_irange', None)164 # Conditioning value usage.165 #166 self.trans_conditioning = misc.get_default(167 kwargs, 'trans_conditioning', True)168 self.conditional_conditioning = misc.get_default(169 kwargs, 'conditional_conditioning', True)170 self.fc_conditioning = misc.get_default(kwargs, 'fc_conditioning', True)171 # Sampling Options.172 #173 self.sample_batch_size = misc.get_default(174 kwargs, 'sample_batch_size', 128)175 self.nsample_batches = misc.get_default(kwargs, 'nsample_batches', 10)176 self.samp_per_cond = misc.get_default(kwargs, 'samp_per_cond', 500)177 # Training configurations.178 #179 self.initializer_class = misc.get_default(kwargs, 'initializer_class',180 None)181 self.initializer_args = misc.get_default(182 kwargs, 'initializer_args', {'minval': -0.05, 'maxval': 0.05})183 self.initializer = None if self.initializer_class is None else \184 self.initializer_class(**self.initializer_args)185 self.batch_size = misc.get_default(kwargs, 'batch_size', 128)186 self.init_lr = misc.get_default(kwargs, 'init_lr', 0.1)187 self.min_lr = misc.get_default(kwargs, 'min_lr', None)188 self.lr_decay = misc.get_default(kwargs, 'lr_decay', 0.9)189 self.decay_interval = misc.get_default(kwargs, 'decay_interval', 10000)190 self.penalty = misc.get_default(kwargs, 'penalty', 0.0)191 self.dropout_keeprate_val = misc.get_default(192 kwargs, 'dropout_keeprate_val', 1.0)193 self.train_iters = misc.get_default(kwargs, 'train_iters', 30000)194 self.hold_iters = misc.get_default(kwargs, 'hold_iters', 100)195 self.print_iters = misc.get_default(kwargs, 'print_iters', 250)196 self.hold_interval = misc.get_default(kwargs, 'hold_interval', 2500)197 self.optimizer_class = misc.get_default(198 kwargs, 'optimizer_class', tf.train.AdamOptimizer)199 self.max_grad_norm = misc.get_default(kwargs, 'max_grad_norm', None)200 self.do_check = misc.get_default(kwargs, 'do_check', False)201 self.momentum = misc.get_default(kwargs, 'momentum', None)202 self.momentum_iter = misc.get_default(203 kwargs, 'momentum_iter', 10000000000)204 self.pretrain_scope = misc.get_default(kwargs, 'pretrain_scope', None)205 self.pretrain_iters = misc.get_default(kwargs, 'pretrain_iters', 5000)206 self.noise_scale = misc.get_default(kwargs, 'noise_scale', None)207 # Image configurations.208 #209 self.img_size = misc.get_default(kwargs, 'img_size', (64, 64, 3))210 self.downsample = misc.get_default(kwargs, 'downsample', 1)211 self.do_resize = misc.get_default(kwargs, 'do_resize', True)212 self.center_crop = misc.get_default(kwargs, 'center_crop', None)213 self.do_bw = misc.get_default(kwargs, 'do_bw', False)214 self.do_read_logit = misc.get_default(kwargs, 'do_read_logit', False)215 self.do_init_logit = misc.get_default(kwargs, 'do_init_logit', False)216 self.seq_feats = misc.get_default(kwargs, 'seq_feats', 256)217 self.mean_layers = misc.get_default(kwargs, 'mean_layers', None)218 self.conv_feats = misc.get_default(kwargs, 'conv_feats', 64)219 self.conv_hid = misc.get_default(kwargs, 'conv_hid', [64, 64, 64])220 self.use_markov_feats = misc.get_default(221 kwargs, 'use_markov_feats', False)222 # self.use_discrete_probs = misc.get_default(223 # kwargs, 'use_discrete_probs', False)224 # flat, column, double_seq, sub_column225 self.image_model = misc.get_default(kwargs, 'image_model', 'column')226 self.use_2nd_markov = misc.get_default(kwargs, 'use_2nd_markov', False)227 self.image_sublevels = misc.get_default(kwargs, 'image_sublevels', 2)228 self.image_cell_class = misc.get_default(kwargs, 'image_cell_class',229 cells.GRUCell)230 self.logit_iters = misc.get_default(kwargs, 'logit_iters', None)231 self.seq_logit_trans = misc.get_default(232 kwargs, 'seq_logit_trans', False)233 self.seq_cell_layers = misc.get_default(kwargs, 'seq_cell_layers', 1)234 self.seq_fc_layers = misc.get_default(kwargs, 'seq_fc_layers', None)235 self.predict_layers = misc.get_default(kwargs, 'predict_layers', None)236 self.predict_alpha = misc.get_default(kwargs, 'predict_alpha', 0.5)237 # Embeddings.238 self.embed_size = misc.get_default(kwargs, 'embed_size', 256)239 self.embed_layers = misc.get_default(kwargs, 'embed_layers', [256, 256])240 self.embed_irange = misc.get_default(kwargs, 'embed_irange', 1e-6)241 self.embed_activation = misc.get_default(242 kwargs, 'embed_activation', tf.nn.relu)243 self.set_regression = misc.get_default(kwargs, 'set_regression', False)244 self.set_classification = misc.get_default(245 kwargs, 'set_classification', False)246 self.set_loss_alpha = misc.get_default(kwargs, 'set_loss_alpha', 0.5)247 self.set_layers = misc.get_default(kwargs, 'set_layers', [256, 256])248 def transformations_generator(self):249 """ Helper function to dynamically build transformation functions based250 on configuration parameters. """251 for func in self.first_transformations:252 yield func253 # TODO: Move to front?254 if self.do_init_cond_trans:255 yield lambda x, c: trans.conditioning_transformation(256 x, c, hidden_sizes=self.cond_hidden_sizes,257 irange=self.cond_irange, output_irange=self.cond_output_irange)258 if self.trans_funcs is not None:259 for func in self.trans_funcs:260 yield lambda x: func(261 x, **self.transform_arguments[func])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful