warprec 2.2.0__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.0 → warprec-2.2.2}/PKG-INFO +1 -1
  2. {warprec-2.2.0 → warprec-2.2.2}/pyproject.toml +1 -1
  3. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/evaluator.py +73 -0
  4. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/f1.py +19 -3
  5. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/base_metric.py +70 -4
  6. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/long_tail.py +2 -2
  7. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/pop_reo.py +2 -2
  8. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/pop_rsp.py +2 -2
  9. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +13 -1
  10. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/hypervolume.py +13 -1
  11. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/novelty_profile.py +2 -2
  12. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/common.py +60 -1
  13. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/swarm.py +28 -3
  14. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/train.py +23 -2
  15. warprec-2.2.2/warprec/recommenders/trainer/dashboard_callbacks.py +176 -0
  16. warprec-2.2.2/warprec/recommenders/trainer/emissions.py +507 -0
  17. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/objectives.py +1 -1
  18. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/trainer.py +18 -3
  19. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/common.py +175 -1
  20. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/config.py +52 -1
  21. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/registry.py +21 -0
  22. warprec-2.2.0/warprec/recommenders/trainer/dashboard_callbacks.py +0 -209
  23. {warprec-2.2.0 → warprec-2.2.2}/LICENSE +0 -0
  24. {warprec-2.2.0 → warprec-2.2.2}/README.md +0 -0
  25. {warprec-2.2.0 → warprec-2.2.2}/warprec/__init__.py +0 -0
  26. {warprec-2.2.0 → warprec-2.2.2}/warprec/common/__init__.py +0 -0
  27. {warprec-2.2.0 → warprec-2.2.2}/warprec/common/initialize.py +0 -0
  28. {warprec-2.2.0 → warprec-2.2.2}/warprec/common/run_state.py +0 -0
  29. {warprec-2.2.0 → warprec-2.2.2}/warprec/common/std_logs.py +0 -0
  30. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/__init__.py +0 -0
  31. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/dataset.py +0 -0
  32. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/__init__.py +0 -0
  33. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/common.py +0 -0
  34. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/context.py +0 -0
  35. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/interactions.py +0 -0
  36. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/knowledge.py +0 -0
  37. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/multimodal.py +0 -0
  38. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/sessions.py +0 -0
  39. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/train_structures/__init__.py +0 -0
  40. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
  41. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
  42. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/train_structures/session_structures.py +0 -0
  43. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/entities/transactions.py +0 -0
  44. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/eval_loaders.py +0 -0
  45. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/filtering.py +0 -0
  46. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/ranking.py +0 -0
  47. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/reader/__init__.py +0 -0
  48. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/reader/azureblob_reader.py +0 -0
  49. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/reader/base_reader.py +0 -0
  50. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/reader/local_reader.py +0 -0
  51. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/schema.py +0 -0
  52. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/splitting/__init__.py +0 -0
  53. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/splitting/splitter.py +0 -0
  54. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/splitting/strategies.py +0 -0
  55. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/stash.py +0 -0
  56. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/writer/__init__.py +0 -0
  57. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/writer/azureblob_writer.py +0 -0
  58. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/writer/base_writer.py +0 -0
  59. {warprec-2.2.0 → warprec-2.2.2}/warprec/data/writer/local_writer.py +0 -0
  60. {warprec-2.2.0 → warprec-2.2.2}/warprec/errors.py +0 -0
  61. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/__init__.py +0 -0
  62. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/factory.py +0 -0
  63. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/__init__.py +0 -0
  64. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
  65. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
  66. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
  67. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
  68. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
  69. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
  70. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/map.py +0 -0
  71. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
  72. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
  73. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
  74. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
  75. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
  76. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/__init__.py +0 -0
  77. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/aclt.py +0 -0
  78. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/aplt.py +0 -0
  79. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/bias/arp.py +0 -0
  80. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
  81. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
  82. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
  83. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
  84. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
  85. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
  86. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/base.py +0 -0
  87. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
  88. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/debiased/recall.py +0 -0
  89. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
  90. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
  91. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
  92. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
  93. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
  94. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
  95. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
  96. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
  97. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
  98. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
  99. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/reo.py +0 -0
  100. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
  101. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
  102. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
  103. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
  104. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
  105. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/efd.py +0 -0
  106. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/novelty/epc.py +0 -0
  107. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/rating/__init__.py +0 -0
  108. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/rating/mae.py +0 -0
  109. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/rating/mse.py +0 -0
  110. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/metrics/rating/rmse.py +0 -0
  111. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/propensity.py +0 -0
  112. {warprec-2.2.0 → warprec-2.2.2}/warprec/evaluation/statistical_significance.py +0 -0
  113. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/__init__.py +0 -0
  114. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/design.py +0 -0
  115. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/estimate.py +0 -0
  116. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/eval.py +0 -0
  117. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/remotes/__init__.py +0 -0
  118. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/remotes/data.py +0 -0
  119. {warprec-2.2.0 → warprec-2.2.2}/warprec/pipelines/remotes/ml.py +0 -0
  120. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/__init__.py +0 -0
  121. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/base_recommender.py +0 -0
  122. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/callbacks.py +0 -0
  123. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
  124. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
  125. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
  126. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
  127. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
  128. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
  129. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
  130. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
  131. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
  132. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
  133. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
  134. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
  135. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
  136. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
  137. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
  138. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
  139. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
  140. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
  141. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
  142. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
  143. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
  144. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
  145. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
  146. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
  147. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
  148. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
  149. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
  150. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
  151. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
  152. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
  153. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
  154. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
  155. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
  156. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
  157. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
  158. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
  159. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
  160. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
  161. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
  162. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
  163. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
  164. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
  165. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
  166. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
  167. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
  168. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
  169. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
  170. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
  171. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
  172. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
  173. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
  174. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
  175. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
  176. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
  177. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
  178. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
  179. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
  180. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
  181. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
  182. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
  183. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
  184. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
  185. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
  186. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
  187. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
  188. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
  189. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
  190. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
  191. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
  192. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
  193. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
  194. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
  195. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
  196. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
  197. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
  198. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
  199. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/layers.py +0 -0
  200. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/losses.py +0 -0
  201. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
  202. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
  203. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
  204. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
  205. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
  206. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
  207. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
  208. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
  209. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
  210. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/optimizer_wrapper.py +0 -0
  211. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/proxy.py +0 -0
  212. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/reranking/__init__.py +0 -0
  213. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/reranking/base.py +0 -0
  214. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/reranking/calibration.py +0 -0
  215. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/reranking/factory.py +0 -0
  216. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/reranking/mmr.py +0 -0
  217. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
  218. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
  219. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
  220. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/caser.py +0 -0
  221. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
  222. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/core.py +0 -0
  223. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
  224. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
  225. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
  226. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
  227. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
  228. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
  229. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
  230. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/narm.py +0 -0
  231. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
  232. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/sequential_recommender/stan.py +0 -0
  233. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/similarities.py +0 -0
  234. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/__init__.py +0 -0
  235. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
  236. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/runtime.py +0 -0
  237. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
  238. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
  239. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
  240. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
  241. {warprec-2.2.0 → warprec-2.2.2}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
  242. {warprec-2.2.0 → warprec-2.2.2}/warprec/run.py +0 -0
  243. {warprec-2.2.0 → warprec-2.2.2}/warprec/serve.py +0 -0
  244. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/__init__.py +0 -0
  245. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/api.py +0 -0
  246. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/app.py +0 -0
  247. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/catalogue.py +0 -0
  248. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/context.py +0 -0
  249. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/deployments.py +0 -0
  250. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/errors.py +0 -0
  251. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/mcp.py +0 -0
  252. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/payload.py +0 -0
  253. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/schemas.py +0 -0
  254. {warprec-2.2.0 → warprec-2.2.2}/warprec/serving/servable.py +0 -0
  255. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/__init__.py +0 -0
  256. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/callback.py +0 -0
  257. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/__init__.py +0 -0
  258. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/dashboard_configuration.py +0 -0
  259. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/estimate_configuration.py +0 -0
  260. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/evaluation_configuration.py +0 -0
  261. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/general_configuration.py +0 -0
  262. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/model_configuration.py +0 -0
  263. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/reader_configuration.py +0 -0
  264. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
  265. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
  266. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
  267. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
  268. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
  269. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
  270. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
  271. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
  272. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
  273. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
  274. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
  275. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
  276. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
  277. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
  278. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/rerank_configuration.py +0 -0
  279. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/run_configuration.py +0 -0
  280. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/search_space_wrapper.py +0 -0
  281. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/serving_configuration.py +0 -0
  282. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/splitter_configuration.py +0 -0
  283. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/training_configuration.py +0 -0
  284. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/config/writer_configuration.py +0 -0
  285. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/enums.py +0 -0
  286. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/helpers.py +0 -0
  287. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/logger/__init__.py +0 -0
  288. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/logger/logger.py +0 -0
  289. {warprec-2.2.0 → warprec-2.2.2}/warprec/utils/pause.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: warprec
3
- Version: 2.2.0
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.0"
64
+ version = "2.2.2"
65
65
 
66
66
  [tool.poetry.dependencies]
67
67
  python = "^3.12"
@@ -29,6 +29,21 @@ from warprec.utils.logger import logger
29
29
  from warprec.utils.registry import metric_registry
30
30
 
31
31
 
32
+ def _sub_metric_names(name: str, params: Dict[str, Any]) -> List[str]:
33
+ """The metrics a configured metric is built from, if it is registered.
34
+
35
+ Args:
36
+ name (str): The configured metric.
37
+ params (Dict[str, Any]): Its parameters.
38
+
39
+ Returns:
40
+ List[str]: The names of the metrics it builds.
41
+ """
42
+ if name.upper() not in metric_registry.list_registered():
43
+ return []
44
+ return metric_registry.get_class(name).sub_metric_names(params)
45
+
46
+
32
47
  class Evaluator:
33
48
  """Evaluator class will evaluate a trained model on a given
34
49
  set of metrics, taking into account the cutoff.
@@ -140,9 +155,67 @@ class Evaluator:
140
155
  check_stash(
141
156
  additional_data, {"k", *self.common_params, *METRIC_ARGUMENTS}, "metric"
142
157
  )
158
+ self._check_stash_parameters(additional_data, metric_list, complex_metrics)
143
159
  self.common_params.update(additional_data)
144
160
  self._init_metrics(metric_list, complex_metrics)
145
161
 
162
+ @staticmethod
163
+ def _check_stash_parameters(
164
+ stash: Dict[str, Any],
165
+ metric_list: List[str],
166
+ complex_metrics: Optional[List[ComplexMetricConfig]],
167
+ ) -> None:
168
+ """Refuse a stash entry that would set a parameter already set.
169
+
170
+ Every metric receives the whole stash as keyword arguments. An entry
171
+ named like a parameter a configured metric (or a metric it is built
172
+ from) takes from WarpRec, e.g. EPC's 'relevance', would silently set it
173
+ for every such metric, and one named like a parameter the
174
+ configuration gives a metric would clash with it. An entry named like
175
+ a parameter only a metric of your own declares is the way that metric
176
+ receives it, and is passed on.
177
+
178
+ Args:
179
+ stash (Dict[str, Any]): The stash.
180
+ metric_list (List[str]): The metrics configured by name.
181
+ complex_metrics (Optional[List[ComplexMetricConfig]]): The metrics
182
+ configured with parameters.
183
+
184
+ Raises:
185
+ ExtensionError: If a stash entry has the name of such a parameter,
186
+ naming the entry and the configured metrics it would reach.
187
+ """
188
+ if not stash:
189
+ return
190
+ configured: List[Tuple[str, Dict[str, Any]]] = [
191
+ (name, {}) for name in metric_list
192
+ ] + [(metric.name, metric.params) for metric in complex_metrics or []]
193
+
194
+ clashes: Dict[str, List[str]] = {}
195
+ for name, params in configured:
196
+ classes = []
197
+ for metric_name in [name, *_sub_metric_names(name, params)]:
198
+ if metric_name.upper() in metric_registry.list_registered():
199
+ classes.append(metric_registry.get_class(metric_name))
200
+ for key in stash:
201
+ if key in params or any(c.warprec_parameter(key) for c in classes):
202
+ clashes.setdefault(key, [])
203
+ if name not in clashes[key]:
204
+ clashes[key].append(name)
205
+
206
+ if clashes:
207
+ details = "; ".join(
208
+ f"{key!r} reaches {', '.join(names)}"
209
+ for key, names in sorted(clashes.items())
210
+ )
211
+ raise ExtensionError(
212
+ "A stash entry has the name of a parameter WarpRec or the "
213
+ "configuration sets for a configured metric, and every metric "
214
+ f"receives the stash, so it would set that parameter: {details}. "
215
+ "Rename the entry; a metric of your own receives an entry by "
216
+ "declaring a parameter of the entry's name."
217
+ )
218
+
146
219
  def _init_metrics(
147
220
  self, metric_list: List[str], complex_metrics: List[ComplexMetricConfig] = None
148
221
  ):
@@ -1,4 +1,5 @@
1
- from typing import Any
1
+ import inspect
2
+ from typing import Any, Dict, List
2
3
 
3
4
  import torch
4
5
  from torch import Tensor
@@ -72,6 +73,21 @@ class F1(TopKMetric):
72
73
  self.metric_instance_1.components | self.metric_instance_2.components
73
74
  )
74
75
 
76
+ @classmethod
77
+ def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
78
+ """The two metrics combined, which receive the keyword arguments.
79
+
80
+ Args:
81
+ params (Dict[str, Any]): The parameters it is configured with.
82
+
83
+ Returns:
84
+ List[str]: The two metrics' names.
85
+ """
86
+ defaults = inspect.signature(cls.__init__).parameters
87
+ return [
88
+ params.get(key, defaults[key].default) for key in ("metric_1", "metric_2")
89
+ ]
90
+
75
91
  def update(self, preds: Tensor, user_indices: Tensor, **kwargs: Any):
76
92
  """Updates the metric state with the new batch of predictions."""
77
93
  # Update first metric
@@ -110,5 +126,5 @@ class F1(TopKMetric):
110
126
  def name(self):
111
127
  """The name of the metric customized based on the metrics compared."""
112
128
  if self.metric_1 == "Precision" and self.metric_2 == "Recall":
113
- return self.__class__.__name__
114
- return f"F1[{self.metric_1}, {self.metric_2}]"
129
+ return self.registered_name()
130
+ return f"{self.registered_name()}[{self.metric_1}, {self.metric_2}]"
@@ -1,11 +1,13 @@
1
+ import inspect
1
2
  from abc import abstractmethod, ABC
2
- from typing import Any, Tuple, Set, Optional
3
+ from typing import Any, Dict, List, Tuple, Set, Optional
3
4
 
4
5
  import torch
5
6
  from torch import Tensor
6
7
  from torchmetrics import Metric
7
8
  from warprec.errors import ExtensionError
8
9
  from warprec.utils.enums import MetricBlock
10
+ from warprec.utils.registry import metric_registry
9
11
 
10
12
 
11
13
  class BaseMetric(Metric, ABC):
@@ -302,9 +304,73 @@ class BaseMetric(Metric, ABC):
302
304
  )
303
305
 
304
306
  @property
305
- def name(self):
306
- """The name of the metric."""
307
- return self.__class__.__name__
307
+ def name(self) -> str:
308
+ """The name the metric reports its results under.
309
+
310
+ Returns:
311
+ str: The name the metric is registered, and configured, under.
312
+ """
313
+ return self.registered_name()
314
+
315
+ @classmethod
316
+ def registered_name(cls) -> str:
317
+ """The name the class is registered under, as it was written.
318
+
319
+ A class registered under a name of its own, e.g. 'MyName' on a class
320
+ Foo, reports under that name, the one the configuration names it by,
321
+ rather than its class name. Every built-in metric is registered under
322
+ its class name. A class that is not registered reports under its
323
+ class name.
324
+
325
+ Returns:
326
+ str: The registered name, or the class name.
327
+ """
328
+ return metric_registry.spelled_name(cls) or cls.__name__
329
+
330
+ @classmethod
331
+ def warprec_parameter(cls, name: str) -> bool:
332
+ """Whether a constructor parameter of the metric is one of WarpRec's.
333
+
334
+ The stash reaches every metric as keyword arguments, so an entry named
335
+ like a parameter sets it. That is how a metric of your own receives an
336
+ entry, by declaring a parameter of its name; a parameter a built-in
337
+ metric declares (EPC's 'relevance') is WarpRec's, set by its default or
338
+ the configuration, and an entry would change it without a word. The
339
+ parameter belongs to the class nearest in the hierarchy that names it,
340
+ so a metric of your own may declare one a built-in it extends has.
341
+
342
+ Args:
343
+ name (str): The parameter.
344
+
345
+ Returns:
346
+ bool: True if the nearest class naming the parameter is WarpRec's.
347
+ """
348
+ for klass in cls.__mro__:
349
+ init = klass.__dict__.get("__init__")
350
+ if init is None:
351
+ continue
352
+ try:
353
+ parameter = inspect.signature(init).parameters.get(name)
354
+ except (TypeError, ValueError):
355
+ continue
356
+ if parameter is not None and parameter.kind not in (
357
+ parameter.VAR_POSITIONAL,
358
+ parameter.VAR_KEYWORD,
359
+ ):
360
+ return klass.__module__.split(".")[0] == "warprec"
361
+ return False
362
+
363
+ @classmethod
364
+ def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
365
+ """The metrics this one builds and hands its keyword arguments to.
366
+
367
+ Args:
368
+ params (Dict[str, Any]): The parameters it is configured with.
369
+
370
+ Returns:
371
+ List[str]: Their names; none for a metric that builds none.
372
+ """
373
+ return []
308
374
 
309
375
  @property
310
376
  def components(self) -> Set[MetricBlock]:
@@ -85,5 +85,5 @@ class LongTailMetric(UserAverageTopKMetric):
85
85
  def name(self):
86
86
  """The name of the metric."""
87
87
  if self.pop_ratio == 0.8:
88
- return self.__class__.__name__
89
- return f"{self.__class__.__name__}[Pop{int(self.pop_ratio * 100)}%]"
88
+ return self.registered_name()
89
+ return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
@@ -123,5 +123,5 @@ class PopREO(TopKMetric):
123
123
  def name(self):
124
124
  """The name of the metric."""
125
125
  if self.pop_ratio == 0.8:
126
- return self.__class__.__name__
127
- return f"PopREO[Pop{int(self.pop_ratio * 100)}%]"
126
+ return self.registered_name()
127
+ return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
@@ -121,5 +121,5 @@ class PopRSP(TopKMetric):
121
121
  def name(self):
122
122
  """The name of the metric."""
123
123
  if self.pop_ratio == 0.8:
124
- return self.__class__.__name__
125
- return f"PopRSP[Pop{int(self.pop_ratio * 100)}%]"
124
+ return self.registered_name()
125
+ return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
@@ -1,4 +1,4 @@
1
- from typing import Any, List
1
+ from typing import Any, Dict, List
2
2
  import torch
3
3
  from torch import Tensor, nn
4
4
  from warprec.errors import ConfigurationError, EvaluationError
@@ -77,6 +77,18 @@ class EucDistance(TopKMetric):
77
77
 
78
78
  self._REQUIRED_COMPONENTS = required_blocks
79
79
 
80
+ @classmethod
81
+ def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
82
+ """The metrics combined, which receive the keyword arguments.
83
+
84
+ Args:
85
+ params (Dict[str, Any]): The parameters it is configured with.
86
+
87
+ Returns:
88
+ List[str]: The names in 'metric_names'.
89
+ """
90
+ return list(params.get("metric_names") or [])
91
+
80
92
  def reset(self) -> None:
81
93
  """Reset the sub-metrics along with the composite.
82
94
 
@@ -1,4 +1,4 @@
1
- from typing import Any, List
1
+ from typing import Any, Dict, List
2
2
  import torch
3
3
  from torch import Tensor, nn
4
4
  from warprec.errors import ConfigurationError, EvaluationError
@@ -83,6 +83,18 @@ class Hypervolume(TopKMetric):
83
83
 
84
84
  self._REQUIRED_COMPONENTS = required_blocks
85
85
 
86
+ @classmethod
87
+ def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
88
+ """The metrics combined, which receive the keyword arguments.
89
+
90
+ Args:
91
+ params (Dict[str, Any]): The parameters it is configured with.
92
+
93
+ Returns:
94
+ List[str]: The names in 'metric_names'.
95
+ """
96
+ return list(params.get("metric_names") or [])
97
+
86
98
  def reset(self) -> None:
87
99
  """Reset the sub-metrics along with the composite.
88
100
 
@@ -110,5 +110,5 @@ class NoveltyProfileMetric(UserAverageTopKMetric):
110
110
  def name(self):
111
111
  """The name of the metric."""
112
112
  if self.relevance == "binary":
113
- return self.__class__.__name__
114
- return f"{self.__class__.__name__}[{self.relevance}]"
113
+ return self.registered_name()
114
+ return f"{self.registered_name()}[{self.relevance}]"
@@ -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