warprec 2.2.1__tar.gz → 2.2.2__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 (289) hide show
  1. {warprec-2.2.1 → warprec-2.2.2}/PKG-INFO +1 -1
  2. {warprec-2.2.1 → warprec-2.2.2}/pyproject.toml +1 -1
  3. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/common.py +60 -1
  4. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/swarm.py +28 -3
  5. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/train.py +23 -2
  6. warprec-2.2.2/warprec/recommenders/trainer/dashboard_callbacks.py +176 -0
  7. warprec-2.2.2/warprec/recommenders/trainer/emissions.py +507 -0
  8. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/objectives.py +1 -1
  9. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/trainer.py +18 -3
  10. warprec-2.2.1/warprec/recommenders/trainer/dashboard_callbacks.py +0 -239
  11. {warprec-2.2.1 → warprec-2.2.2}/LICENSE +0 -0
  12. {warprec-2.2.1 → warprec-2.2.2}/README.md +0 -0
  13. {warprec-2.2.1 → warprec-2.2.2}/warprec/__init__.py +0 -0
  14. {warprec-2.2.1 → warprec-2.2.2}/warprec/common/__init__.py +0 -0
  15. {warprec-2.2.1 → warprec-2.2.2}/warprec/common/initialize.py +0 -0
  16. {warprec-2.2.1 → warprec-2.2.2}/warprec/common/run_state.py +0 -0
  17. {warprec-2.2.1 → warprec-2.2.2}/warprec/common/std_logs.py +0 -0
  18. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/__init__.py +0 -0
  19. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/dataset.py +0 -0
  20. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/__init__.py +0 -0
  21. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/common.py +0 -0
  22. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/context.py +0 -0
  23. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/interactions.py +0 -0
  24. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/knowledge.py +0 -0
  25. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/multimodal.py +0 -0
  26. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/sessions.py +0 -0
  27. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/train_structures/__init__.py +0 -0
  28. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
  29. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
  30. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/train_structures/session_structures.py +0 -0
  31. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/entities/transactions.py +0 -0
  32. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/eval_loaders.py +0 -0
  33. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/filtering.py +0 -0
  34. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/ranking.py +0 -0
  35. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/reader/__init__.py +0 -0
  36. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/reader/azureblob_reader.py +0 -0
  37. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/reader/base_reader.py +0 -0
  38. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/reader/local_reader.py +0 -0
  39. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/schema.py +0 -0
  40. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/splitting/__init__.py +0 -0
  41. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/splitting/splitter.py +0 -0
  42. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/splitting/strategies.py +0 -0
  43. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/stash.py +0 -0
  44. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/writer/__init__.py +0 -0
  45. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/writer/azureblob_writer.py +0 -0
  46. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/writer/base_writer.py +0 -0
  47. {warprec-2.2.1 → warprec-2.2.2}/warprec/data/writer/local_writer.py +0 -0
  48. {warprec-2.2.1 → warprec-2.2.2}/warprec/errors.py +0 -0
  49. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/__init__.py +0 -0
  50. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/evaluator.py +0 -0
  51. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/factory.py +0 -0
  52. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/__init__.py +0 -0
  53. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
  54. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
  55. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
  56. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
  57. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
  58. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
  59. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
  60. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/map.py +0 -0
  61. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
  62. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
  63. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
  64. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
  65. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
  66. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/base_metric.py +0 -0
  67. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/__init__.py +0 -0
  68. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/aclt.py +0 -0
  69. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/aplt.py +0 -0
  70. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/arp.py +0 -0
  71. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
  72. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
  73. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
  74. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
  75. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
  76. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
  77. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
  78. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
  79. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
  80. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/base.py +0 -0
  81. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
  82. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/recall.py +0 -0
  83. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
  84. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
  85. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
  86. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
  87. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
  88. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
  89. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
  90. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
  91. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
  92. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
  93. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/reo.py +0 -0
  94. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
  95. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
  96. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
  97. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
  98. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
  99. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
  100. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
  101. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/efd.py +0 -0
  102. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/epc.py +0 -0
  103. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
  104. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/rating/__init__.py +0 -0
  105. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/rating/mae.py +0 -0
  106. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/rating/mse.py +0 -0
  107. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/metrics/rating/rmse.py +0 -0
  108. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/propensity.py +0 -0
  109. {warprec-2.2.1 → warprec-2.2.2}/warprec/evaluation/statistical_significance.py +0 -0
  110. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/__init__.py +0 -0
  111. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/design.py +0 -0
  112. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/estimate.py +0 -0
  113. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/eval.py +0 -0
  114. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/remotes/__init__.py +0 -0
  115. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/remotes/data.py +0 -0
  116. {warprec-2.2.1 → warprec-2.2.2}/warprec/pipelines/remotes/ml.py +0 -0
  117. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/__init__.py +0 -0
  118. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/base_recommender.py +0 -0
  119. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/callbacks.py +0 -0
  120. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
  121. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
  122. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
  123. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
  124. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
  125. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
  126. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
  127. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
  128. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
  129. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
  130. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
  131. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
  132. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
  133. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
  134. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
  135. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
  136. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
  137. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
  138. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
  139. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
  140. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
  141. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
  142. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
  143. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
  144. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
  145. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
  146. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
  147. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
  148. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
  149. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
  150. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
  151. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
  152. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
  153. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
  154. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
  155. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
  156. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
  157. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
  158. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
  159. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
  160. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
  161. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
  162. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
  163. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
  164. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
  165. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
  166. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
  167. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
  168. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
  169. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
  170. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
  171. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
  172. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
  173. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
  174. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
  175. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
  176. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
  177. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
  178. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
  179. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
  180. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
  181. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
  182. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
  183. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
  184. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
  185. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
  186. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
  187. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
  188. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
  189. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
  190. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
  191. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
  192. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
  193. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
  194. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
  195. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
  196. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/layers.py +0 -0
  197. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/losses.py +0 -0
  198. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
  199. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
  200. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
  201. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
  202. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
  203. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
  204. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
  205. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
  206. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
  207. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/optimizer_wrapper.py +0 -0
  208. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/proxy.py +0 -0
  209. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/reranking/__init__.py +0 -0
  210. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/reranking/base.py +0 -0
  211. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/reranking/calibration.py +0 -0
  212. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/reranking/factory.py +0 -0
  213. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/reranking/mmr.py +0 -0
  214. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
  215. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
  216. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
  217. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/caser.py +0 -0
  218. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
  219. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/core.py +0 -0
  220. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
  221. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
  222. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
  223. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
  224. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
  225. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
  226. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
  227. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/narm.py +0 -0
  228. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
  229. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/stan.py +0 -0
  230. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/similarities.py +0 -0
  231. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/__init__.py +0 -0
  232. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
  233. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/runtime.py +0 -0
  234. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
  235. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
  236. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
  237. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
  238. {warprec-2.2.1 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
  239. {warprec-2.2.1 → warprec-2.2.2}/warprec/run.py +0 -0
  240. {warprec-2.2.1 → warprec-2.2.2}/warprec/serve.py +0 -0
  241. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/__init__.py +0 -0
  242. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/api.py +0 -0
  243. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/app.py +0 -0
  244. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/catalogue.py +0 -0
  245. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/context.py +0 -0
  246. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/deployments.py +0 -0
  247. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/errors.py +0 -0
  248. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/mcp.py +0 -0
  249. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/payload.py +0 -0
  250. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/schemas.py +0 -0
  251. {warprec-2.2.1 → warprec-2.2.2}/warprec/serving/servable.py +0 -0
  252. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/__init__.py +0 -0
  253. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/callback.py +0 -0
  254. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/__init__.py +0 -0
  255. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/common.py +0 -0
  256. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/config.py +0 -0
  257. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/dashboard_configuration.py +0 -0
  258. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/estimate_configuration.py +0 -0
  259. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/evaluation_configuration.py +0 -0
  260. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/general_configuration.py +0 -0
  261. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/model_configuration.py +0 -0
  262. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/reader_configuration.py +0 -0
  263. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
  264. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
  265. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
  266. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
  267. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
  268. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
  269. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
  270. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
  271. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
  272. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
  273. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
  274. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
  275. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
  276. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
  277. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/rerank_configuration.py +0 -0
  278. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/run_configuration.py +0 -0
  279. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/search_space_wrapper.py +0 -0
  280. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/serving_configuration.py +0 -0
  281. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/splitter_configuration.py +0 -0
  282. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/training_configuration.py +0 -0
  283. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/config/writer_configuration.py +0 -0
  284. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/enums.py +0 -0
  285. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/helpers.py +0 -0
  286. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/logger/__init__.py +0 -0
  287. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/logger/logger.py +0 -0
  288. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/pause.py +0 -0
  289. {warprec-2.2.1 → warprec-2.2.2}/warprec/utils/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: warprec
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: Unifying Academic Rigor and Industrial Scale for Responsible, Reproducible, and Efficient Recommendation
5
5
  Author: MarcoWV
6
6
  Author-email: marco.avolio@wideverse.com
@@ -61,7 +61,7 @@ warprec = "warprec.run:main"
61
61
  "warprec.serve" = "warprec.serve:main"
62
62
 
63
63
  [tool.poetry]
64
- version = "2.2.1"
64
+ version = "2.2.2"
65
65
 
66
66
  [tool.poetry.dependencies]
67
67
  python = "^3.12"
@@ -1,6 +1,7 @@
1
1
  import time
2
+ from contextlib import AbstractContextManager, nullcontext
2
3
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Optional, Tuple
4
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
4
5
 
5
6
  import ray
6
7
 
@@ -31,6 +32,10 @@ from warprec.pipelines.remotes import remote_data_preparation
31
32
  from warprec.utils.enums import ResumeMode
32
33
  from warprec.utils.logger import logger
33
34
 
35
+ if TYPE_CHECKING:
36
+ # The dashboard extra is optional
37
+ from warprec.recommenders.trainer.emissions import EmissionsSettings
38
+
34
39
 
35
40
  @dataclass
36
41
  class PipelineContext:
@@ -205,6 +210,60 @@ def bootstrap_pipeline(path: str, pipeline: str, start_message: str) -> Pipeline
205
210
  )
206
211
 
207
212
 
213
+ def data_preparation_seconds(
214
+ started_at: float, emissions: Optional["EmissionsSettings"]
215
+ ) -> float:
216
+ """How long a run took to prepare its data, up to now.
217
+
218
+ The run waits for its CodeCarbon trackers to measure before it prepares the
219
+ data; that wait is not part of the preparation and is left out.
220
+
221
+ Args:
222
+ started_at (float): When the run started, as 'time.time()'.
223
+ emissions (Optional[EmissionsSettings]): The run's CodeCarbon
224
+ measurement, or None when the run is not measured.
225
+
226
+ Returns:
227
+ float: The seconds since the run started, without the wait.
228
+ """
229
+ waited = emissions.startup_seconds if emissions is not None else 0.0
230
+ return time.time() - started_at - waited
231
+
232
+
233
+ def measure_emissions(context: PipelineContext) -> AbstractContextManager[Any]:
234
+ """The CodeCarbon measurement of a run, when the configuration asks for one.
235
+
236
+ Entered as the run starts its work, before the data is prepared, and left
237
+ when it ends, whether it completes, pauses or fails, so that the data
238
+ preparation, the searches, the retraining and the test evaluation are all
239
+ covered.
240
+
241
+ Args:
242
+ context (PipelineContext): The context produced by the bootstrap.
243
+
244
+ Returns:
245
+ AbstractContextManager[Any]: An 'EmissionsRecorder', which gives the
246
+ 'EmissionsSettings' the trainers take, or a context giving None
247
+ when CodeCarbon is disabled or not installed.
248
+ """
249
+ codecarbon = context.config.dashboard.codecarbon
250
+ if not codecarbon.enabled:
251
+ return nullcontext()
252
+ try:
253
+ # pylint: disable = import-outside-toplevel # the dashboard extra is optional
254
+ from warprec.recommenders.trainer.emissions import EmissionsRecorder
255
+ except ImportError:
256
+ # The trainers say the dashboards are not available
257
+ return nullcontext()
258
+ return EmissionsRecorder(
259
+ tracking_mode=codecarbon.tracking_mode,
260
+ save_to_api=codecarbon.save_to_api,
261
+ save_to_file=codecarbon.save_to_file,
262
+ output_dir=context.config.get_storage_path(),
263
+ project_name=context.run_name,
264
+ )
265
+
266
+
208
267
  def prepare_datasets(
209
268
  context: PipelineContext,
210
269
  ) -> Tuple[Dataset, Optional[Dataset], Optional[List[Dataset]]]:
@@ -1,5 +1,5 @@
1
1
  import time
2
- from typing import Callable, Dict, Any, Optional, List, Tuple
2
+ from typing import TYPE_CHECKING, Callable, Dict, Any, Optional, List, Tuple
3
3
 
4
4
  import ray
5
5
  from ray import tune
@@ -12,7 +12,10 @@ from warprec.common import (
12
12
  from warprec.data.writer import WriterFactory
13
13
  from warprec.data import Dataset
14
14
  from warprec.pipelines.common import (
15
+ PipelineContext,
15
16
  bootstrap_pipeline,
17
+ data_preparation_seconds,
18
+ measure_emissions,
16
19
  prepare_datasets,
17
20
  report_statistical_significance,
18
21
  write_model_outputs,
@@ -32,6 +35,9 @@ from warprec.utils.pause import PauseController
32
35
  from warprec.utils.helpers import model_param_from_dict
33
36
  from warprec.utils.logger import logger
34
37
 
38
+ if TYPE_CHECKING:
39
+ from warprec.recommenders.trainer.emissions import EmissionsSettings
40
+
35
41
  # The hooks Ray Tune calls on a callback while a sweep runs
36
42
  TUNE_HOOKS = (
37
43
  "setup",
@@ -202,6 +208,20 @@ def swarm_pipeline(path: str):
202
208
  "WARNING: Swarm pipeline is experimental. Please submit bug reports via GitHub Issues."
203
209
  )
204
210
  context = bootstrap_pipeline(path, "swarm", "Start experiment swarming.")
211
+ with measure_emissions(context) as emissions:
212
+ _swarm_models(context, emissions)
213
+
214
+
215
+ def _swarm_models(
216
+ context: PipelineContext, emissions: Optional["EmissionsSettings"]
217
+ ) -> None:
218
+ """Prepare the data, then run every model at once on the cluster.
219
+
220
+ Args:
221
+ context (PipelineContext): The context produced by the bootstrap.
222
+ emissions (Optional[EmissionsSettings]): The run's CodeCarbon
223
+ measurement, or None when the run is not measured.
224
+ """
205
225
  config = context.config
206
226
 
207
227
  # Build the datasets on the cluster and persist the splits if asked to
@@ -217,7 +237,7 @@ def swarm_pipeline(path: str):
217
237
  if requires_stat_significance:
218
238
  model_results: Dict[str, Any] = {}
219
239
 
220
- data_preparation_time = time.time() - context.started_at
240
+ data_preparation_time = data_preparation_seconds(context.started_at, emissions)
221
241
  logger.positive(
222
242
  f"Data preparation completed in {data_preparation_time:.2f} seconds."
223
243
  )
@@ -283,6 +303,7 @@ def swarm_pipeline(path: str):
283
303
  run_name=context.run_name,
284
304
  writer_timestamp=context.state.writer_timestamp,
285
305
  resumable=model_name in resumable_models,
306
+ emissions=emissions,
286
307
  ) # type: ignore[call-arg]
287
308
  futures.append(future)
288
309
 
@@ -410,7 +431,7 @@ def swarm_pipeline(path: str):
410
431
 
411
432
 
412
433
  @ray.remote(num_cpus=0.05) # Zero-Resource Orchestrator
413
- def remote_model_pipeline(
434
+ def remote_model_pipeline( # pylint: disable = too-many-arguments, too-many-positional-arguments
414
435
  model_name: str,
415
436
  config: TrainConfiguration,
416
437
  main_dataset: Dataset,
@@ -421,6 +442,7 @@ def remote_model_pipeline(
421
442
  run_name: Optional[str] = None,
422
443
  writer_timestamp: Optional[str] = None,
423
444
  resumable: bool = False,
445
+ emissions: Optional["EmissionsSettings"] = None,
424
446
  ) -> Tuple[str, Optional[Recommender], Dict, Dict, Dict, Dict]:
425
447
  """Orchestrates the entire lifecycle of a single model in parallel.
426
448
 
@@ -441,6 +463,8 @@ def remote_model_pipeline(
441
463
  file names of this run.
442
464
  resumable (bool): Whether the run state allows restoring the Ray Tune
443
465
  experiment this model left behind.
466
+ emissions (Optional[EmissionsSettings]): The run's CodeCarbon
467
+ measurement, or None when the run is not measured.
444
468
 
445
469
  Returns:
446
470
  Tuple[str, Optional[Recommender], Dict, Dict, Dict, Dict]: A tuple containing:
@@ -468,6 +492,7 @@ def remote_model_pipeline(
468
492
  run_name=run_name,
469
493
  errored_trials=config.run.errored_trials,
470
494
  resumable=resumable,
495
+ emissions=emissions,
471
496
  )
472
497
 
473
498
  # Run the HPO
@@ -1,5 +1,5 @@
1
1
  import time
2
- from typing import List, Optional, Dict, Any
2
+ from typing import TYPE_CHECKING, List, Optional, Dict, Any
3
3
 
4
4
  import ray
5
5
 
@@ -11,7 +11,10 @@ from warprec.common import (
11
11
  )
12
12
  from warprec.data import Dataset
13
13
  from warprec.pipelines.common import (
14
+ PipelineContext,
14
15
  bootstrap_pipeline,
16
+ data_preparation_seconds,
17
+ measure_emissions,
15
18
  prepare_datasets,
16
19
  report_statistical_significance,
17
20
  write_model_outputs,
@@ -33,6 +36,9 @@ from warprec.utils.pause import PauseController, RunPaused
33
36
  from warprec.utils.logger import logger
34
37
  from warprec.recommenders.trainer import Trainer, TrainingOutcome
35
38
 
39
+ if TYPE_CHECKING:
40
+ from warprec.recommenders.trainer.emissions import EmissionsSettings
41
+
36
42
 
37
43
  def resolve_model_outcome(
38
44
  model_name: str,
@@ -115,6 +121,20 @@ def train_pipeline(path: str):
115
121
  path (str): Path to the configuration file.
116
122
  """
117
123
  context = bootstrap_pipeline(path, "train", "Starting experiment.")
124
+ with measure_emissions(context) as emissions:
125
+ _train_models(context, emissions)
126
+
127
+
128
+ def _train_models(
129
+ context: PipelineContext, emissions: Optional["EmissionsSettings"]
130
+ ) -> None:
131
+ """Prepare the data, then optimize, evaluate and write every model.
132
+
133
+ Args:
134
+ context (PipelineContext): The context produced by the bootstrap.
135
+ emissions (Optional[EmissionsSettings]): The run's CodeCarbon
136
+ measurement, or None when the run is not measured.
137
+ """
118
138
  config = context.config
119
139
 
120
140
  # Build the datasets on the cluster and persist the splits if asked to
@@ -130,7 +150,7 @@ def train_pipeline(path: str):
130
150
  if requires_stat_significance:
131
151
  model_results: Dict[str, Any] = {}
132
152
 
133
- data_preparation_time = time.time() - context.started_at
153
+ data_preparation_time = data_preparation_seconds(context.started_at, emissions)
134
154
  logger.positive(
135
155
  f"Data preparation completed in {data_preparation_time:.2f} seconds."
136
156
  )
@@ -184,6 +204,7 @@ def train_pipeline(path: str):
184
204
  run_name=context.run_name,
185
205
  errored_trials=config.run.errored_trials,
186
206
  resumable=resumable,
207
+ emissions=emissions,
187
208
  )
188
209
  model_state.tune_experiment_name = trainer.experiment_name(model_name)
189
210
 
@@ -0,0 +1,176 @@
1
+ # pylint: disable=unused-argument, protected-access
2
+ from typing import Optional
3
+
4
+ import ray
5
+ from ray import tune
6
+ from ray.air.integrations.mlflow import MLflowLoggerCallback
7
+ from ray.air.integrations.wandb import WandbLoggerCallback
8
+ from ray.exceptions import GetTimeoutError, RayError
9
+
10
+ from warprec.recommenders.trainer.emissions import (
11
+ TRACKER_TIMEOUT_SECONDS,
12
+ EmissionsRecorder,
13
+ EmissionsSettings,
14
+ )
15
+ from warprec.utils.logger import logger
16
+
17
+
18
+ class WarpRecWandbLoggerCallback(WandbLoggerCallback):
19
+ """Ray's W&B callback, closing the runs of the trials still open at the end.
20
+
21
+ Ray Tune stops the trials still running at the end of an interrupted sweep
22
+ without calling 'on_trial_complete', so Ray's callback never tells their
23
+ logging actors to finish, and 'on_experiment_end' waits 'upload_timeout',
24
+ 30 minutes by default, for them. Telling them first lets each one flush its
25
+ queue and close its run, and the wait ends within seconds.
26
+ """
27
+
28
+ def on_experiment_end(self, trials, **info):
29
+ if hasattr(self, "_signal_logging_actor_stop"):
30
+ for trial in list(self._trial_logging_actors):
31
+ self._signal_logging_actor_stop(trial=trial)
32
+ super().on_experiment_end(trials, **info)
33
+
34
+
35
+ def mlflow_metric_name(name: str) -> str:
36
+ """The name MLflow receives for a WarpRec metric.
37
+
38
+ WarpRec names a metric ``<metric>@<k>``, and MLflow refuses names holding an
39
+ ``@``, so the cutoff is separated by a slash instead (``nDCG@10`` is sent as
40
+ ``nDCG/10``), which MLflow also uses to group related metrics.
41
+
42
+ Args:
43
+ name (str): The metric name as WarpRec reports it.
44
+
45
+ Returns:
46
+ str: The name to log the metric under in MLflow.
47
+ """
48
+ return name.replace("@", "/")
49
+
50
+
51
+ class WarpRecMLflowLoggerCallback(MLflowLoggerCallback):
52
+ """Ray's MLflow callback, with metric names MLflow accepts.
53
+
54
+ Only what is sent to MLflow is renamed: the report Ray Tune and the other
55
+ callbacks see keeps WarpRec's ``<metric>@<k>`` names.
56
+ """
57
+
58
+ def log_trial_result(self, iteration, trial, result):
59
+ renamed = {mlflow_metric_name(key): value for key, value in result.items()}
60
+ super().log_trial_result(iteration, trial, renamed)
61
+
62
+
63
+ class CodeCarbonCallback(tune.Callback):
64
+ """CodeCarbon for a Ray Tune search.
65
+
66
+ The run the search belongs to measures it: the train and swarm pipelines
67
+ start an 'EmissionsRecorder' before they prepare the data and hand its
68
+ 'settings' over. A search run without one, from a 'Trainer' used on its
69
+ own, starts its own recorder as its trials are set up and stops it when
70
+ the search ends.
71
+
72
+ With 'machine' tracking the recorder measures the Ray nodes, and there is
73
+ nothing left for the search to do. With 'process' tracking each Ray Train
74
+ worker of a trial measures itself (see 'trial_emissions') and hands its row
75
+ to the recorder through Ray; this callback logs a trial that completes or
76
+ fails with fewer rows delivered than it has workers.
77
+
78
+ Args:
79
+ save_to_api (bool): Whether to send the emissions to the CodeCarbon API.
80
+ save_to_file (bool): Whether to write the rows to 'emissions.csv'.
81
+ output_dir (str): The folder of 'emissions.csv'.
82
+ tracking_mode (str): CodeCarbon's tracking mode, 'machine' or 'process'.
83
+ project_name (Optional[str]): The project name of the rows, the run's
84
+ name. Defaults to 'warprec'.
85
+ settings (Optional[EmissionsSettings]): The measurement of the run the
86
+ search belongs to, or None when the search measures itself.
87
+ """
88
+
89
+ def __init__(
90
+ self,
91
+ save_to_api: bool = False,
92
+ save_to_file: bool = False,
93
+ output_dir: str = "./",
94
+ tracking_mode: str = "machine",
95
+ project_name: Optional[str] = None,
96
+ settings: Optional[EmissionsSettings] = None,
97
+ ):
98
+ self.save_to_api = save_to_api
99
+ self.save_to_file = save_to_file
100
+ self.output_dir = output_dir
101
+ self.tracking_mode = tracking_mode
102
+ self.project_name = project_name or "warprec"
103
+ self.settings = settings
104
+ self.workers_per_trial = 1
105
+ self._recorder: Optional[EmissionsRecorder] = None
106
+
107
+ def trial_settings(self, num_workers: int = 1) -> Optional[EmissionsSettings]:
108
+ """What a trial needs to measure itself.
109
+
110
+ Called as the search is set up: a search measuring itself starts
111
+ doing so here.
112
+
113
+ Args:
114
+ num_workers (int): The Ray Train workers of each trial, as many
115
+ rows as a trial delivers.
116
+
117
+ Returns:
118
+ Optional[EmissionsSettings]: The settings 'trial_emissions' takes,
119
+ or None when the trials are not measured one by one.
120
+ """
121
+ self.workers_per_trial = num_workers
122
+ if self.settings is None and self._recorder is None:
123
+ self._recorder = EmissionsRecorder(
124
+ tracking_mode=self.tracking_mode,
125
+ save_to_api=self.save_to_api,
126
+ save_to_file=self.save_to_file,
127
+ output_dir=self.output_dir,
128
+ project_name=self.project_name,
129
+ )
130
+ self._recorder.start()
131
+ settings = self.settings
132
+ if settings is None and self._recorder is not None:
133
+ settings = self._recorder.settings
134
+ if self.tracking_mode != "process":
135
+ return None
136
+ return settings
137
+
138
+ def _check_rows(self, trial_id: str) -> None:
139
+ """Log a finished trial whose workers did not all deliver their row.
140
+
141
+ Args:
142
+ trial_id (str): The trial.
143
+ """
144
+ settings = self.settings or (
145
+ self._recorder.settings if self._recorder is not None else None
146
+ )
147
+ if self.tracking_mode != "process" or settings is None:
148
+ return
149
+ try:
150
+ delivered = ray.get(
151
+ settings.inbox.delivered.remote(trial_id),
152
+ timeout=TRACKER_TIMEOUT_SECONDS,
153
+ )
154
+ except (RayError, GetTimeoutError) as error:
155
+ logger.attention(
156
+ f"Could not check the CodeCarbon rows of trial {trial_id}: "
157
+ f"{type(error).__name__}."
158
+ )
159
+ return
160
+ if delivered < self.workers_per_trial:
161
+ logger.attention(
162
+ f"Trial {trial_id} finished with {delivered} of its "
163
+ f"{self.workers_per_trial} CodeCarbon rows delivered: the "
164
+ "emissions of the missing workers are not in emissions.csv."
165
+ )
166
+
167
+ def on_trial_complete(self, iteration, trials, trial, **info):
168
+ self._check_rows(trial.trial_id)
169
+
170
+ def on_trial_error(self, iteration, trials, trial, **info):
171
+ self._check_rows(trial.trial_id)
172
+
173
+ def on_experiment_end(self, trials, **info):
174
+ if self._recorder is not None:
175
+ self._recorder.stop()
176
+ self._recorder = None