idds-server 2.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. idds/agents/__init__.py +9 -0
  2. idds/agents/archive/__init__.py +9 -0
  3. idds/agents/archive/archiver.py +77 -0
  4. idds/agents/archive/run_archive.py +146 -0
  5. idds/agents/carrier/__init__.py +9 -0
  6. idds/agents/carrier/finisher.py +616 -0
  7. idds/agents/carrier/iutils.py +226 -0
  8. idds/agents/carrier/plugins/__init__.py +9 -0
  9. idds/agents/carrier/plugins/base.py +224 -0
  10. idds/agents/carrier/plugins/panda.py +203 -0
  11. idds/agents/carrier/poller.py +730 -0
  12. idds/agents/carrier/receiver.py +341 -0
  13. idds/agents/carrier/submitter.py +616 -0
  14. idds/agents/carrier/trigger.py +294 -0
  15. idds/agents/carrier/utils.py +2413 -0
  16. idds/agents/clerk/__init__.py +9 -0
  17. idds/agents/clerk/clerk.py +2104 -0
  18. idds/agents/common/__init__.py +9 -0
  19. idds/agents/common/baseagent.py +431 -0
  20. idds/agents/common/cache/__init__.py +9 -0
  21. idds/agents/common/cache/redis.py +108 -0
  22. idds/agents/common/eventbus/__init__.py +9 -0
  23. idds/agents/common/eventbus/baseeventbusbackend.py +132 -0
  24. idds/agents/common/eventbus/baseeventbusbackendopt.py +172 -0
  25. idds/agents/common/eventbus/dbeventbusbackend.py +85 -0
  26. idds/agents/common/eventbus/event.py +11 -0
  27. idds/agents/common/eventbus/eventbus.py +150 -0
  28. idds/agents/common/eventbus/msgeventbusbackend.py +620 -0
  29. idds/agents/common/plugins/__init__.py +9 -0
  30. idds/agents/common/plugins/messaging.py +409 -0
  31. idds/agents/common/timerscheduler.py +239 -0
  32. idds/agents/common/timertask.py +68 -0
  33. idds/agents/conductor/__init__.py +9 -0
  34. idds/agents/conductor/conductor.py +360 -0
  35. idds/agents/conductor/consumer.py +107 -0
  36. idds/agents/coordinator/__init__.py +9 -0
  37. idds/agents/coordinator/coordinator.py +375 -0
  38. idds/agents/coordinator/nats_coordinator.py +377 -0
  39. idds/agents/main.py +169 -0
  40. idds/agents/marshaller/__init__.py +9 -0
  41. idds/agents/marshaller/marshaller.py +293 -0
  42. idds/agents/prompt/__init__.py +9 -0
  43. idds/agents/prompt/handlers/__init__.py +9 -0
  44. idds/agents/prompt/handlers/panda.py +244 -0
  45. idds/agents/prompt/handlers/slicehandler.py +182 -0
  46. idds/agents/prompt/handlers/workerhandler.py +572 -0
  47. idds/agents/prompt/transceiver.py +395 -0
  48. idds/agents/transformer/__init__.py +9 -0
  49. idds/agents/transformer/transformer.py +1616 -0
  50. idds/agents/transporter/__init__.py +9 -0
  51. idds/agents/transporter/transporter.py +427 -0
  52. idds/api/__init__.py +9 -0
  53. idds/api/catalog.py +84 -0
  54. idds/api/collections.py +80 -0
  55. idds/api/contents.py +88 -0
  56. idds/api/processings.py +71 -0
  57. idds/api/requests.py +87 -0
  58. idds/api/transforms.py +68 -0
  59. idds/core/__init__.py +9 -0
  60. idds/core/authentication.py +140 -0
  61. idds/core/catalog.py +898 -0
  62. idds/core/commands.py +106 -0
  63. idds/core/conditions.py +104 -0
  64. idds/core/events.py +104 -0
  65. idds/core/health.py +102 -0
  66. idds/core/messages.py +151 -0
  67. idds/core/meta.py +58 -0
  68. idds/core/processings.py +462 -0
  69. idds/core/requests.py +515 -0
  70. idds/core/requests_group.py +76 -0
  71. idds/core/throttlers.py +64 -0
  72. idds/core/transforms.py +661 -0
  73. idds/core/version.py +12 -0
  74. idds/core/workprogress.py +212 -0
  75. idds/orm/__init__.py +9 -0
  76. idds/orm/base/__init__.py +9 -0
  77. idds/orm/base/alembic/__init__.py +9 -0
  78. idds/orm/base/alembic/env.py +100 -0
  79. idds/orm/base/alembic/versions/0204f391c32d_add_poll_period_in_message.py +42 -0
  80. idds/orm/base/alembic/versions/1bc6e82e8514_using_hash_on_contents_long_name.py +61 -0
  81. idds/orm/base/alembic/versions/2553ccb45260_add_unmapped_num_in_processing.py +61 -0
  82. idds/orm/base/alembic/versions/3073c5de8f73_add_conditions_and_campaign.py +86 -0
  83. idds/orm/base/alembic/versions/354f8e5a5879_add_meta_info_table.py +57 -0
  84. idds/orm/base/alembic/versions/40ead97e63c6_messages_table_add_internal_id.py +39 -0
  85. idds/orm/base/alembic/versions/53d0af715dab_add_site_throttler.py +97 -0
  86. idds/orm/base/alembic/versions/5e0aa2aa1fa3_add_fetch_status_in_contents_update.py +41 -0
  87. idds/orm/base/alembic/versions/6931b48500a2_add_campaign_group.py +112 -0
  88. idds/orm/base/alembic/versions/6ae1f334bf41_create_contents_dep_index.py +40 -0
  89. idds/orm/base/alembic/versions/6ca0e5e466eb_update_message_null_constraints.py +43 -0
  90. idds/orm/base/alembic/versions/87df821d153a_opt_group_table.py +41 -0
  91. idds/orm/base/alembic/versions/8c3a2b989a93_update_campaign_columns.py +71 -0
  92. idds/orm/base/alembic/versions/8fe5cab9bde1_update_transforms_adding_constraint.py +42 -0
  93. idds/orm/base/alembic/versions/__init__.py +9 -0
  94. idds/orm/base/alembic/versions/a844dae57021_add_process_thread_locking_information.py +67 -0
  95. idds/orm/base/alembic/versions/abf9fce65c86_add_parent_internal_id_in_transforms.py +43 -0
  96. idds/orm/base/alembic/versions/ad6d53a69afa_add_cloud_info_in_requests.py +49 -0
  97. idds/orm/base/alembic/versions/b0ec813021d6_add_sub_map_id.py +48 -0
  98. idds/orm/base/alembic/versions/cc9f730e54c5_add_parent_transform_id_and_processing_.py +51 -0
  99. idds/orm/base/alembic/versions/e3f3af2cadc7_add_new_requests_in_requests_group.py +41 -0
  100. idds/orm/base/alembic/versions/f26b00cc867d_add_more_files_statistics_items.py +43 -0
  101. idds/orm/base/alembic/versions/f79663a7e94e_add_external_content_id.py +45 -0
  102. idds/orm/base/enum.py +120 -0
  103. idds/orm/base/models.py +1236 -0
  104. idds/orm/base/session.py +417 -0
  105. idds/orm/base/types.py +194 -0
  106. idds/orm/base/utils.py +151 -0
  107. idds/orm/collections.py +441 -0
  108. idds/orm/commands.py +195 -0
  109. idds/orm/conditions.py +167 -0
  110. idds/orm/contents.py +1656 -0
  111. idds/orm/events.py +323 -0
  112. idds/orm/health.py +107 -0
  113. idds/orm/messages.py +260 -0
  114. idds/orm/meta.py +102 -0
  115. idds/orm/processings.py +614 -0
  116. idds/orm/requests.py +1416 -0
  117. idds/orm/requests_group.py +120 -0
  118. idds/orm/throttlers.py +151 -0
  119. idds/orm/transforms.py +718 -0
  120. idds/orm/workprogress.py +304 -0
  121. idds/rest/__init__.py +9 -0
  122. idds/rest/v1/__init__.py +9 -0
  123. idds/rest/v1/app.py +193 -0
  124. idds/rest/v1/auth.py +139 -0
  125. idds/rest/v1/cacher.py +99 -0
  126. idds/rest/v1/catalog.py +218 -0
  127. idds/rest/v1/controller.py +93 -0
  128. idds/rest/v1/hyperparameteropt.py +158 -0
  129. idds/rest/v1/logs.py +104 -0
  130. idds/rest/v1/messages.py +194 -0
  131. idds/rest/v1/metainfo.py +60 -0
  132. idds/rest/v1/monitor.py +528 -0
  133. idds/rest/v1/ping.py +52 -0
  134. idds/rest/v1/requests.py +559 -0
  135. idds/rest/v1/transforms.py +127 -0
  136. idds/rest/v1/utils.py +268 -0
  137. idds/tests/__init__.py +9 -0
  138. idds/tests/activelearning_test.py +56 -0
  139. idds/tests/activelearning_test_codes/merge.py +31 -0
  140. idds/tests/activelearning_test_codes/runtasklocal.py +43 -0
  141. idds/tests/activelearning_test_codes/simplescript.py +30 -0
  142. idds/tests/auth_test_script.py +137 -0
  143. idds/tests/cacher_test.py +32 -0
  144. idds/tests/catalog_test.py +45 -0
  145. idds/tests/client_test.py +50 -0
  146. idds/tests/common.py +337 -0
  147. idds/tests/core_tests.py +311 -0
  148. idds/tests/core_tests_atlas.py +157 -0
  149. idds/tests/core_tests_dep_id.py +35 -0
  150. idds/tests/core_tests_stat.py +35 -0
  151. idds/tests/datacarousel_test.py +115 -0
  152. idds/tests/doma_build_test.py +164 -0
  153. idds/tests/doma_build_test_pandaclient.py +189 -0
  154. idds/tests/find_dependencies.py +73 -0
  155. idds/tests/fix_content_dep_id.py +69 -0
  156. idds/tests/fix_trasnform_name.py +27 -0
  157. idds/tests/group_submission.py +92 -0
  158. idds/tests/hyperparameteropt_bayesian_test.py +56 -0
  159. idds/tests/hyperparameteropt_client_test.py +49 -0
  160. idds/tests/hyperparameteropt_docker_local_test.py +176 -0
  161. idds/tests/hyperparameteropt_docker_test.py +57 -0
  162. idds/tests/hyperparameteropt_nevergrad_test.py +56 -0
  163. idds/tests/jsonload_test.py +81 -0
  164. idds/tests/kill_workflow_task.py +41 -0
  165. idds/tests/logs_test.py +34 -0
  166. idds/tests/match_test.py +49 -0
  167. idds/tests/message_test.py +22 -0
  168. idds/tests/message_test1.py +25 -0
  169. idds/tests/migrating_requests_v1_to_v2.py +80 -0
  170. idds/tests/os_boto3_test.py +86 -0
  171. idds/tests/panda_client_submit_test.py +66 -0
  172. idds/tests/panda_client_test.py +24 -0
  173. idds/tests/panda_iam_test.py +41 -0
  174. idds/tests/panda_test.py +352 -0
  175. idds/tests/performance_test_with_cx_oracle.py +169 -0
  176. idds/tests/performance_test_with_sqlalchemy.py +133 -0
  177. idds/tests/relation_map_test.py +64 -0
  178. idds/tests/rest_test.py +29 -0
  179. idds/tests/retry_processing.py +9 -0
  180. idds/tests/run_sql.py +65 -0
  181. idds/tests/scaling_checks.py +45 -0
  182. idds/tests/set_throttlers.py +10 -0
  183. idds/tests/split_messages.py +30 -0
  184. idds/tests/subprocess_test.py +45 -0
  185. idds/tests/test_activelearning.py +181 -0
  186. idds/tests/test_atlaspandawork.py +194 -0
  187. idds/tests/test_auth.py +128 -0
  188. idds/tests/test_big_request.py +68 -0
  189. idds/tests/test_catalog.py +546 -0
  190. idds/tests/test_catalog_core.py +48 -0
  191. idds/tests/test_class_attr.py +39 -0
  192. idds/tests/test_client.py +73 -0
  193. idds/tests/test_core_debug.py +50 -0
  194. idds/tests/test_datacarousel.py +145 -0
  195. idds/tests/test_domapanda.py +363 -0
  196. idds/tests/test_domapanda_big.py +328 -0
  197. idds/tests/test_domapanda_build.py +207 -0
  198. idds/tests/test_domapanda_build_pandaclient.py +226 -0
  199. idds/tests/test_domapanda_es.py +319 -0
  200. idds/tests/test_domapanda_long_name.py +272 -0
  201. idds/tests/test_domapanda_lsst_workflow.py +330 -0
  202. idds/tests/test_domapanda_mem.py +290 -0
  203. idds/tests/test_domapanda_pandaclient.py +196 -0
  204. idds/tests/test_domapanda_small_mem.py +279 -0
  205. idds/tests/test_domapanda_workflow.py +185 -0
  206. idds/tests/test_get_dn.py +127 -0
  207. idds/tests/test_get_request_info.py +36 -0
  208. idds/tests/test_get_request_info_panda.py +38 -0
  209. idds/tests/test_get_source_code.py +24 -0
  210. idds/tests/test_hyperparameteropt.py +65 -0
  211. idds/tests/test_iworkflow/optimize.py +437 -0
  212. idds/tests/test_iworkflow/optimize_iworkflow.py +124 -0
  213. idds/tests/test_iworkflow/test_asyncresults.py +51 -0
  214. idds/tests/test_iworkflow/test_imports.py +40 -0
  215. idds/tests/test_iworkflow/test_iworkflow.py +144 -0
  216. idds/tests/test_iworkflow/test_iworkflow1.py +136 -0
  217. idds/tests/test_iworkflow/test_iworkflow_local.py +122 -0
  218. idds/tests/test_iworkflow/test_iworkflow_local_mul.py +122 -0
  219. idds/tests/test_iworkflow/test_iworkflow_mul.py +152 -0
  220. idds/tests/test_iworkflow/test_plot.py +70 -0
  221. idds/tests/test_logger.py +83 -0
  222. idds/tests/test_merge_dict.py +48 -0
  223. idds/tests/test_migrate_requests.py +120 -0
  224. idds/tests/test_nats.py +88 -0
  225. idds/tests/test_prompt_transformer.py +97 -0
  226. idds/tests/test_prompt_worker.py +168 -0
  227. idds/tests/test_property.py +17 -0
  228. idds/tests/test_request_transform.py +70 -0
  229. idds/tests/test_requests.py +91 -0
  230. idds/tests/test_running_data.py +212 -0
  231. idds/tests/test_scaling.py +51 -0
  232. idds/tests/test_sequence.py +4 -0
  233. idds/tests/test_token.py +48 -0
  234. idds/tests/test_token_refresh.py +81 -0
  235. idds/tests/test_transform_collection_content.py +219 -0
  236. idds/tests/test_transform_processing.py +56 -0
  237. idds/tests/test_workflow.py +127 -0
  238. idds/tests/test_workflow_condition.py +723 -0
  239. idds/tests/test_workflow_condition_v2.py +1926 -0
  240. idds/tests/test_workflow_condition_v2_1.py +248 -0
  241. idds/tests/test_wrapper.py +86 -0
  242. idds/tests/trigger_release.py +34 -0
  243. idds_server-2.6.0.data/data/config_default/alembic.ini +107 -0
  244. idds_server-2.6.0.data/data/config_default/auth.cfg +8 -0
  245. idds_server-2.6.0.data/data/config_default/gacl +29 -0
  246. idds_server-2.6.0.data/data/config_default/healthmonitor_daemon +4 -0
  247. idds_server-2.6.0.data/data/config_default/httpd-idds-443-py311-al9.conf +205 -0
  248. idds_server-2.6.0.data/data/config_default/httpd-idds-443-py39-cc7.conf +205 -0
  249. idds_server-2.6.0.data/data/config_default/httpd_daemon.sh +28 -0
  250. idds_server-2.6.0.data/data/config_default/idds.cfg +230 -0
  251. idds_server-2.6.0.data/data/config_default/idds.cfg.orig +132 -0
  252. idds_server-2.6.0.data/data/config_default/idds_health_check.py +223 -0
  253. idds_server-2.6.0.data/data/config_default/logrotate_daemon +14 -0
  254. idds_server-2.6.0.data/data/config_default/logrotate_idds +19 -0
  255. idds_server-2.6.0.data/data/config_default/nats_daemon.sh +44 -0
  256. idds_server-2.6.0.data/data/config_default/panda.cfg +9 -0
  257. idds_server-2.6.0.data/data/config_default/rucio.cfg +22 -0
  258. idds_server-2.6.0.data/data/config_default/supervisord_healthmonitor.ini +17 -0
  259. idds_server-2.6.0.data/data/config_default/supervisord_httpd.ini +26 -0
  260. idds_server-2.6.0.data/data/config_default/supervisord_idds.ini +25 -0
  261. idds_server-2.6.0.data/data/config_default/supervisord_idds_clerk.ini +26 -0
  262. idds_server-2.6.0.data/data/config_default/supervisord_idds_finisher.ini +26 -0
  263. idds_server-2.6.0.data/data/config_default/supervisord_idds_poller.ini +26 -0
  264. idds_server-2.6.0.data/data/config_default/supervisord_idds_receiver.ini +26 -0
  265. idds_server-2.6.0.data/data/config_default/supervisord_idds_submitter.ini +26 -0
  266. idds_server-2.6.0.data/data/config_default/supervisord_idds_transformer.ini +26 -0
  267. idds_server-2.6.0.data/data/config_default/supervisord_idds_trigger.ini +26 -0
  268. idds_server-2.6.0.data/data/config_default/supervisord_iddsfake.ini +24 -0
  269. idds_server-2.6.0.data/data/config_default/supervisord_logrotate.ini +17 -0
  270. idds_server-2.6.0.data/data/config_default/supervisord_nats.ini +22 -0
  271. idds_server-2.6.0.data/data/config_default/supervisord_syslog-ng.ini +22 -0
  272. idds_server-2.6.0.data/data/config_default/vomsprox-renew +27 -0
  273. idds_server-2.6.0.data/data/etc/condor/collector/00personal_condor.config +42 -0
  274. idds_server-2.6.0.data/data/etc/condor/collector/09_flin_condor.config +3 -0
  275. idds_server-2.6.0.data/data/etc/condor/submitter/00personal_condor.config +43 -0
  276. idds_server-2.6.0.data/data/etc/idds/alembic.ini.template +107 -0
  277. idds_server-2.6.0.data/data/etc/idds/auth/auth.cfg.template +34 -0
  278. idds_server-2.6.0.data/data/etc/idds/condor/client/00personal_condor.config +43 -0
  279. idds_server-2.6.0.data/data/etc/idds/condor/server/00personal_condor.config +42 -0
  280. idds_server-2.6.0.data/data/etc/idds/idds.cfg.client.template +25 -0
  281. idds_server-2.6.0.data/data/etc/idds/idds.cfg.template +132 -0
  282. idds_server-2.6.0.data/data/etc/idds/rest/gacl.template +29 -0
  283. idds_server-2.6.0.data/data/etc/idds/rest/httpd-idds-443-py36-cc7.conf.template +120 -0
  284. idds_server-2.6.0.data/data/etc/idds/rest/httpd-idds-443-py36-cc7_normal.conf.template +63 -0
  285. idds_server-2.6.0.data/data/etc/idds/rest/httpd-idds-443-py39-cc7.conf.template +133 -0
  286. idds_server-2.6.0.data/data/etc/idds/rest/ssl.conf +55 -0
  287. idds_server-2.6.0.data/data/etc/idds/supervisord.d/idds.ini +29 -0
  288. idds_server-2.6.0.data/data/etc/idds/website/25-port443.conf +30 -0
  289. idds_server-2.6.0.data/data/etc/idds/website/25-port80.conf +10 -0
  290. idds_server-2.6.0.data/data/etc/panda/panda.cfg +12 -0
  291. idds_server-2.6.0.data/data/etc/sql/oracle_11.sql +688 -0
  292. idds_server-2.6.0.data/data/etc/sql/oracle_11_test.sql +43 -0
  293. idds_server-2.6.0.data/data/etc/sql/oracle_19.sql +651 -0
  294. idds_server-2.6.0.data/data/etc/sql/oracle_19_sqlalchemy.sql +625 -0
  295. idds_server-2.6.0.data/data/etc/sql/oracle_update.sql +619 -0
  296. idds_server-2.6.0.data/data/etc/sql/postgres_partition.sql +15 -0
  297. idds_server-2.6.0.data/data/etc/sql/postgresql.sql +563 -0
  298. idds_server-2.6.0.data/data/etc/sql/postgresql_init.sql +18 -0
  299. idds_server-2.6.0.data/data/etc/sql/postgresql_update.sql +21 -0
  300. idds_server-2.6.0.data/data/tools/env/clean_heartbeat.py +33 -0
  301. idds_server-2.6.0.data/data/tools/env/config_monitor.py +32 -0
  302. idds_server-2.6.0.data/data/tools/env/config_server +20 -0
  303. idds_server-2.6.0.data/data/tools/env/create_database.py +21 -0
  304. idds_server-2.6.0.data/data/tools/env/create_postgres_db.sh +16 -0
  305. idds_server-2.6.0.data/data/tools/env/destroy_database.py +28 -0
  306. idds_server-2.6.0.data/data/tools/env/dump_database.py +21 -0
  307. idds_server-2.6.0.data/data/tools/env/environment.yml +34 -0
  308. idds_server-2.6.0.data/data/tools/env/flake +8 -0
  309. idds_server-2.6.0.data/data/tools/env/install_env_conda.sh +19 -0
  310. idds_server-2.6.0.data/data/tools/env/install_idds.sh +47 -0
  311. idds_server-2.6.0.data/data/tools/env/install_idds_example.sh +117 -0
  312. idds_server-2.6.0.data/data/tools/env/install_idds_full.sh +136 -0
  313. idds_server-2.6.0.data/data/tools/env/install_packages.sh +13 -0
  314. idds_server-2.6.0.data/data/tools/env/merge_configmap.py +99 -0
  315. idds_server-2.6.0.data/data/tools/env/merge_idds_configs.py +130 -0
  316. idds_server-2.6.0.data/data/tools/env/setup_dev.sh +36 -0
  317. idds_server-2.6.0.data/data/tools/env/setup_httpd_conf.py +121 -0
  318. idds_server-2.6.0.data/data/tools/env/setup_idds.sh +10 -0
  319. idds_server-2.6.0.data/data/tools/env/setup_idds_path.py +177 -0
  320. idds_server-2.6.0.data/data/tools/env/setup_panda.sh +189 -0
  321. idds_server-2.6.0.data/scripts/idds-daemon +68 -0
  322. idds_server-2.6.0.data/scripts/idds.wsgi +25 -0
  323. idds_server-2.6.0.data/scripts/idds.wsgi.template +25 -0
  324. idds_server-2.6.0.data/scripts/run-idds +21 -0
  325. idds_server-2.6.0.data/scripts/run-idds-fake +5 -0
  326. idds_server-2.6.0.dist-info/METADATA +58 -0
  327. idds_server-2.6.0.dist-info/RECORD +330 -0
  328. idds_server-2.6.0.dist-info/WHEEL +5 -0
  329. idds_server-2.6.0.dist-info/licenses/LICENSE.rst +14 -0
  330. idds_server-2.6.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # http://www.apache.org/licenses/LICENSE-2.0OA
7
+ #
8
+ # Authors:
9
+ # - Wen Guan, <wen.guan@cern.ch>, 2019
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # http://www.apache.org/licenses/LICENSE-2.0OA
7
+ #
8
+ # Authors:
9
+ # - Wen Guan, <wen.guan@cern.ch>, 2019
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # http://www.apache.org/licenses/LICENSE-2.0OA
7
+ #
8
+ # Authors:
9
+ # - Wen Guan, <wen.guan@cern.ch>, 2019 - 2023
10
+
11
+ import traceback
12
+
13
+ from idds.common.constants import Sections, RequestStatus
14
+ from idds.common.utils import setup_logging
15
+ from idds.core import (requests as core_requests,
16
+ messages as core_messages)
17
+ from idds.agents.common.baseagent import BaseAgent
18
+
19
+
20
+ setup_logging(__name__)
21
+
22
+
23
+ class Archiver(BaseAgent):
24
+ """
25
+ Archiver works to archive data
26
+ """
27
+
28
+ def __init__(self, num_threads=1, poll_period=7, older_than=30, **kwargs):
29
+ self.set_max_workers()
30
+ num_threads = self.max_number_workers
31
+ super(Archiver, self).__init__(num_threads=num_threads, name='Archive', **kwargs)
32
+ if not poll_period:
33
+ poll_period = 7 # days
34
+ self.poll_period = int(poll_period) * 3600 * 24
35
+ if not older_than:
36
+ older_than = 30
37
+ self.older_than = int(older_than) # days
38
+ self.config_section = Sections.Archiver
39
+
40
+ def clean_messages(self):
41
+ try:
42
+ status = [RequestStatus.Finished, RequestStatus.SubFinished,
43
+ RequestStatus.Failed, RequestStatus.Cancelled,
44
+ RequestStatus.Suspended, RequestStatus.Expired]
45
+ request_id = core_requests.get_last_request_id(older_than=self.older_than, status=status)
46
+ if request_id:
47
+ self.logger.info("cleaning old mesages older than request id %s" % request_id)
48
+ core_messages.clean_old_messages(request_id=request_id)
49
+ except Exception as ex:
50
+ self.logger.error(ex)
51
+ self.logger.error(traceback.format_exc())
52
+
53
+ def run(self):
54
+ """
55
+ Main run function.
56
+ """
57
+ try:
58
+ self.logger.info("Starting main thread")
59
+ self.init_thread_info()
60
+
61
+ self.add_default_tasks()
62
+
63
+ self.logger.info("poll period: %s seconds" % self.poll_period)
64
+ self.logger.info("older_than: %s days" % self.older_than)
65
+
66
+ task = self.create_task(task_func=self.clean_messages, task_output_queue=None,
67
+ task_args=tuple(), task_kwargs={}, delay_time=self.poll_period, priority=1)
68
+ self.add_task(task)
69
+
70
+ self.execute()
71
+ except KeyboardInterrupt:
72
+ self.stop()
73
+
74
+
75
+ if __name__ == '__main__':
76
+ agent = Archiver()
77
+ agent()
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # http://www.apache.org/licenses/LICENSE-2.0OA
7
+ #
8
+ # Authors:
9
+ # - Wen Guan, <wen.guan@cern.ch>, 2021
10
+
11
+
12
+ """
13
+ performance test to insert contents.
14
+ """
15
+ import cx_Oracle
16
+
17
+
18
+ from idds.common.config import config_get
19
+ # from idds.core.contents import add_content
20
+
21
+
22
+ def get_archive_sql(schema):
23
+ sql = """
24
+ BEGIN
25
+ FOR i in (SELECT request_id, scope, name, requester, request_type, transform_tag,
26
+ workload_id, priority, status, substatus, locking, created_at,
27
+ updated_at, next_poll_at, accessed_at, expired_at, errors,
28
+ request_metadata, processing_metadata
29
+ FROM {schema}.requests
30
+ WHERE status in (3, 5, 9, 17) and created_at < sysdate - interval '3' month
31
+ order by request_id asc)
32
+ LOOP
33
+ --- archive records
34
+ insert into {schema}.requests_archive(request_id, scope, name, requester,
35
+ request_type, transform_tag, workload_id, priority, status,
36
+ substatus, locking, created_at, updated_at, next_poll_at,
37
+ accessed_at, expired_at, errors, request_metadata,
38
+ processing_metadata)
39
+ values(i.request_id, i.scope, i.name, i.requester, i.request_type, i.transform_tag,
40
+ i.workload_id, i.priority, i.status, i.substatus, i.locking, i.created_at,
41
+ i.updated_at, i.next_poll_at, i.accessed_at, i.expired_at, i.errors,
42
+ i.request_metadata, i.processing_metadata);
43
+
44
+ insert into {schema}.transforms_archive(transform_id, request_id, workload_id,
45
+ transform_type, transform_tag, priority,
46
+ safe2get_output_from_input, status,
47
+ substatus, locking, retries, created_at,
48
+ updated_at, next_poll_at, started_at,
49
+ finished_at, expired_at, transform_metadata,
50
+ running_metadata)
51
+ select transform_id, request_id, workload_id, transform_type, transform_tag,
52
+ priority, safe2get_output_from_input, status, substatus, locking,
53
+ retries, created_at, updated_at, next_poll_at, started_at, finished_at,
54
+ expired_at, transform_metadata, running_metadata
55
+ from {schema}.transforms where request_id=i.request_id;
56
+
57
+ insert into {schema}.processings_archive(processing_id, transform_id, request_id,
58
+ workload_id, status, substatus, locking, submitter, submitted_id,
59
+ granularity, granularity_type, created_at, updated_at, next_poll_at,
60
+ submitted_at, finished_at, expired_at, processing_metadata,
61
+ running_metadata, output_metadata)
62
+ select processing_id, transform_id, request_id, workload_id, status, substatus,
63
+ locking, submitter, submitted_id, granularity, granularity_type,
64
+ created_at, updated_at, next_poll_at, submitted_at, finished_at, expired_at,
65
+ processing_metadata, running_metadata, output_metadata
66
+ from {schema}.processings where request_id=i.request_id;
67
+
68
+ insert into {schema}.collections_archive(coll_id, coll_type, transform_id, request_id,
69
+ workload_id, relation_type, scope, name, bytes, status, substatus, locking,
70
+ total_files, storage_id, new_files, processed_files, processing_files,
71
+ processing_id, retries, created_at, updated_at, next_poll_at, accessed_at,
72
+ expired_at, coll_metadata)
73
+ select coll_id, coll_type, transform_id, request_id, workload_id, relation_type,
74
+ scope, name, bytes, status, substatus, locking, total_files, storage_id,
75
+ new_files, processed_files, processing_files, processing_id, retries,
76
+ created_at, updated_at, next_poll_at, accessed_at, expired_at,
77
+ coll_metadata
78
+ from {schema}.collections where request_id=i.request_id;
79
+
80
+ insert into {schema}.contents_archive(content_id, transform_id, coll_id, request_id,
81
+ workload_id, map_id, scope, name, min_id, max_id, content_type,
82
+ content_relation_type, status, substatus, locking, bytes, md5, adler32,
83
+ processing_id, storage_id, retries, path, created_at, updated_at,
84
+ accessed_at, expired_at, content_metadata)
85
+ select content_id, transform_id, coll_id, request_id, workload_id, map_id,
86
+ scope, name, min_id, max_id, content_type, content_relation_type,
87
+ status, substatus, locking, bytes, md5, adler32, processing_id,
88
+ storage_id, retries, path, created_at, updated_at, accessed_at,
89
+ expired_at, content_metadata
90
+ from {schema}.contents where request_id=i.request_id;
91
+
92
+ insert into {schema}.messages_archive(msg_id, msg_type, status, substatus, locking,
93
+ source, destination, request_id, workload_id, transform_id, processing_id,
94
+ num_contents, created_at, updated_at, msg_content)
95
+ select msg_id, msg_type, status, substatus, locking, source, destination,
96
+ request_id, workload_id, transform_id, processing_id, num_contents,
97
+ created_at, updated_at, msg_content
98
+ from {schema}.messages where request_id=i.request_id;
99
+
100
+
101
+ -- clean records
102
+ delete from {schema}.messages where request_id = i.request_id;
103
+ delete from {schema}.contents where request_id = i.request_id;
104
+ delete from {schema}.collections where request_id = i.request_id;
105
+ delete from {schema}.processings where request_id = i.request_id;
106
+ delete from {schema}.transforms where request_id = i.request_id;
107
+ delete from {schema}.requests where request_id = i.request_id;
108
+ END LOOP;
109
+ COMMIT;
110
+ END;
111
+ """
112
+ sql = sql.format(schema=schema)
113
+ return sql
114
+
115
+
116
+ def run_archive_sql(db_pool, schema):
117
+ connection = db_pool.acquire()
118
+
119
+ sql = get_archive_sql(schema)
120
+ # print(sql)
121
+ cursor = connection.cursor()
122
+ cursor.execute(sql)
123
+ cursor.close()
124
+
125
+ connection.commit()
126
+ db_pool.release(connection)
127
+
128
+
129
+ def get_session_pool():
130
+ sql_connection = config_get('database', 'default')
131
+ sql_connection = sql_connection.replace("oracle://", "")
132
+ user_pass, tns = sql_connection.split('@')
133
+ user, passwd = user_pass.split(':')
134
+ db_pool = cx_Oracle.SessionPool(user, passwd, tns, min=12, max=20, increment=1)
135
+
136
+ schema = config_get('database', 'schema')
137
+ return db_pool, schema
138
+
139
+
140
+ def run_archive():
141
+ pool, schema = get_session_pool()
142
+ run_archive_sql(pool, schema)
143
+
144
+
145
+ if __name__ == '__main__':
146
+ run_archive()
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # You may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ # http://www.apache.org/licenses/LICENSE-2.0OA
7
+ #
8
+ # Authors:
9
+ # - Wen Guan, <wen.guan@cern.ch>, 2019