Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ta/fix wordcloud #58

Merged
merged 10 commits into from
Jul 3, 2024
Merged

Ta/fix wordcloud #58

merged 10 commits into from
Jul 3, 2024

Conversation

anquetos
Copy link
Collaborator

@anquetos anquetos commented Jul 2, 2024

Goal

Remove usage of word_cloud library which was causing a resource warning :

ResourceWarning: unclosed file <_io.TextIOWrapper name='C:\\Users\\thoma\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\python-template-Sk64sqGT-py3.12\\Lib\\site-packages\\wordcloud\\stopwords' mode='r' encoding='cp1252'>
  STOPWORDS = set(map(str.strip, open(os.path.join(FILE, 'stopwords')).readlines()))
ResourceWarning: Enable tracemalloc to get the object allocation traceback

This issue is still opened on the repository (amueller/word_cloud#764).

Solution

The word cloud is now created directly with the Pillow library and its ImageDraw and ImageFont modules.

Since it was necessary to specify the ttf file to load in the ImageDraw.truetype() function, font management has been changed from Google API to a local ressource folder app/assets/fonts.

Other ressources of the project as images or CSS files have also been moved to the assets folder.

@anquetos anquetos linked an issue Jul 2, 2024 that may be closed by this pull request
@gaudinnicolas
Copy link
Contributor

@anquetos , ce serait cool d'intégrer #45 à ta PR avant merge. d'après ce que j'ai vu il y a aura quelques conflits à gérer mais principalement des paths. et vu le nouveau assets, c'est une bonne occasion. t'en penses quoi?

@anquetos
Copy link
Collaborator Author

anquetos commented Jul 2, 2024

@gaudinnicolas, oui ce serait bien. Par contre je ne sais pas trop comment faire pour l'intégrer, peux-tu m'aiguiller ?

@anquetos tu peux prendre le zip de https://github.com/QuentinMadura/12_taxobservatory_dataviz/tree/main et copier les images dans assets (remplacer existantes) et il y a 3 fichiers à modifier car 2 images ont été transformées en jpg d'après
QuentinMadura@4025c39

@anquetos
Copy link
Collaborator Author

anquetos commented Jul 2, 2024

@gaudinnicolas, ah ok, tout simplement. Je pensais qu'il y avait moyen de faire un truc via GitHub mais c'est plus simple comme ça.
Je le ferai demain matin.

@anquetos anquetos linked an issue Jul 3, 2024 that may be closed by this pull request
@anquetos
Copy link
Collaborator Author

anquetos commented Jul 3, 2024

Update

@gaudinnicolas gaudinnicolas merged commit 7a2fade into dev Jul 3, 2024
1 check passed
@gaudinnicolas gaudinnicolas deleted the ta/fix-wordcloud branch July 3, 2024 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Front - Performance / Intégration / Accessibilité / SEO [Home] - ResourceWarning nuage de mots
2 participants