-
Notifications
You must be signed in to change notification settings - Fork 48
Feat/cache #400
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
Feat/cache #400
Conversation
atlas/static/index.js
Outdated
@@ -0,0 +1,26 @@ | |||
if(configuration.AFFICHAGE_STAT_GLOBALES) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ajouter un espace entre "if" et "(" pour que cela soit plus lisible.
Idem sur le 2ème "if".
docs/installation.rst
Outdated
:: | ||
|
||
source venv/bin/activate | ||
pip install -r requirements-dev.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il n'y a pas de fichier requirements-dev.txt
. Il faudrait soit le créer (si c'est nécessaire) soit supprimer cette section.
docs/installation.rst
Outdated
:: | ||
|
||
source venv/bin/activate | ||
flask run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avant, il faut ajouter: cp .flaskenv.sample .flaskenv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ne semble pas fonctionner en l'état depuis la racine du dépôt.
Voir le problème indiqué dans le commentaire ci-dessus.
atlas/app.py
Outdated
if __name__ == "__main__": | ||
# validation de la configuration secrète | ||
app = create_app() | ||
app.run( | ||
host="0.0.0.0", | ||
port=secret_conf["GUNICORN_PORT"], | ||
debug=secret_conf["modeDebug"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je n'ai pas réussi à lancer l'appli avec flask run
. J'ai une erreur au lancement:
flask.cli.NoAppException: While importing "atlas.atlas.app", an ImportError was raised:
Traceback (most recent call last):
File "/home/jpmilcent/workspace/cbna/sinp/atlas/venv/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
__import__(module_name)
File "/home/jpmilcent/workspace/cbna/sinp/atlas/atlas/app.py", line 8, in <module>
from atlas.env import config, secret_conf, cache
ModuleNotFoundError: No module named 'atlas.env'
Apparemment, avec ce mécanisme de lancement il faut changer les chemins d'acccès au fichier dans l'appli :
from atlas.env import config, secret_conf, cache
devient
from .env import config, secret_conf, cache
En attendant, de voie comment régler ce problème, j'ai pu lancer l'appli avec python atlas/app.py
après avoir ajouter ceci à la fin de app.py
:
if __name__ == "__main__":
app = create_app()
app.run()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Est-ce que tu as lancé l'application depuis le repertoire 'atlas' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Est-ce que tu as lancé l'application depuis le repertoire 'atlas' ?
J'ai essayé aussi sans succès. Dès que je lance http://127.0.0.1:8081/
dans mon navigateur, j'ai l'erreur.
A noter que le .flaskenv
est à la racine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Le lancement de la commande pip install -e .
dans le dossier contenant le fichier setup.py
ne résout pas le problème.
@cache.cached() | ||
def main_stat(): | ||
connection = utils.engine.connect() | ||
return vmObservationsRepository.statIndex(connection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je suis assez surpris par la rapidité d’exécution des requêtes présentes dans statIndex()
. Le passage à la v1.5 et le changement dans les VM en est peut être à l'origine.
En tout cas, le cache semble remplir son rôle sur une base avec 11 millions d'observations. En relançant, l'appli le cache est bien vidé.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faudrait rajouter du cache pour la section "Nouvelles espèces" et pour la carte "Dernières observations".
Si j'active ces sections sur la page d'accueil, cela ralentie énormément l'affichage avec une base de 11 millions d'observations...
atlas/app.py
Outdated
if __name__ == "__main__": | ||
# validation de la configuration secrète | ||
app = create_app() | ||
app.run( | ||
host="0.0.0.0", | ||
port=secret_conf["GUNICORN_PORT"], | ||
debug=secret_conf["modeDebug"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Est-ce que tu as lancé l'application depuis le repertoire 'atlas' ?
J'ai essayé aussi sans succès. Dès que je lance http://127.0.0.1:8081/
dans mon navigateur, j'ai l'erreur.
A noter que le .flaskenv
est à la racine.
# Temps en seconde de la durée du cache | ||
# utilisé pour les statistiques de la page d'accueil (stats global et rang taxonomique) | ||
# à synchroniser avec le raffraichissement des VM | ||
CACHE_TIMEOUT = fields.Number(load_default=3600) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai du seulement mettre CACHE_TIMEOUT = 3600
ici.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu as fait un pip install -e .
depuis la racine ?
@@ -26,6 +26,8 @@ | |||
$(".lazy").lazy(); | |||
}); | |||
</script> | |||
<script src="{{ url_for('static', filename='index.js') }}"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faudrait rajouter cette ligne dans un test qui vérifie que l'on affiche bien les stats globale sur la page d'accueil : {% if configuration.AFFICHAGE_STAT_GLOBALES or configuration.AFFICHAGE_RANG_STAT %}
.
Sinon, on charge un fichier pour rien...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il y a déjà des IF dans le fichier js. Et si un jour on ajoute encore d'autre truc dans ce index.js, qui eux ne sont pas dépendant de paramètres ..
docs/installation.rst
Outdated
:: | ||
|
||
source venv/bin/activate | ||
flask run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ne semble pas fonctionner en l'état depuis la racine du dépôt.
Voir le problème indiqué dans le commentaire ci-dessus.
Il faudrait passer ces routes en API, et mettre un cache spécifique dessus. J'ai pas le temps de le faire là. Je propose qu'on merge ça en l'état pour éviter que la PR diverge. On pourra le faire par la suite en suivant le même exemple |
@TheoLechemia Ok, ça me va. Par contre, il faut résoudre le problème du |
J'ai relancé un |
243a8f2
to
a02e521
Compare
a02e521
to
3f71b99
Compare
Utilisation de la lib flask-cache pour le calcul des statistiques de la page d'acceuil.
Les stats sont passés en API