bertrend 0.3.1__tar.gz → 0.3.3__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 (185) hide show
  1. {bertrend-0.3.1 → bertrend-0.3.3}/PKG-INFO +78 -72
  2. {bertrend-0.3.1 → bertrend-0.3.3}/README.md +27 -21
  3. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/llm_utils/newsletter_features.py +3 -3
  4. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/authentication.py +0 -1
  5. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/abstractive_summarizer.py +1 -1
  6. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/chatgpt_summarizer.py +1 -1
  7. bertrend-0.3.3/bertrend/tests/README_integration_tests.md +91 -0
  8. bertrend-0.3.3/bertrend/tests/conftest.py +11 -0
  9. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_abstractive_summarizer.py +25 -16
  10. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_extractive_summarizer.py +34 -21
  11. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_installation.py +1 -3
  12. bertrend-0.3.3/bertrend/tests/test_integration.py +442 -0
  13. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_topic_metrics.py +29 -23
  14. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/representative_docs.py +6 -5
  15. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/newsletters/__main__.py +4 -2
  16. bertrend-0.3.3/pyproject.toml +96 -0
  17. bertrend-0.3.1/pyproject.toml +0 -91
  18. {bertrend-0.3.1 → bertrend-0.3.3}/AUTHORS.txt +0 -0
  19. {bertrend-0.3.1 → bertrend-0.3.3}/LICENSE.md +0 -0
  20. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/BERTopicModel.py +0 -0
  21. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/BERTrend.py +0 -0
  22. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/__init__.py +0 -0
  23. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/config/bertopic_default_config.toml +0 -0
  24. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/config/bertrend_default_config.toml +0 -0
  25. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/config/parameters.py +0 -0
  26. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/config/services_default_config.toml +0 -0
  27. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/__init__.py +0 -0
  28. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/__init__.py +0 -0
  29. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/data_loading_component.py +0 -0
  30. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/embed_documents_component.py +0 -0
  31. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/icons.py +0 -0
  32. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/messages.py +0 -0
  33. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/parameters_component.py +0 -0
  34. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/demos_utils/state_utils.py +0 -0
  35. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/start_summarizer_app.sh +0 -0
  36. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/start_topic_analysis_app.sh +0 -0
  37. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/start_weak_signals_app.sh +0 -0
  38. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/summarization/__init__.py +0 -0
  39. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/summarization/summarizer_app.py +0 -0
  40. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/__init__.py +0 -0
  41. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/app.py +0 -0
  42. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/app_utils.py +0 -0
  43. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/__init__.py +0 -0
  44. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/explore_topics.py +0 -0
  45. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/newsletters_generation.py +0 -0
  46. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/temporal_visualizations.py +0 -0
  47. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/topic_visualizations.py +0 -0
  48. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/demo_pages/training_page.py +0 -0
  49. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/topic_analysis/messages.py +0 -0
  50. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/weak_signals/__init__.py +0 -0
  51. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/weak_signals/app.py +0 -0
  52. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/weak_signals/messages.py +0 -0
  53. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/demos/weak_signals/visualizations_utils.py +0 -0
  54. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/llm_utils/__init__.py +0 -0
  55. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/llm_utils/newsletter.css +0 -0
  56. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/llm_utils/openai_client.py +0 -0
  57. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/llm_utils/prompts.py +0 -0
  58. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/metrics/__init__.py +0 -0
  59. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/metrics/temporal_metrics_embedding.py +0 -0
  60. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/metrics/topic_metrics.py +0 -0
  61. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/resources/common_ngrams.json +0 -0
  62. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/resources/stopwords-en.json +0 -0
  63. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/resources/stopwords-fr.json +0 -0
  64. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/resources/stopwords-rte.json +0 -0
  65. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/__init__.py +0 -0
  66. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/embedding_client.py +0 -0
  67. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/embedding_service.py +0 -0
  68. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summarizer.py +0 -0
  69. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/__init__.py +0 -0
  70. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/extractive_summarizer.py +0 -0
  71. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/lexrank.py +0 -0
  72. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/services/summary/prompts.py +0 -0
  73. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/__init__.py +0 -0
  74. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_bertrend.py +0 -0
  75. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_cache_utils.py +0 -0
  76. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_chatgpt_summarizer.py +0 -0
  77. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_config_utils.py +0 -0
  78. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_data_loading.py +0 -0
  79. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_data_structure.py +0 -0
  80. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_embedding_client.py +0 -0
  81. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_newsletter_features.py +0 -0
  82. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_openai_client.py +0 -0
  83. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_representative_docs.py +0 -0
  84. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_summarizer.py +0 -0
  85. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_temporal_metrics_embedding.py +0 -0
  86. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_topic_description.py +0 -0
  87. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_topic_model.py +0 -0
  88. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_trend_analysis_data_structure.py +0 -0
  89. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_trend_analysis_prompts.py +0 -0
  90. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_trend_analysis_visualizations.py +0 -0
  91. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_trend_analysis_weak_signals.py +0 -0
  92. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_utils_init.py +0 -0
  93. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/tests/test_visualizations.py +0 -0
  94. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/__init__.py +0 -0
  95. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/data_structure.py +0 -0
  96. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/prompts.py +0 -0
  97. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/topic_description.py +0 -0
  98. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/topic_analysis/visualizations.py +0 -0
  99. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/__init__.py +0 -0
  100. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/data_structure.py +0 -0
  101. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/prompts.py +0 -0
  102. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/signal_llm_template_en.html +0 -0
  103. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/signal_llm_template_fr.html +0 -0
  104. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/visualizations.py +0 -0
  105. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/trend_analysis/weak_signals.py +0 -0
  106. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/utils/__init__.py +0 -0
  107. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/utils/cache_utils.py +0 -0
  108. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/utils/config_utils.py +0 -0
  109. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend/utils/data_loading.py +0 -0
  110. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/__init__.py +0 -0
  111. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/common/__init__.py +0 -0
  112. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/common/crontab_utils.py +0 -0
  113. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/common/mail_utils.py +0 -0
  114. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/arxiv_feed.toml +0 -0
  115. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/decarbonation_feed.toml +0 -0
  116. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/llm_en_feed.toml +0 -0
  117. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/llm_feed.toml +0 -0
  118. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/nlp_feed.toml +0 -0
  119. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/feeds/rte_feed.toml +0 -0
  120. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/gmail_credentials.json +0 -0
  121. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/arxiv_newsletter_from_last.toml +0 -0
  122. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/arxiv_newsletter_from_scratch.toml +0 -0
  123. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/decarbonation_newsletter_from_last.toml +0 -0
  124. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/decarbonation_newsletter_from_scratch.toml +0 -0
  125. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/llm_en_newsletter_from_last.toml +0 -0
  126. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/llm_newsletter_from_last.toml +0 -0
  127. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/nlp_newsletter_from_last.toml +0 -0
  128. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/rte_newsletter_from_last.toml +0 -0
  129. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/config/newsletters/rte_newsletter_from_scratch.toml +0 -0
  130. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/__init__.py +0 -0
  131. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/__main__.py +0 -0
  132. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/arxiv_provider.py +0 -0
  133. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/bing_news_provider.py +0 -0
  134. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/curebot_provider.py +0 -0
  135. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/data_provider.py +0 -0
  136. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/google_news_provider.py +0 -0
  137. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/newscatcher_provider.py +0 -0
  138. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/data_provider/utils.py +0 -0
  139. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/__init__.py +0 -0
  140. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/__init__.py +0 -0
  141. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/app.py +0 -0
  142. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/app_utils.py +0 -0
  143. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/config.toml +0 -0
  144. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/import_extraction_article.ipynb +0 -0
  145. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/old_veille_analyse.py +0 -0
  146. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/prompts.py +0 -0
  147. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/start_newsletter_generator.sh +0 -0
  148. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/tabs/tab1.py +0 -0
  149. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/tabs/tab2.py +0 -0
  150. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/curebot/tabs/tab3.py +0 -0
  151. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/dataviz/Main_page.py +0 -0
  152. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/dataviz/__init__.py +0 -0
  153. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/dataviz/pages/1_Data_feeds.py +0 -0
  154. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/__init__.py +0 -0
  155. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/entity_utils.py +0 -0
  156. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/spacy/__init__.py +0 -0
  157. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/spacy/common_factory.py +0 -0
  158. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/spacy/dbpedia.py +0 -0
  159. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/spacy/nlp.config +0 -0
  160. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/exploration/geolocalization/spacy/utils.py +0 -0
  161. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/install_feeds_and_newsletters.py +0 -0
  162. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/newsletters/__init__.py +0 -0
  163. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/.streamlit/config.toml +0 -0
  164. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/.streamlit/secrets.toml +0 -0
  165. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/__init__.py +0 -0
  166. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/app.py +0 -0
  167. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/authentication.py +0 -0
  168. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/dashboard_analysis.py +0 -0
  169. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/dashboard_common.py +0 -0
  170. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/dashboard_signals.py +0 -0
  171. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/feeds_common.py +0 -0
  172. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/feeds_config.py +0 -0
  173. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/feeds_data.py +0 -0
  174. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/i18n.py +0 -0
  175. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/llm_utils.py +0 -0
  176. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/models_info.py +0 -0
  177. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/perf_utils.py +0 -0
  178. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/process_new_data.py +0 -0
  179. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/report_generation.py +0 -0
  180. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/report_template.html +0 -0
  181. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/report_utils.py +0 -0
  182. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/start_demo.sh +0 -0
  183. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/prospective_demo/streamlit_utils.py +0 -0
  184. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/start_apps.sh +0 -0
  185. {bertrend-0.3.1 → bertrend-0.3.3}/bertrend_apps/stop_apps.sh +0 -0
@@ -1,90 +1,88 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: bertrend
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: BERTrend analyses topic evolution over time using state-of-the-art transformer models: topic modelling and LLM
5
- Home-page: https://github.com/rte-france/BERTrend
6
5
  License: LICENSE.md
7
- Keywords: topics,BERTopic,transformers,weak signals
6
+ Keywords: topics,BERTopic,transformers,weak signals,LLM
8
7
  Author: Jérôme Picault
9
8
  Author-email: jerome.picault@rte-france.com
9
+ Maintainer: Jérôme Picault
10
+ Maintainer-email: jerome.picault@rte-france.com
10
11
  Requires-Python: >=3.12,<4.0
11
- Classifier: License :: Other/Proprietary License
12
- Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
14
13
  Provides-Extra: apps
15
- Provides-Extra: tests
16
14
  Requires-Dist: Pyqtree (==1.0.0)
17
- Requires-Dist: arxiv (>=2.2.0,<3.0.0) ; extra == "apps"
15
+ Requires-Dist: arxiv (>=2.2.0) ; extra == "apps"
18
16
  Requires-Dist: bertopic (==0.16.2)
19
- Requires-Dist: black (>=24.10.0,<25.0.0)
20
- Requires-Dist: coverage (>=7.6.9,<8.0.0) ; extra == "tests"
21
- Requires-Dist: cron-descriptor (>=1.4.5,<2.0.0)
17
+ Requires-Dist: black (>=24.10.0)
18
+ Requires-Dist: coverage (>=7.6.9)
19
+ Requires-Dist: cron-descriptor (>=1.4.5)
22
20
  Requires-Dist: dask (==2024.12.0)
23
21
  Requires-Dist: datamapplot (==0.3.0)
24
- Requires-Dist: dateparser (>=1.2.0,<2.0.0)
25
- Requires-Dist: dill (>=0.4.0,<0.5.0)
26
- Requires-Dist: feedparser (>=6.0.11,<7.0.0) ; extra == "apps"
27
- Requires-Dist: gensim (==4.3.2)
28
- Requires-Dist: google-api-python-client (>=2.148.0,<3.0.0) ; extra == "apps"
29
- Requires-Dist: google-auth-oauthlib (>=1.2.1,<2.0.0) ; extra == "apps"
30
- Requires-Dist: googlenewsdecoder (>=0.1.7,<0.2.0) ; extra == "apps"
31
- Requires-Dist: goose3 (>=3.1.19,<4.0.0) ; extra == "apps"
32
- Requires-Dist: hdbscan (>=0.8.40,<0.9.0)
33
- Requires-Dist: ipython (>=8.28.0,<9.0.0)
34
- Requires-Dist: joblib (>=1.4.2,<2.0.0)
35
- Requires-Dist: jsonlines (>=4.0.0,<5.0.0)
36
- Requires-Dist: langchain-chroma (>=0.2.2,<0.3.0)
37
- Requires-Dist: langchain-community (>=0.3.21,<0.4.0)
38
- Requires-Dist: langchain-openai (>=0.3.12,<0.4.0)
39
- Requires-Dist: langdetect (>=1.0.9,<2.0.0)
40
- Requires-Dist: loguru (>=0.7.3,<0.8.0)
41
- Requires-Dist: lxml-html-clean (>=0.2.2,<0.3.0)
42
- Requires-Dist: markdown (>=3.7,<4.0)
43
- Requires-Dist: newscatcherapi (>=0.7.3,<0.8.0) ; extra == "apps"
44
- Requires-Dist: newspaper4k (>=0.9.3.1,<0.10.0.0) ; extra == "apps"
45
- Requires-Dist: nltk (>=3.9.1,<4.0.0)
22
+ Requires-Dist: dateparser (>=1.2.0)
23
+ Requires-Dist: dill (>=0.4.0)
24
+ Requires-Dist: feedparser (>=6.0.11) ; extra == "apps"
25
+ Requires-Dist: gensim (>=4.3.3)
26
+ Requires-Dist: google-api-python-client (>=2.148.0) ; extra == "apps"
27
+ Requires-Dist: google-auth-oauthlib (>=1.2.1) ; extra == "apps"
28
+ Requires-Dist: googlenewsdecoder (>=0.1.7) ; extra == "apps"
29
+ Requires-Dist: goose3 (>=3.1.19) ; extra == "apps"
30
+ Requires-Dist: hdbscan (>=0.8.40)
31
+ Requires-Dist: ipython (>=8.28.0)
32
+ Requires-Dist: joblib (>=1.4.2)
33
+ Requires-Dist: jsonlines (>=4.0.0)
34
+ Requires-Dist: langchain-core (>=0.3.59)
35
+ Requires-Dist: langdetect (>=1.0.9)
36
+ Requires-Dist: loguru (>=0.7.3)
37
+ Requires-Dist: lxml-html-clean (>=0.2.2)
38
+ Requires-Dist: markdown (>=3.7)
39
+ Requires-Dist: newscatcherapi (>=0.7.3) ; extra == "apps"
40
+ Requires-Dist: newspaper4k (>=0.9.3.1) ; extra == "apps"
41
+ Requires-Dist: nltk (>=3.9.1)
46
42
  Requires-Dist: numpy (<2)
47
- Requires-Dist: openai (>=1.77.0,<2.0.0)
43
+ Requires-Dist: openai (>=1.77.0)
48
44
  Requires-Dist: opentelemetry-exporter-otlp-proto-grpc (==1.25.0)
49
- Requires-Dist: pandas (>=2.2.2,<3.0.0)
50
- Requires-Dist: plotly (>=5.24.1,<6.0.0)
51
- Requires-Dist: plotly-resampler (>=0.10.0,<0.11.0)
52
- Requires-Dist: pygooglenews (>=0.1.3,<0.2.0) ; extra == "apps"
45
+ Requires-Dist: pandas (>=2.2.2)
46
+ Requires-Dist: plotly (>=5.24.1)
47
+ Requires-Dist: plotly-resampler (>=0.10.0)
48
+ Requires-Dist: pygooglenews (>=0.1.3) ; extra == "apps"
53
49
  Requires-Dist: pylabeladjust (==0.1.13)
54
- Requires-Dist: pytest (>=8.3.3,<9.0.0) ; extra == "tests"
55
- Requires-Dist: requests (>=2.32.3,<3.0.0)
56
- Requires-Dist: scikit-learn (>=1.5.2,<2.0.0)
50
+ Requires-Dist: pytest (>=8.3.3)
51
+ Requires-Dist: requests (>=2.32.3)
52
+ Requires-Dist: scikit-learn (>=1.5.2)
57
53
  Requires-Dist: scipy (==1.12)
58
- Requires-Dist: seaborn (>=0.13.2,<0.14.0)
54
+ Requires-Dist: seaborn (>=0.13.2)
59
55
  Requires-Dist: sentence-transformers (==3.0.1)
60
- Requires-Dist: sentencepiece (>=0.2.0,<0.3.0)
61
- Requires-Dist: streamlit (>=1.45.0,<2.0.0)
62
- Requires-Dist: streamlit-code-editor (>=0.1.22,<0.2.0)
63
- Requires-Dist: thefuzz (>=0.22.1,<0.23.0)
64
- Requires-Dist: tiktoken (>=0.8.0,<0.9.0)
56
+ Requires-Dist: sentencepiece (>=0.2.0)
57
+ Requires-Dist: starlette (>=0.46.2)
58
+ Requires-Dist: streamlit (>=1.45.0)
59
+ Requires-Dist: streamlit-code-editor (>=0.1.22)
60
+ Requires-Dist: thefuzz (>=0.22.1)
61
+ Requires-Dist: tiktoken (>=0.8.0)
65
62
  Requires-Dist: tldextract (>=2.0.1)
66
63
  Requires-Dist: tokenizers (<0.20.0)
67
- Requires-Dist: torch (>=2.5.1,<3.0.0)
68
- Requires-Dist: tqdm (>=4.67.1,<5.0.0)
69
- Requires-Dist: umap-learn (>=0.5.7,<0.6.0)
64
+ Requires-Dist: torch (>=2.7.0)
65
+ Requires-Dist: tqdm (>=4.67.1)
66
+ Requires-Dist: umap-learn (>=0.5.7)
67
+ Project-URL: Bug Tracker, https://github.com/rte-france/BERTrend/issues
68
+ Project-URL: Documentation, https://github.com/rte-france/BERTrend
69
+ Project-URL: Homepage, https://github.com/rte-france/BERTrend
70
70
  Project-URL: Repository, https://github.com/rte-france/BERTrend
71
71
  Description-Content-Type: text/markdown
72
72
 
73
73
  # BERTrend
74
74
 
75
75
  [![rte-france - BERTrend](https://img.shields.io/static/v1?label=rte-france&message=BERTrend&color=blue&logo=github)](https://github.com/rte-france/BERTrend "Go to GitHub repo")
76
- ![GitHub License](https://img.shields.io/github/license/rte-france/BERTrend)
77
76
  [![stars - BERTrend](https://img.shields.io/github/stars/rte-france/BERTrend?style=social)](https://github.com/rte-france/BERTrend)
78
77
  [![forks - BERTrend](https://img.shields.io/github/forks/rte-france/BERTrend?style=social)](https://github.com/rte-france/BERTrend)
79
78
  [![issues - BERTrend](https://img.shields.io/github/issues/rte-france/BERTrend)](https://github.com/rte-france/BERTrend/issues)
80
- ![Static Badge](https://img.shields.io/badge/python-%3E%3D3.12-blue)
79
+ [![Downloads](https://pepy.tech/badge/bertrend)](https://pepy.tech/project/bertrend)
80
+ [![PyPi_Version](https://img.shields.io/pypi/v/bertrend.svg)](https://pypi.org/project/bertrend/)
81
+ [![PyPi_Compat](https://img.shields.io/pypi/pyversions/bertrend.svg)](https://pypi.org/project/bertrend/)
82
+ ![GitHub License](https://img.shields.io/github/license/rte-france/BERTrend)
81
83
 
82
84
  ![BERTrend pipeline](./BERTrend_overview.png)
83
85
 
84
- ## Work in progress
85
-
86
- - make BERTrend available as a python package in PyPI
87
-
88
86
  ## Paper
89
87
 
90
88
  The code in this repository is part of the work described in the paper:
@@ -139,7 +137,7 @@ https://github.com/user-attachments/assets/d79368d9-d4e0-4324-8a98-a888f0ab3b65
139
137
  - Categorization of signals into three different dataframes: noise, weak and strong signals
140
138
  (each dataframe contains useful information about the signals)
141
139
  - Interpretation of these signals using LLMs
142
- - Inspection of topic merging process using Sankey diagram
140
+ - Inspection of the topic merging process using Sankey diagram
143
141
 
144
142
  ## Installation
145
143
 
@@ -164,25 +162,26 @@ BERTrend requires the following environment variables to be set:
164
162
 
165
163
  `python -m venv <path>/bertrend`
166
164
 
165
+
166
+ - Installation from pypi
167
+
168
+ `pip install bertrend`
169
+
170
+
167
171
  - Install using pip or poetry in the BERTrend home directory:
168
172
 
169
173
  ```bash
170
174
  # Basic installation with core dependencies
171
175
  pip install . # or poetry install
172
176
 
173
- # Installation with test dependencies
174
- pip install ".[tests]" # or poetry install --with test
175
-
176
- # Installation with apps dependencies
177
- pip install ".[apps]" # or poetry install --with apps
177
+ # Installation with apps dependencies
178
+ pip install ".[apps]" # or poetry install --extras apps
178
179
 
179
- # Installation with all optional dependencies
180
- pip install ".[tests,apps]" # or poetry install --with test,apps
181
180
  ```
182
181
 
183
182
  - (Use `pip install -e .` for a local installation)
184
183
 
185
- NB. Due to the number of dependencies, the installation may take some time on an empty environement.
184
+ NB. Due to the number of dependencies, the installation may take some time on an empty environment.
186
185
 
187
186
  ### Dependency Management
188
187
 
@@ -228,7 +227,7 @@ For custom dataset creation, please refer to the documentation page about [data
228
227
 
229
228
  In order to use the provided demos, datasets :
230
229
  - can be stored on the server in: `$BERTREND_BASE_DIR/data/bertrend/`
231
- - or can be uploaded from the client device on which is displayed the Streamlit apps.
230
+ - or can be uploaded from the client device on which are displayed the Streamlit apps.
232
231
 
233
232
  #### Dataset Format
234
233
  Required columns:
@@ -255,6 +254,13 @@ CUDA_VISIBLE_DEVICES=<gpu_number> streamlit run app.py
255
254
  - `Parameters`: Include all BERTopic parameters. Choose the embedding model carefully based on your data language.
256
255
  The embedding model can run locally (a GPU is recommended); it is also possible to use a remote embedding service.
257
256
 
257
+ We recommend using a remote embedding service (this is now the default config) as it simplifies the computing.
258
+
259
+ The change of configuration can be done in: [services_default_config.toml](bertrend/config/services_default_config.toml).
260
+
261
+ An example of a very simple implementation to deploy a separate embedding service can be found here: https://github.com/rte-france/wattelse/tree/main/wattelse/api/embedding. (this implementation is compatible with our code)
262
+
263
+
258
264
  ![parameters](docs/images/parameters.png)
259
265
 
260
266
  Please refer to the [BERTopic documentation](https://maartengr.github.io/BERTopic/algorithm/algorithm.html) for parameter details.
@@ -273,7 +279,7 @@ The application is split into several pages:
273
279
  - Computes topics over time
274
280
  ![exploration_over_time](./docs/images/explore1.png)
275
281
 
276
- - Allow to select sources and generate short descriptions for each theme
282
+ - Allow selecting sources and generating short descriptions for each theme
277
283
  ![topic_exploration](./docs/images/explore2.png)
278
284
 
279
285
  - `Topic visualization`: Several visualization types available:
@@ -291,7 +297,7 @@ The application is split into several pages:
291
297
  ![temptopic_metrics](./docs/images/temptopic_metrics.png)
292
298
 
293
299
  - `Generate Newsletters`
294
- - This is an example of application combining topic analysis and LLMs
300
+ - This is an example of an application combining topic analysis and LLMs
295
301
  - Generates newsletters based on prominent topics
296
302
  - Uses LLMs to generate topic descriptions and summarize representative documents
297
303
 
@@ -340,8 +346,8 @@ Provides various statistics about topics:
340
346
  - As topics are hard to interprete by humans, we showcase how it can be
341
347
  done using LLMs.
342
348
  - Choose a specific topic and click on the button to generate an interpretation
343
- - LLM-based in-depth signal analysis is done using predefined templates for example:
344
- - describe what happens since last timestamp (summary of main events)
349
+ - LLM-based in-depth signal analysis is done using predefined templates, for example:
350
+ - describe what's happened since the last timestamp (summary of main events)
345
351
  - present through a multi-faceted description info about key developments, foreseen changes, potential impact, etc.
346
352
 
347
353
 
@@ -369,7 +375,7 @@ See [AUTHORS](./AUTHORS.txt) for the full list of contributors.
369
375
 
370
376
  ## License Information
371
377
 
372
- Copyright 2023-2025 RTE France RTE: http://www.rte-france.com
378
+ Copyright 2023–2025 RTE France RTE: http://www.rte-france.com
373
379
 
374
380
  This Source Code is subject to the terms of the Mozilla Public License (MPL) v2 also available here: https://www.mozilla.org/en-US/MPL/2.0/
375
381
 
@@ -1,18 +1,16 @@
1
1
  # BERTrend
2
2
 
3
3
  [![rte-france - BERTrend](https://img.shields.io/static/v1?label=rte-france&message=BERTrend&color=blue&logo=github)](https://github.com/rte-france/BERTrend "Go to GitHub repo")
4
- ![GitHub License](https://img.shields.io/github/license/rte-france/BERTrend)
5
4
  [![stars - BERTrend](https://img.shields.io/github/stars/rte-france/BERTrend?style=social)](https://github.com/rte-france/BERTrend)
6
5
  [![forks - BERTrend](https://img.shields.io/github/forks/rte-france/BERTrend?style=social)](https://github.com/rte-france/BERTrend)
7
6
  [![issues - BERTrend](https://img.shields.io/github/issues/rte-france/BERTrend)](https://github.com/rte-france/BERTrend/issues)
8
- ![Static Badge](https://img.shields.io/badge/python-%3E%3D3.12-blue)
7
+ [![Downloads](https://pepy.tech/badge/bertrend)](https://pepy.tech/project/bertrend)
8
+ [![PyPi_Version](https://img.shields.io/pypi/v/bertrend.svg)](https://pypi.org/project/bertrend/)
9
+ [![PyPi_Compat](https://img.shields.io/pypi/pyversions/bertrend.svg)](https://pypi.org/project/bertrend/)
10
+ ![GitHub License](https://img.shields.io/github/license/rte-france/BERTrend)
9
11
 
10
12
  ![BERTrend pipeline](./BERTrend_overview.png)
11
13
 
12
- ## Work in progress
13
-
14
- - make BERTrend available as a python package in PyPI
15
-
16
14
  ## Paper
17
15
 
18
16
  The code in this repository is part of the work described in the paper:
@@ -67,7 +65,7 @@ https://github.com/user-attachments/assets/d79368d9-d4e0-4324-8a98-a888f0ab3b65
67
65
  - Categorization of signals into three different dataframes: noise, weak and strong signals
68
66
  (each dataframe contains useful information about the signals)
69
67
  - Interpretation of these signals using LLMs
70
- - Inspection of topic merging process using Sankey diagram
68
+ - Inspection of the topic merging process using Sankey diagram
71
69
 
72
70
  ## Installation
73
71
 
@@ -92,25 +90,26 @@ BERTrend requires the following environment variables to be set:
92
90
 
93
91
  `python -m venv <path>/bertrend`
94
92
 
93
+
94
+ - Installation from pypi
95
+
96
+ `pip install bertrend`
97
+
98
+
95
99
  - Install using pip or poetry in the BERTrend home directory:
96
100
 
97
101
  ```bash
98
102
  # Basic installation with core dependencies
99
103
  pip install . # or poetry install
100
104
 
101
- # Installation with test dependencies
102
- pip install ".[tests]" # or poetry install --with test
103
-
104
- # Installation with apps dependencies
105
- pip install ".[apps]" # or poetry install --with apps
105
+ # Installation with apps dependencies
106
+ pip install ".[apps]" # or poetry install --extras apps
106
107
 
107
- # Installation with all optional dependencies
108
- pip install ".[tests,apps]" # or poetry install --with test,apps
109
108
  ```
110
109
 
111
110
  - (Use `pip install -e .` for a local installation)
112
111
 
113
- NB. Due to the number of dependencies, the installation may take some time on an empty environement.
112
+ NB. Due to the number of dependencies, the installation may take some time on an empty environment.
114
113
 
115
114
  ### Dependency Management
116
115
 
@@ -156,7 +155,7 @@ For custom dataset creation, please refer to the documentation page about [data
156
155
 
157
156
  In order to use the provided demos, datasets :
158
157
  - can be stored on the server in: `$BERTREND_BASE_DIR/data/bertrend/`
159
- - or can be uploaded from the client device on which is displayed the Streamlit apps.
158
+ - or can be uploaded from the client device on which are displayed the Streamlit apps.
160
159
 
161
160
  #### Dataset Format
162
161
  Required columns:
@@ -183,6 +182,13 @@ CUDA_VISIBLE_DEVICES=<gpu_number> streamlit run app.py
183
182
  - `Parameters`: Include all BERTopic parameters. Choose the embedding model carefully based on your data language.
184
183
  The embedding model can run locally (a GPU is recommended); it is also possible to use a remote embedding service.
185
184
 
185
+ We recommend using a remote embedding service (this is now the default config) as it simplifies the computing.
186
+
187
+ The change of configuration can be done in: [services_default_config.toml](bertrend/config/services_default_config.toml).
188
+
189
+ An example of a very simple implementation to deploy a separate embedding service can be found here: https://github.com/rte-france/wattelse/tree/main/wattelse/api/embedding. (this implementation is compatible with our code)
190
+
191
+
186
192
  ![parameters](docs/images/parameters.png)
187
193
 
188
194
  Please refer to the [BERTopic documentation](https://maartengr.github.io/BERTopic/algorithm/algorithm.html) for parameter details.
@@ -201,7 +207,7 @@ The application is split into several pages:
201
207
  - Computes topics over time
202
208
  ![exploration_over_time](./docs/images/explore1.png)
203
209
 
204
- - Allow to select sources and generate short descriptions for each theme
210
+ - Allow selecting sources and generating short descriptions for each theme
205
211
  ![topic_exploration](./docs/images/explore2.png)
206
212
 
207
213
  - `Topic visualization`: Several visualization types available:
@@ -219,7 +225,7 @@ The application is split into several pages:
219
225
  ![temptopic_metrics](./docs/images/temptopic_metrics.png)
220
226
 
221
227
  - `Generate Newsletters`
222
- - This is an example of application combining topic analysis and LLMs
228
+ - This is an example of an application combining topic analysis and LLMs
223
229
  - Generates newsletters based on prominent topics
224
230
  - Uses LLMs to generate topic descriptions and summarize representative documents
225
231
 
@@ -268,8 +274,8 @@ Provides various statistics about topics:
268
274
  - As topics are hard to interprete by humans, we showcase how it can be
269
275
  done using LLMs.
270
276
  - Choose a specific topic and click on the button to generate an interpretation
271
- - LLM-based in-depth signal analysis is done using predefined templates for example:
272
- - describe what happens since last timestamp (summary of main events)
277
+ - LLM-based in-depth signal analysis is done using predefined templates, for example:
278
+ - describe what's happened since the last timestamp (summary of main events)
273
279
  - present through a multi-faceted description info about key developments, foreseen changes, potential impact, etc.
274
280
 
275
281
 
@@ -297,7 +303,7 @@ See [AUTHORS](./AUTHORS.txt) for the full list of contributors.
297
303
 
298
304
  ## License Information
299
305
 
300
- Copyright 2023-2025 RTE France RTE: http://www.rte-france.com
306
+ Copyright 2023–2025 RTE France RTE: http://www.rte-france.com
301
307
 
302
308
  This Source Code is subject to the terms of the Mozilla Public License (MPL) v2 also available here: https://www.mozilla.org/en-US/MPL/2.0/
303
309
 
@@ -126,9 +126,9 @@ def generate_newsletter(
126
126
  # Iterate over topics
127
127
  for i in tqdm(range(top_n_topics), desc="Processing topics..."):
128
128
  sub_df = get_most_representative_docs(
129
- topic_model,
130
- df,
131
- topics,
129
+ topic_model=topic_model,
130
+ df=df,
131
+ topics=topics,
132
132
  mode=top_n_docs_mode,
133
133
  df_split=df_split,
134
134
  topic_number=i,
@@ -2,7 +2,6 @@
2
2
  # See AUTHORS.txt
3
3
  # SPDX-License-Identifier: MPL-2.0
4
4
  # This file is part of BERTrend.
5
- import os
6
5
  import time
7
6
 
8
7
  import requests
@@ -22,7 +22,7 @@ class AbstractiveSummarizer(Summarizer):
22
22
  def __init__(self, model_name=DEFAULT_ABSTRACTIVE_MODEL):
23
23
  self.model_name = model_name
24
24
  self.WHITESPACE_HANDLER = lambda k: re.sub(
25
- "\s+", " ", re.sub("\n+", " ", k.strip())
25
+ r"\s+", " ", re.sub(r"\n+", " ", k.strip())
26
26
  )
27
27
  self.tokenizer = AutoTokenizer.from_pretrained(model_name)
28
28
  self.model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
@@ -35,7 +35,7 @@ class GPTSummarizer(Summarizer):
35
35
  prompt_language: str = "fr",
36
36
  max_article_length: int = 1500,
37
37
  model_name: str = None,
38
- **kwargs
38
+ **kwargs,
39
39
  ) -> str:
40
40
  # Limit input length in case the text is large
41
41
  article_text = keep_first_n_words(article_text, max_article_length)
@@ -0,0 +1,91 @@
1
+ # BERTrend Integration Tests
2
+
3
+ This directory contains integration tests for the BERTrend project. These tests verify that the different components of the system work together correctly in real-world scenarios.
4
+
5
+ ## Overview
6
+
7
+ The integration tests are organized into several test classes, each focusing on a specific integration point:
8
+
9
+ 1. **TestEmbeddingServiceIntegration**: Tests the integration of the EmbeddingService with local embedding models.
10
+ 2. **TestBERTopicModelIntegration**: Tests the integration of BERTopicModel with pre-computed embeddings.
11
+ 3. **TestBERTrendIntegration**: Tests the end-to-end workflow of BERTrend, including training topic models, calculating signal popularity, and classifying signals.
12
+ 4. **TestDataPipelineIntegration**: Tests the data loading and processing pipeline.
13
+ 5. **TestNewsletterIntegration**: Tests the newsletter generation functionality, which combines topic modeling with LLM-based summarization.
14
+
15
+ ## Running the Tests
16
+
17
+ To run the integration tests, you need to have the BERTrend package installed with all its dependencies. You can run the tests using pytest with the following command:
18
+
19
+ ```bash
20
+ pytest -m integration bertrend/tests/test_integration.py -v
21
+ ```
22
+
23
+ This will run only the tests marked with the `integration` marker. The `-v` flag provides verbose output.
24
+
25
+ ### Running Specific Tests
26
+
27
+ To run a specific test class, you can use:
28
+
29
+ ```bash
30
+ pytest -m integration bertrend/tests/test_integration.py::TestBERTrendIntegration -v
31
+ ```
32
+
33
+ To run a specific test method, you can use:
34
+
35
+ ```bash
36
+ pytest -m integration bertrend/tests/test_integration.py::TestBERTrendIntegration::test_bertrend_end_to_end -v
37
+ ```
38
+
39
+ ## Test Requirements
40
+
41
+ The integration tests have the following requirements:
42
+
43
+ 1. **Sentence Transformer Models**: The tests use the `all-MiniLM-L6-v2` model, which will be downloaded automatically if not already present.
44
+ 2. **OpenAI API Key**: The newsletter generation test requires an OpenAI API key. If the key is not available, the test will be skipped.
45
+ 3. **Temporary Directory**: The tests use pytest's `tmp_path` fixture to create temporary directories for saving models and files.
46
+
47
+ ## Adding New Integration Tests
48
+
49
+ When adding new integration tests, please follow these guidelines:
50
+
51
+ 1. Use the `@pytest.mark.integration` decorator to mark the test as an integration test.
52
+ 2. Use small, fast models and synthetic data to ensure the tests run efficiently.
53
+ 3. Include assertions that verify the correct integration between components.
54
+ 4. Handle external dependencies gracefully, skipping tests if necessary.
55
+ 5. Clean up any resources created during the test.
56
+
57
+ ## Example
58
+
59
+ Here's an example of a simple integration test:
60
+
61
+ ```python
62
+ @pytest.mark.integration
63
+ def test_embedding_service_with_local_model():
64
+ """Test that EmbeddingService works with a local model."""
65
+ # Use a small, fast model for testing
66
+ model_name = "all-MiniLM-L6-v2"
67
+
68
+ # Create a small test dataset
69
+ texts = [
70
+ "This is a test document about artificial intelligence.",
71
+ "Machine learning is a subset of artificial intelligence.",
72
+ "Natural language processing is used in many applications."
73
+ ]
74
+
75
+ # Initialize the embedding service with local model
76
+ embedding_service = EmbeddingService(
77
+ local=True,
78
+ model_name=model_name
79
+ )
80
+
81
+ # Generate embeddings
82
+ embeddings, token_strings, token_embeddings = embedding_service.embed(texts)
83
+
84
+ # Verify the results
85
+ assert embeddings is not None
86
+ assert embeddings.shape == (len(texts), 384) # 384 is the dimension for all-MiniLM-L6-v2
87
+ assert token_strings is not None
88
+ assert token_embeddings is not None
89
+ assert len(token_strings) == len(texts)
90
+ assert len(token_embeddings) == len(texts)
91
+ ```
@@ -0,0 +1,11 @@
1
+ # Copyright (c) 2024, RTE (https://www.rte-france.com)
2
+ # See AUTHORS.txt
3
+ # SPDX-License-Identifier: MPL-2.0
4
+ # This file is part of BERTrend.
5
+
6
+ import pytest
7
+
8
+
9
+ def pytest_configure(config):
10
+ """Register custom markers."""
11
+ config.addinivalue_line("markers", "integration: mark test as an integration test")
@@ -36,12 +36,15 @@ def mock_model():
36
36
  @pytest.fixture
37
37
  def mock_abstractive_summarizer(mock_tokenizer, mock_model):
38
38
  """Create a mock AbstractiveSummarizer with mocked dependencies."""
39
- with patch(
40
- "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained",
41
- return_value=mock_tokenizer,
42
- ), patch(
43
- "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained",
44
- return_value=mock_model,
39
+ with (
40
+ patch(
41
+ "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained",
42
+ return_value=mock_tokenizer,
43
+ ),
44
+ patch(
45
+ "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained",
46
+ return_value=mock_model,
47
+ ),
45
48
  ):
46
49
  summarizer = AbstractiveSummarizer()
47
50
  # Set the mocks directly to ensure they're used
@@ -52,11 +55,14 @@ def mock_abstractive_summarizer(mock_tokenizer, mock_model):
52
55
 
53
56
  def test_initialization():
54
57
  """Test that the AbstractiveSummarizer initializes with the correct model."""
55
- with patch(
56
- "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained"
57
- ) as mock_tokenizer, patch(
58
- "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained"
59
- ) as mock_model:
58
+ with (
59
+ patch(
60
+ "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained"
61
+ ) as mock_tokenizer,
62
+ patch(
63
+ "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained"
64
+ ) as mock_model,
65
+ ):
60
66
 
61
67
  # Mock the to() method to avoid device-related issues
62
68
  mock_model.return_value.to.return_value = mock_model.return_value
@@ -124,11 +130,14 @@ def test_custom_model():
124
130
  """Test initialization with a custom model."""
125
131
  custom_model = "custom/model"
126
132
 
127
- with patch(
128
- "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained"
129
- ) as mock_tokenizer, patch(
130
- "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained"
131
- ) as mock_model:
133
+ with (
134
+ patch(
135
+ "bertrend.services.summary.abstractive_summarizer.AutoTokenizer.from_pretrained"
136
+ ) as mock_tokenizer,
137
+ patch(
138
+ "bertrend.services.summary.abstractive_summarizer.AutoModelForSeq2SeqLM.from_pretrained"
139
+ ) as mock_model,
140
+ ):
132
141
 
133
142
  # Mock the to() method to avoid device-related issues
134
143
  mock_model.return_value.to.return_value = mock_model.return_value