Skip to content

feat/populate with testing data 88#134

Merged
Marc-AntoineA merged 24 commits intodevfrom
feat/populate-with-testing-data-88
Mar 27, 2025
Merged

feat/populate with testing data 88#134
Marc-AntoineA merged 24 commits intodevfrom
feat/populate-with-testing-data-88

Conversation

@Marc-AntoineA
Copy link
Contributor

@Marc-AntoineA Marc-AntoineA commented Mar 16, 2025

Specs :

@QuentinMadura
Copy link
Contributor

Est-ce que le fait de générer les données fictives au niveau de la CI est dans le scope de cette MR ? Nécessaire notamment #152 qui a besoin de données pour pouvoir interagir avec les éléments de la carte

@Marc-AntoineA Marc-AntoineA changed the title draft: feat/populate with testing data 88 feat/populate with testing data 88 Mar 27, 2025
Copy link
Member

@ludovicdmt ludovicdmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Y faut y faire un peu de ménage mais sinon ça me semble correct, juste une interrogation sur pyproj ?

@receiver(pre_save, sender=Tile)
def before_save_tile(sender, instance, **kwargs):
"""Transform the geometry to the map geometry."""
print("hello")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A enlever

def save_mvt(self, mvt_data, filename):
"""Save the MVT data into the FileField."""
content = ContentFile(mvt_data)
print("fiename is ", filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Du coup en l’occurence c’est bien que j’ai supprimé ici :D

@@ -1,5 +1,19 @@
# Journal de changements

## 🔖 0.3.0 (20225-XX-XX) - XXX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

self.stdout.write(self.style.SUCCESS("> MVT Tiles for plantability computed"))

def handle(self, *args, **options):
self._create_city_and_iris()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self._create_city_and_iris()
if not os.environ.get("E2E_TESTS"):
raise NotImplementedError("This command is only for e2e tests")
self._create_city_and_iris()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux avoir envie de l'utiliser en local pour éviter de te générer toute la DB aussi non ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suite aux échanges sur Slack, on ne fait pas cette modification suggérée.

@maxbellec
Copy link
Contributor

maxbellec commented Mar 27, 2025

je préfère avoir une base de donnée à part pour les tests. Dans DO, j'ai fait

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
    },
    "test": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": "tests_db.sqlite3",
    },
}
if config.getstr("database.engine") == "postgresql":
    DATABASES["default"] = {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": config.getstr("database.name"),  # noqa: F405
        "USER": config.getstr("database.user"),  # noqa: F405
        "PASSWORD": config.getstr("database.password"),  # noqa: F405
    }
if os.environ.get("E2E_TESTS"):
    DATABASES["default"] = DATABASES["test"]

et donc quand je fais les tests je lance E2E_TESTS=1 python manage.py runserver
comme ça en local je peux avoir en parallèle une copie des données de prod ou les données E2E

Copy link
Member

@ludovicdmt ludovicdmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais oublié de regardé là. Bon pour moi et merci pour ce taf !

(x - radius, y - radius),
]
)
# Ce n’est pas au bon endroit ^^
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem

self.stdout.write(self.style.SUCCESS("> Tiles created"))

def _generate_plantability_tiles(self):
random.seed(38250)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien

Comment on lines +142 to +143
for i in range(4):
for j in range(4):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Détail mais j'aime bien itertools.product pour la lisibilité

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En quoi est-ce que tu trouves ça plus lisible ? Est-ce parce qu’on enlève une tabulation ? 

De mon côté, j’ai plus l’habitude des boucles imbriquées que je trouve plus lisibles. Mais dans ce contexte, je m’en moque un peu donc je tente de faire à ta manière.

self.stdout.write(self.style.SUCCESS("> MVT Tiles for plantability computed"))

def handle(self, *args, **options):
self._create_city_and_iris()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tu peux avoir envie de l'utiliser en local pour éviter de te générer toute la DB aussi non ?

@Marc-AntoineA
Copy link
Contributor Author

@ludovicdmt , @maxbellec , pour moi cette base de données n’est pas du tout seulement pour les tests e2e mais surtout pour pouvoir développer en local sans récupérer toute la base de données à chaque fois. Ces derniers jours, ça m’est arrivé plusieurs fois de devoir faire des recever_db_and_media et vraiment très désagréable (plusieurs dizaines de minutes de téléchargement).

C’est d’ailleurs pour que les données puissent co-exister que je n’ai pas généré les données sur Lyon mais ailleurs.

Je suis donc plutôt défavorable à séparer dans une db dédiée.

Copy link
Contributor Author

@Marc-AntoineA Marc-AntoineA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Des commentaires

@Marc-AntoineA Marc-AntoineA merged commit 5fdc221 into dev Mar 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants