ratio1 3.4.102__tar.gz → 3.4.104__tar.gz

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 (227) hide show
  1. {ratio1-3.4.102 → ratio1-3.4.104}/PKG-INFO +1 -1
  2. {ratio1-3.4.102 → ratio1-3.4.104}/pyproject.toml +1 -1
  3. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/_ver.py +1 -1
  4. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/evm_net.py +2 -2
  5. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/r1fs.py +585 -2
  6. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/pickle_serialization_mixin.py +86 -31
  7. {ratio1-3.4.102 → ratio1-3.4.104}/.devcontainer/Dockerfile +0 -0
  8. {ratio1-3.4.102 → ratio1-3.4.104}/.devcontainer/devcontainer.json +0 -0
  9. {ratio1-3.4.102 → ratio1-3.4.104}/.gitattributes +0 -0
  10. {ratio1-3.4.102 → ratio1-3.4.104}/.github/workflows/python-publish.yml +0 -0
  11. {ratio1-3.4.102 → ratio1-3.4.104}/.gitignore +0 -0
  12. {ratio1-3.4.102 → ratio1-3.4.104}/.vscode/launch.json +0 -0
  13. {ratio1-3.4.102 → ratio1-3.4.104}/LICENSE +0 -0
  14. {ratio1-3.4.102 → ratio1-3.4.104}/README.md +0 -0
  15. {ratio1-3.4.102 → ratio1-3.4.104}/TODOs.md +0 -0
  16. {ratio1-3.4.102 → ratio1-3.4.104}/__init__.py +0 -0
  17. {ratio1-3.4.102 → ratio1-3.4.104}/r1ctl.MD +0 -0
  18. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/__init__.py +0 -0
  19. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/__init__.py +0 -0
  20. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/distributed_custom_code_presets.py +0 -0
  21. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/generic_session.py +0 -0
  22. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/instance.py +0 -0
  23. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/payload/__init__.py +0 -0
  24. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/payload/payload.py +0 -0
  25. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/pipeline.py +0 -0
  26. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/plugin_template.py +0 -0
  27. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/responses.py +0 -0
  28. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/transaction.py +0 -0
  29. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base/webapp_pipeline.py +0 -0
  30. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/base_decentra_object.py +0 -0
  31. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/bc/__init__.py +0 -0
  32. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/bc/base.py +0 -0
  33. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/bc/chain.py +0 -0
  34. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/bc/ec.py +0 -0
  35. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/bc/evm.py +0 -0
  36. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/141.136.35.100.crt +0 -0
  37. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/195.35.29.4.crt +0 -0
  38. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/31.97.72.187.crt +0 -0
  39. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/51.15.142.167.crt +0 -0
  40. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/72.60.187.24.crt +0 -0
  41. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/72.60.81.67.crt +0 -0
  42. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/72.60.83.78.crt +0 -0
  43. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/__init__.py +0 -0
  44. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/a0d9818f.ala.eu-central-1.emqxsl.com.crt +0 -0
  45. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/r9092118.ala.eu-central-1.emqxsl.com.crt +0 -0
  46. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/certs/s624dbd4.ala.us-east-1.emqxsl.com.crt +0 -0
  47. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/README.md +0 -0
  48. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/cli.py +0 -0
  49. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/cli_commands.py +0 -0
  50. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/nodes.py +0 -0
  51. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/oracles.py +0 -0
  52. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/cli/package_update.py +0 -0
  53. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/code_cheker/__init__.py +0 -0
  54. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/code_cheker/base.py +0 -0
  55. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/code_cheker/checker.py +0 -0
  56. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/comm/__init__.py +0 -0
  57. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/comm/amqp_wrapper.py +0 -0
  58. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/comm/base_comm_wrapper.py +0 -0
  59. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/comm/mqtt_wrapper.py +0 -0
  60. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/README.md +0 -0
  61. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/__init__.py +0 -0
  62. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/apps.py +0 -0
  63. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/base.py +0 -0
  64. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/comms.py +0 -0
  65. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/environment.py +0 -0
  66. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/formatter.py +0 -0
  67. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/heartbeat.py +0 -0
  68. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/misc.py +0 -0
  69. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/payload.py +0 -0
  70. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/const/plugins/deeploy_const.py +0 -0
  71. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/__init__.py +0 -0
  72. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/__init__.py +0 -0
  73. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/chain_dist_custom_job_01_plugin.py +0 -0
  74. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/custom_webapi_01_plugin.py +0 -0
  75. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/generic_http_01_plugin.py +0 -0
  76. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/net_mon_01_plugin.py +0 -0
  77. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/telegram_basic_bot_01_plugin.py +0 -0
  78. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/telegram_conversational_bot_01_plugin.py +0 -0
  79. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/instance/view_scene_01_plugin.py +0 -0
  80. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/default/session/mqtt_session.py +0 -0
  81. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/__init__.py +0 -0
  82. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/base/__init__.py +0 -0
  83. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/base/base_formatter.py +0 -0
  84. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/default/__init__.py +0 -0
  85. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/default/a_dummy.py +0 -0
  86. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/default/aixp1.py +0 -0
  87. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/default/default.py +0 -0
  88. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/io_formatter/io_formatter_manager.py +0 -0
  89. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/__init__.py +0 -0
  90. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ifps_keygen +0 -0
  91. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/ipfs.service +0 -0
  92. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/launch_service.sh +0 -0
  93. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/restart.sh +0 -0
  94. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/run.sh +0 -0
  95. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/setup.sh +0 -0
  96. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/show.sh +0 -0
  97. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/ipfs/ipfs_setup/write_key.sh +0 -0
  98. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/__init__.py +0 -0
  99. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/base_logger.py +0 -0
  100. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/__init__.py +0 -0
  101. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/class_instance_mixin.py +0 -0
  102. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/computer_vision_mixin.py +0 -0
  103. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/datetime_mixin.py +0 -0
  104. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/download_mixin.py +0 -0
  105. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/general_serialization_mixin.py +0 -0
  106. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/json_serialization_mixin.py +0 -0
  107. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/machine_mixin.py +0 -0
  108. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/process_mixin.py +0 -0
  109. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/resource_size_mixin.py +0 -0
  110. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/timers_mixin.py +0 -0
  111. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/upload_mixin.py +0 -0
  112. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/logger_mixins/utils_mixin.py +0 -0
  113. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/small_logger.py +0 -0
  114. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/tzlocal/__init__.py +0 -0
  115. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/tzlocal/unix.py +0 -0
  116. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/tzlocal/utils.py +0 -0
  117. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/tzlocal/win32.py +0 -0
  118. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/logging/tzlocal/windows_tz.py +0 -0
  119. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/plugins_manager_mixin.py +0 -0
  120. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/utils/__init__.py +0 -0
  121. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/utils/comm_utils.py +0 -0
  122. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/utils/config.py +0 -0
  123. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/utils/dotenv.py +0 -0
  124. {ratio1-3.4.102 → ratio1-3.4.104}/ratio1/utils/oracle_sync/oracle_tester.py +0 -0
  125. {ratio1-3.4.102 → ratio1-3.4.104}/requirements.txt +0 -0
  126. {ratio1-3.4.102 → ratio1-3.4.104}/template.env +0 -0
  127. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/.example_env +0 -0
  128. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/8. custom_code_fastapi_assets/index.html +0 -0
  129. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/9. code_sandbox_from_scratch_assets/index.html +0 -0
  130. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/_example_pk_sdk.pem +0 -0
  131. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/eth2025/deploy_home_safety.py +0 -0
  132. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/eth2025/deploy_maintenance_monitoring.py +0 -0
  133. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex01_part1_connect.py +0 -0
  134. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex01_part2_filter.py +0 -0
  135. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex01_part3_adv_filter.py +0 -0
  136. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex02_part1_deploy_webapi.py +0 -0
  137. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex02_part2_deploy_plugin.py +0 -0
  138. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex02_part3_deploy_r1fs_test.py +0 -0
  139. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex03_custom_code_on_one_remote__example_1.py +0 -0
  140. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex04_custom_code_on_one_remote__example_2.py +0 -0
  141. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex05_custom_code_on_one_remote__example_3.py +0 -0
  142. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex06_custom_code_on_multiple_remotes__example_1.py +0 -0
  143. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex07_custom_code_on_multiple_remotes__example_2.py +0 -0
  144. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex08_custom_webapi.py +0 -0
  145. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex09_code_sandbox_from_scratch.py +0 -0
  146. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex10_telegram_echo_bot.py +0 -0
  147. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex11_telegram_blackjack_bot.py +0 -0
  148. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex12_telegram_smart_bot.py +0 -0
  149. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex13_launch_repo_based_webapp.py +0 -0
  150. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex14_wallets.py +0 -0
  151. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex15_telegram_rogue_style_game.py +0 -0
  152. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex16_launch_repo_based_http_server.py +0 -0
  153. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex17_launch_repo_based_balanced_webapp.py +0 -0
  154. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex18_deploy_container_webapi.py +0 -0
  155. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex19_deeploy_container_example.py +0 -0
  156. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex20_deeploy_telegram_bot.py +0 -0
  157. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex21_telegram_community_bot.py +0 -0
  158. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex22_deeploy_custom_code.py +0 -0
  159. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/ex23_deploy_worker_app.py +0 -0
  160. {ratio1-3.4.102 → ratio1-3.4.104}/tutorials/video_presentation/1. hello_world.ipynb +0 -0
  161. {ratio1-3.4.102 → ratio1-3.4.104}/winrun.bat +0 -0
  162. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/README.md +0 -0
  163. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/_show_config_check.py +0 -0
  164. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/cstore_check.py +0 -0
  165. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/dauth_check.py +0 -0
  166. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/keys_check.py +0 -0
  167. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/node_info_check.py +0 -0
  168. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/ora_check.py +0 -0
  169. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/ora_intervals.py +0 -0
  170. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/ora_sign_check.py +0 -0
  171. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/owner_check.py +0 -0
  172. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/payload_check.py +0 -0
  173. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/session_check.py +0 -0
  174. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_all_active_jobs_check.py +0 -0
  175. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_auth_check.py +0 -0
  176. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_first_closable_job_check.py +0 -0
  177. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_nodes_licenses.py +0 -0
  178. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_oracles_check.py +0 -0
  179. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/w3_poai_check.py +0 -0
  180. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/whitelist_check.py +0 -0
  181. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/_checks/workload_check.py +0 -0
  182. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/ai4e/delete.py +0 -0
  183. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/ai4e/launcher.py +0 -0
  184. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/dates/check_date.py +0 -0
  185. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/debug/close_pipeline.py +0 -0
  186. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/decentralized/chain_dist_example.py +0 -0
  187. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/decentralized/chain_dist_example_initiator.py +0 -0
  188. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/decentralized/chain_dist_example_worker.py +0 -0
  189. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/deeploy/checker.py +0 -0
  190. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/deeploy/checker2.py +0 -0
  191. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/deeploy/create_request.py +0 -0
  192. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/enc_dec/enc_dec_test.py +0 -0
  193. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/allocate_rewards.py +0 -0
  194. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/balance.py +0 -0
  195. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/eth_sign.py +0 -0
  196. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/info.md +0 -0
  197. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/send.py +0 -0
  198. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/send_many.py +0 -0
  199. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/eth/sign.py +0 -0
  200. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/log.py +0 -0
  201. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/logger/run.py +0 -0
  202. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/lp/lp_checker.py +0 -0
  203. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/multi-enc-dec/multi_test1.py +0 -0
  204. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/multi-enc-dec/multi_test2.py +0 -0
  205. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/netmon/check_netmon.py +0 -0
  206. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/netmon/netmon_data.json +0 -0
  207. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/pipelines/start.py +0 -0
  208. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/pipelines/stop.py +0 -0
  209. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/scripts/monitoring/collect_messages.py +0 -0
  210. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/scripts/monitoring/get_hb_distribution.py +0 -0
  211. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/scripts/monitoring/multithreaded_network_sniffer.py +0 -0
  212. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/sign/simple_payload_checker.py +0 -0
  213. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/sign/test_sign1.py +0 -0
  214. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/sign/test_sign2.py +0 -0
  215. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/test.py +0 -0
  216. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/tokens/get_check.py +0 -0
  217. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/utils/get_documentation.py +0 -0
  218. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/various/attach_example.py +0 -0
  219. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/various/ex1.py +0 -0
  220. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/various/hello.py +0 -0
  221. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/various/remote_exec.py +0 -0
  222. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/various/save_images.py +0 -0
  223. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/wl/wl_add.py +0 -0
  224. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/xarchive/_tutorials/3. simple_real_time_custom_code.py +0 -0
  225. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/xarchive/_tutorials/4. real_time_custom_code_2.py +0 -0
  226. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/xarchive/_tutorials/8. chatbot.py +0 -0
  227. {ratio1-3.4.102 → ratio1-3.4.104}/xperimental/xarchive/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ratio1
3
- Version: 3.4.102
3
+ Version: 3.4.104
4
4
  Summary: `ratio1` or Ration1 SDK is the Python SDK required for client app development for the Ratio1 ecosystem
5
5
  Project-URL: Homepage, https://github.com/Ratio1/ratio1_sdk
6
6
  Project-URL: Bug Tracker, https://github.com/Ratio1/ratio1_sdk/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "ratio1"
7
- version = "3.4.102"
7
+ version = "3.4.104"
8
8
  authors = [
9
9
  { name="Andrei Ionut Damian", email="andrei.damian@ratio1.ai" },
10
10
  { name="Cristan Bleotiu", email="cristian.bleotiu@ratio1.ai" },
@@ -1,4 +1,4 @@
1
- __VER__ = "3.4.102"
1
+ __VER__ = "3.4.104"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  with open("pyproject.toml", "rt") as fd:
@@ -616,8 +616,8 @@ EVM_NET_CONSTANTS = {
616
616
  "0xai_A61eKDV1otIH6uWy3zDlbJNJUWayp1jAsirOuYxztf82", # tr1s-02
617
617
  ],
618
618
  EvmNetConstants.EE_ORACLE_SYNC_USE_R1FS_KEY: False, # Do not use R1FS for oracle sync in testnet.
619
- EvmNetConstants.ORACLE_SYNC_BLOCKCHAIN_PRESENCE_MIN_THRESHOLD_KEY: 0.3,
620
- EvmNetConstants.ORACLE_SYNC_ONLINE_PRESENCE_MIN_THRESHOLD_KEY: 0.4,
619
+ EvmNetConstants.ORACLE_SYNC_BLOCKCHAIN_PRESENCE_MIN_THRESHOLD_KEY: 0.15,
620
+ EvmNetConstants.ORACLE_SYNC_ONLINE_PRESENCE_MIN_THRESHOLD_KEY: 0.2,
621
621
  },
622
622
  EvmNetData.DEVNET: {
623
623
  EvmNetConstants.EE_NET_MON_01_SUPERVISOR_LOG_TIME_KEY: 60, # Log every minute.
@@ -922,9 +922,9 @@ class R1FSEngine:
922
922
  if not os.path.isfile(file_path):
923
923
  raise FileNotFoundError(f"File not found: {file_path}")
924
924
 
925
- # Check file size and throw an error if larger than 2 GB.
925
+ # Check file size and throw an error if larger than 5 GB.
926
926
  file_size = os.path.getsize(file_path)
927
- if file_size > 2 * 1024 * 1024 * 1024:
927
+ if file_size > 5 * 1024 * 1024 * 1024:
928
928
  raise ValueError(f"File {file_path} is too large ({file_size} bytes). Maximum allowed size is 2 GB.")
929
929
 
930
930
  key = self._hash_secret(secret) # mandatory passphrase
@@ -1522,6 +1522,589 @@ class R1FSEngine:
1522
1522
  result = False
1523
1523
  return result
1524
1524
 
1525
+
1526
+ ########## START DELETE METHODS ##########
1527
+ if True:
1528
+ def is_pinned(self, cid: str, show_logs: bool = False) -> bool:
1529
+ """
1530
+ Check if a CID is pinned locally.
1531
+
1532
+ Parameters
1533
+ ----------
1534
+ cid : str
1535
+ The CID to check.
1536
+
1537
+ show_logs : bool, optional
1538
+ Whether to show logs. Default is False.
1539
+
1540
+ Returns
1541
+ -------
1542
+ bool
1543
+ True if the CID is pinned, False otherwise.
1544
+
1545
+ Examples
1546
+ --------
1547
+ >>> if engine.is_pinned("QmHash123..."):
1548
+ >>> print("File is pinned")
1549
+ """
1550
+ try:
1551
+ output = self.__run_command(
1552
+ ["ipfs", "pin", "ls", "--type=recursive", cid],
1553
+ raise_on_error=False,
1554
+ show_logs=False
1555
+ )
1556
+ is_pinned = cid in output
1557
+ if show_logs:
1558
+ self.Pd(f"CID {cid} pinned: {is_pinned}")
1559
+ return is_pinned
1560
+ except Exception as e:
1561
+ if show_logs:
1562
+ self.Pd(f"Error checking if CID {cid} is pinned: {e}")
1563
+ return False
1564
+
1565
+ def unpin_file(
1566
+ self,
1567
+ cid: str,
1568
+ unpin_remote: bool = True,
1569
+ show_logs: bool = True,
1570
+ raise_on_error: bool = False
1571
+ ) -> bool:
1572
+ """
1573
+ Unpin a file from R1FS locally and optionally on the relay.
1574
+ This marks the file for garbage collection but does not immediately delete it.
1575
+
1576
+ Parameters
1577
+ ----------
1578
+ cid : str
1579
+ The CID to unpin.
1580
+
1581
+ unpin_remote : bool, optional
1582
+ Whether to also unpin from the relay. Default is True.
1583
+
1584
+ show_logs : bool, optional
1585
+ Whether to show logs. Default is True.
1586
+
1587
+ raise_on_error : bool, optional
1588
+ If True, raise an Exception on errors. Otherwise logs them. Default is False.
1589
+
1590
+ Returns
1591
+ -------
1592
+ bool
1593
+ True if unpinning was successful, False otherwise.
1594
+
1595
+ Examples
1596
+ --------
1597
+ >>> # Unpin locally and on relay
1598
+ >>> engine.unpin_file("QmHash123...")
1599
+
1600
+ >>> # Unpin only locally
1601
+ >>> engine.unpin_file("QmHash123...", unpin_remote=False)
1602
+ """
1603
+ if cid in [None, ""]:
1604
+ msg = "CID parameter cannot be None or empty"
1605
+ if raise_on_error:
1606
+ raise ValueError(msg)
1607
+ else:
1608
+ if show_logs:
1609
+ self.P(msg, color='r')
1610
+ return False
1611
+
1612
+ success = True
1613
+
1614
+ try:
1615
+ # First, unpin locally
1616
+ result = self.__run_command(
1617
+ ["ipfs", "pin", "rm", cid],
1618
+ raise_on_error=raise_on_error,
1619
+ show_logs=False
1620
+ )
1621
+
1622
+ if show_logs:
1623
+ self.Pd(f"Unpinned CID locally: {cid}")
1624
+
1625
+ except Exception as e:
1626
+ msg = f"Error unpinning CID {cid} locally: {e}"
1627
+ success = False
1628
+ if raise_on_error:
1629
+ raise RuntimeError(msg)
1630
+ else:
1631
+ if show_logs:
1632
+ self.P(msg, color='r')
1633
+ return False
1634
+
1635
+ # Then, notify the relay to unpin (mirrors add_file behavior)
1636
+ if unpin_remote and self.__ipfs_relay_api is not None:
1637
+ try:
1638
+ request_url = f"{self.__ipfs_relay_api}/api/v0/pin/rm?arg={cid}"
1639
+ response = requests.post(
1640
+ request_url,
1641
+ auth=HTTPBasicAuth(self.__ipfs_api_key_username, self.__ipfs_api_key_password),
1642
+ verify=self.__ipfs_certificate_path
1643
+ )
1644
+
1645
+ if response.status_code == 200:
1646
+ if show_logs:
1647
+ self.Pd(f"Relay successfully notified to unpin CID={cid}")
1648
+ else:
1649
+ msg = f"Failed to notify relay to unpin CID {cid}: {response.text}"
1650
+ if raise_on_error:
1651
+ raise RuntimeError(msg)
1652
+ else:
1653
+ if show_logs:
1654
+ self.P(msg, color='r')
1655
+ success = False
1656
+ #end if response status code
1657
+ except requests.RequestException as e:
1658
+ msg = f"Error notifying relay to unpin CID {cid}: {e}"
1659
+ if raise_on_error:
1660
+ raise RuntimeError(msg)
1661
+ else:
1662
+ if show_logs:
1663
+ self.P(msg, color='r')
1664
+ success = False
1665
+ #end try
1666
+ #end if relay API exists
1667
+
1668
+ # Remove from tracking dicts if present
1669
+ if success:
1670
+ self.__uploaded_files.pop(cid, None)
1671
+ self.__downloaded_files.pop(cid, None)
1672
+
1673
+ return success
1674
+
1675
+ def delete_file(
1676
+ self,
1677
+ cid: str,
1678
+ unpin_remote: bool = True,
1679
+ run_gc: bool = False,
1680
+ cleanup_local_files: bool = False,
1681
+ show_logs: bool = True,
1682
+ raise_on_error: bool = False
1683
+ ) -> bool:
1684
+ """
1685
+ Delete a file from R1FS by unpinning it locally and optionally on the relay,
1686
+ then optionally running garbage collection.
1687
+
1688
+ Note: Unpinning removes the file from your local node and (optionally) the relay.
1689
+ However, if other nodes have pinned this content, it may remain accessible on the network.
1690
+
1691
+ Parameters
1692
+ ----------
1693
+ cid : str
1694
+ The CID to delete.
1695
+
1696
+ unpin_remote : bool, optional
1697
+ Whether to also unpin from the relay. Default is True.
1698
+ Set to False if you only want to free local storage.
1699
+
1700
+ run_gc : bool, optional
1701
+ Whether to run garbage collection immediately after unpinning.
1702
+ Default is False (GC runs automatically with --enable-gc flag on daemon).
1703
+ Set to True for immediate disk space reclamation.
1704
+
1705
+ cleanup_local_files : bool, optional
1706
+ Whether to also remove local downloaded files from the downloads directory.
1707
+ Default is False.
1708
+
1709
+ show_logs : bool, optional
1710
+ Whether to show logs. Default is True.
1711
+
1712
+ raise_on_error : bool, optional
1713
+ If True, raise an Exception on errors. Otherwise logs them. Default is False.
1714
+
1715
+ Returns
1716
+ -------
1717
+ bool
1718
+ True if deletion was successful, False otherwise.
1719
+
1720
+ Examples
1721
+ --------
1722
+ >>> # Simple delete (unpin locally and on relay)
1723
+ >>> engine.delete_file("QmHash123...")
1724
+
1725
+ >>> # Delete with immediate garbage collection
1726
+ >>> engine.delete_file("QmHash123...", run_gc=True)
1727
+
1728
+ >>> # Delete only locally, keep on relay
1729
+ >>> engine.delete_file("QmHash123...", unpin_remote=False)
1730
+
1731
+ >>> # Full cleanup: unpin everywhere, GC, and remove local files
1732
+ >>> engine.delete_file("QmHash123...", run_gc=True, cleanup_local_files=True)
1733
+ """
1734
+ if cid in [None, ""]:
1735
+ msg = "CID parameter cannot be None or empty"
1736
+ if raise_on_error:
1737
+ raise ValueError(msg)
1738
+ else:
1739
+ if show_logs:
1740
+ self.P(msg, color='r')
1741
+ return False
1742
+
1743
+ try:
1744
+ # Unpin the file (locally and optionally on relay)
1745
+ success = self.unpin_file(
1746
+ cid=cid,
1747
+ unpin_remote=unpin_remote,
1748
+ show_logs=show_logs,
1749
+ raise_on_error=raise_on_error
1750
+ )
1751
+
1752
+ if not success:
1753
+ return False
1754
+
1755
+ # Optional: clean up local downloaded files
1756
+ if cleanup_local_files:
1757
+ local_folder = os.path.join(self.__downloads_dir, cid)
1758
+ if os.path.exists(local_folder):
1759
+ try:
1760
+ if os.path.isdir(local_folder):
1761
+ shutil.rmtree(local_folder)
1762
+ else:
1763
+ os.remove(local_folder)
1764
+ if show_logs:
1765
+ self.Pd(f"Removed local files for CID {cid}")
1766
+ except Exception as e:
1767
+ msg = f"Error removing local files for CID {cid}: {e}"
1768
+ if show_logs:
1769
+ self.P(msg, color='r')
1770
+ # Don't fail the whole operation if local cleanup fails
1771
+
1772
+ # Optional: run garbage collection immediately
1773
+ if run_gc:
1774
+ if show_logs:
1775
+ self.Pd("Running garbage collection...")
1776
+ try:
1777
+ gc_result = self.__run_command(
1778
+ ["ipfs", "repo", "gc"],
1779
+ raise_on_error=False,
1780
+ show_logs=False # GC output can be very verbose
1781
+ )
1782
+ if show_logs:
1783
+ self.P(f"Deleted file {cid} and ran garbage collection", color='g')
1784
+ except Exception as e:
1785
+ msg = f"Error running garbage collection: {e}"
1786
+ if show_logs:
1787
+ self.P(msg, color='r')
1788
+ # Don't fail if GC fails - the unpin was successful
1789
+ else:
1790
+ if show_logs:
1791
+ location = "local + relay" if unpin_remote else "local only"
1792
+ self.P(f"Unpinned file {cid} ({location})", color='g')
1793
+
1794
+ return True
1795
+
1796
+ except Exception as e:
1797
+ msg = f"Error deleting file {cid}: {e}"
1798
+ if raise_on_error:
1799
+ raise RuntimeError(msg)
1800
+ else:
1801
+ if show_logs:
1802
+ self.P(msg, color='r')
1803
+ return False
1804
+
1805
+ def delete_files(
1806
+ self,
1807
+ cids: list,
1808
+ unpin_remote: bool = True,
1809
+ run_gc_after_all: bool = True,
1810
+ cleanup_local_files: bool = False,
1811
+ show_logs: bool = True,
1812
+ raise_on_error: bool = False,
1813
+ continue_on_error: bool = True
1814
+ ) -> dict:
1815
+ """
1816
+ Delete multiple files from R1FS in bulk.
1817
+ More efficient than calling delete_file repeatedly as it can run GC once at the end.
1818
+
1819
+ Parameters
1820
+ ----------
1821
+ cids : list
1822
+ List of CIDs to delete.
1823
+
1824
+ unpin_remote : bool, optional
1825
+ Whether to also unpin from the relay. Default is True.
1826
+
1827
+ run_gc_after_all : bool, optional
1828
+ Whether to run garbage collection once after all deletions.
1829
+ Default is True. More efficient than running GC for each file.
1830
+
1831
+ cleanup_local_files : bool, optional
1832
+ Whether to also remove local downloaded files. Default is False.
1833
+
1834
+ show_logs : bool, optional
1835
+ Whether to show logs. Default is True.
1836
+
1837
+ raise_on_error : bool, optional
1838
+ If True, raise an Exception on first error. Default is False.
1839
+
1840
+ continue_on_error : bool, optional
1841
+ Whether to continue deleting remaining files if one fails.
1842
+ Only used if raise_on_error is False. Default is True.
1843
+
1844
+ Returns
1845
+ -------
1846
+ dict
1847
+ Dictionary with keys:
1848
+ - 'success': list of successfully deleted CIDs
1849
+ - 'failed': list of CIDs that failed to delete
1850
+ - 'total': total number of CIDs processed
1851
+ - 'success_count': number of successful deletions
1852
+ - 'failed_count': number of failed deletions
1853
+
1854
+ Examples
1855
+ --------
1856
+ >>> # Delete multiple files efficiently
1857
+ >>> cids = ["QmHash1...", "QmHash2...", "QmHash3..."]
1858
+ >>> result = engine.delete_files(cids)
1859
+ >>> print(f"Deleted {result['success_count']} of {result['total']} files")
1860
+
1861
+ >>> # Delete locally only, no GC
1862
+ >>> result = engine.delete_files(cids, unpin_remote=False, run_gc_after_all=False)
1863
+
1864
+ >>> # Full cleanup
1865
+ >>> result = engine.delete_files(
1866
+ >>> cids,
1867
+ >>> cleanup_local_files=True,
1868
+ >>> run_gc_after_all=True
1869
+ >>> )
1870
+ """
1871
+ if not isinstance(cids, list):
1872
+ msg = "cids parameter must be a list"
1873
+ if raise_on_error:
1874
+ raise ValueError(msg)
1875
+ else:
1876
+ if show_logs:
1877
+ self.P(msg, color='r')
1878
+ return {
1879
+ 'success': [],
1880
+ 'failed': cids if isinstance(cids, list) else [cids],
1881
+ 'total': 0,
1882
+ 'success_count': 0,
1883
+ 'failed_count': 0
1884
+ }
1885
+
1886
+ if len(cids) == 0:
1887
+ if show_logs:
1888
+ self.Pd("No CIDs provided for deletion")
1889
+ return {
1890
+ 'success': [],
1891
+ 'failed': [],
1892
+ 'total': 0,
1893
+ 'success_count': 0,
1894
+ 'failed_count': 0
1895
+ }
1896
+
1897
+ if show_logs:
1898
+ self.P(f"Deleting {len(cids)} files from R1FS...", color='m')
1899
+
1900
+ success_list = []
1901
+ failed_list = []
1902
+
1903
+ for i, cid in enumerate(cids):
1904
+ if show_logs:
1905
+ self.Pd(f"Processing {i+1}/{len(cids)}: {cid}")
1906
+
1907
+ try:
1908
+ # Delete without running GC for each file (we'll do it once at the end)
1909
+ result = self.delete_file(
1910
+ cid=cid,
1911
+ unpin_remote=unpin_remote,
1912
+ run_gc=False, # Don't GC per file
1913
+ cleanup_local_files=cleanup_local_files,
1914
+ show_logs=False, # Reduce log spam
1915
+ raise_on_error=raise_on_error
1916
+ )
1917
+
1918
+ if result:
1919
+ success_list.append(cid)
1920
+ else:
1921
+ failed_list.append(cid)
1922
+ if not continue_on_error:
1923
+ break
1924
+ except Exception as e:
1925
+ failed_list.append(cid)
1926
+ if show_logs:
1927
+ self.P(f"Error deleting CID {cid}: {e}", color='r')
1928
+ if raise_on_error:
1929
+ raise
1930
+ if not continue_on_error:
1931
+ break
1932
+
1933
+ # Run garbage collection once at the end (more efficient)
1934
+ if run_gc_after_all and len(success_list) > 0:
1935
+ if show_logs:
1936
+ self.P("Running garbage collection for all deleted files...", color='m')
1937
+ try:
1938
+ gc_result = self.__run_command(
1939
+ ["ipfs", "repo", "gc"],
1940
+ raise_on_error=False,
1941
+ show_logs=False
1942
+ )
1943
+ if show_logs:
1944
+ self.Pd("Garbage collection completed")
1945
+ except Exception as e:
1946
+ if show_logs:
1947
+ self.P(f"Warning: Garbage collection failed: {e}", color='r')
1948
+ # Don't fail the whole operation if GC fails
1949
+
1950
+ result = {
1951
+ 'success': success_list,
1952
+ 'failed': failed_list,
1953
+ 'total': len(cids),
1954
+ 'success_count': len(success_list),
1955
+ 'failed_count': len(failed_list)
1956
+ }
1957
+
1958
+ if show_logs:
1959
+ location = "local + relay" if unpin_remote else "local only"
1960
+ self.P(
1961
+ f"Bulk delete completed: {result['success_count']}/{result['total']} succeeded ({location})",
1962
+ color='g' if result['failed_count'] == 0 else 'y'
1963
+ )
1964
+ if result['failed_count'] > 0:
1965
+ self.P(f"Failed to delete {result['failed_count']} files", color='r')
1966
+
1967
+ return result
1968
+
1969
+ def garbage_collect(self, show_logs: bool = True, raise_on_error: bool = False) -> bool:
1970
+ """
1971
+ Manually run IPFS garbage collection to reclaim disk space from unpinned files.
1972
+
1973
+ Note: The IPFS daemon runs with --enable-gc flag, so GC happens automatically.
1974
+ This method is useful for immediate disk space reclamation.
1975
+
1976
+ Parameters
1977
+ ----------
1978
+ show_logs : bool, optional
1979
+ Whether to show logs. Default is True.
1980
+
1981
+ raise_on_error : bool, optional
1982
+ If True, raise an Exception on errors. Default is False.
1983
+
1984
+ Returns
1985
+ -------
1986
+ bool
1987
+ True if garbage collection succeeded, False otherwise.
1988
+
1989
+ Examples
1990
+ --------
1991
+ >>> # Run garbage collection manually
1992
+ >>> engine.garbage_collect()
1993
+ """
1994
+ try:
1995
+ if show_logs:
1996
+ self.P("Running IPFS garbage collection...", color='m')
1997
+
1998
+ result = self.__run_command(
1999
+ ["ipfs", "repo", "gc"],
2000
+ raise_on_error=raise_on_error,
2001
+ show_logs=False # GC output can be very verbose
2002
+ )
2003
+
2004
+ if show_logs:
2005
+ # Count lines in output to show how many blocks were freed
2006
+ lines = result.strip().split('\n') if result else []
2007
+ blocks_removed = len([l for l in lines if l.strip()])
2008
+ self.P(f"Garbage collection completed (~{blocks_removed} blocks processed)", color='g')
2009
+
2010
+ return True
2011
+
2012
+ except Exception as e:
2013
+ msg = f"Error running garbage collection: {e}"
2014
+ if raise_on_error:
2015
+ raise RuntimeError(msg)
2016
+ else:
2017
+ if show_logs:
2018
+ self.P(msg, color='r')
2019
+ return False
2020
+
2021
+ def cleanup_downloads(
2022
+ self,
2023
+ cid: str = None,
2024
+ show_logs: bool = True
2025
+ ) -> int:
2026
+ """
2027
+ Clean up downloaded files from the local downloads directory.
2028
+ This does NOT unpin files from IPFS, only removes local file copies.
2029
+
2030
+ Parameters
2031
+ ----------
2032
+ cid : str, optional
2033
+ Specific CID to clean up. If None, cleans all downloads.
2034
+
2035
+ show_logs : bool, optional
2036
+ Whether to show logs. Default is True.
2037
+
2038
+ Returns
2039
+ -------
2040
+ int
2041
+ Number of items cleaned up.
2042
+
2043
+ Examples
2044
+ --------
2045
+ >>> # Clean up all downloaded files
2046
+ >>> count = engine.cleanup_downloads()
2047
+ >>> print(f"Cleaned up {count} files")
2048
+
2049
+ >>> # Clean up specific CID's downloads
2050
+ >>> engine.cleanup_downloads(cid="QmHash123...")
2051
+ """
2052
+ count = 0
2053
+
2054
+ try:
2055
+ if not os.path.exists(self.__downloads_dir):
2056
+ if show_logs:
2057
+ self.Pd(f"Downloads directory does not exist: {self.__downloads_dir}")
2058
+ return 0
2059
+
2060
+ if cid is not None:
2061
+ # Clean up specific CID
2062
+ target_path = os.path.join(self.__downloads_dir, cid)
2063
+ if os.path.exists(target_path):
2064
+ try:
2065
+ if os.path.isdir(target_path):
2066
+ shutil.rmtree(target_path)
2067
+ else:
2068
+ os.remove(target_path)
2069
+ count = 1
2070
+ if show_logs:
2071
+ self.P(f"Cleaned up local files for CID: {cid}", color='g')
2072
+ # Remove from tracking dict
2073
+ self.__downloaded_files.pop(cid, None)
2074
+ except Exception as e:
2075
+ if show_logs:
2076
+ self.P(f"Error cleaning up CID {cid}: {e}", color='r')
2077
+ else:
2078
+ if show_logs:
2079
+ self.Pd(f"No local files found for CID: {cid}")
2080
+ else:
2081
+ # Clean up all downloads
2082
+ for item in os.listdir(self.__downloads_dir):
2083
+ item_path = os.path.join(self.__downloads_dir, item)
2084
+ try:
2085
+ if os.path.isdir(item_path):
2086
+ shutil.rmtree(item_path)
2087
+ else:
2088
+ os.remove(item_path)
2089
+ count += 1
2090
+ except Exception as e:
2091
+ if show_logs:
2092
+ self.P(f"Error removing {item_path}: {e}", color='r')
2093
+
2094
+ if show_logs:
2095
+ self.P(f"Cleaned up {count} items from downloads directory", color='g')
2096
+
2097
+ # Clear all tracking
2098
+ self.__downloaded_files.clear()
2099
+
2100
+ except Exception as e:
2101
+ if show_logs:
2102
+ self.P(f"Error during cleanup: {e}", color='r')
2103
+
2104
+ return count
2105
+
2106
+ ######## END DELETE METHODS #########
2107
+
1525
2108
  def calculate_file_cid(
1526
2109
  self,
1527
2110
  file_path: str,