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

Évaluer les validateurs GBFS #1891

Closed
AntoineAugusti opened this issue Nov 2, 2021 · 7 comments
Closed

Évaluer les validateurs GBFS #1891

AntoineAugusti opened this issue Nov 2, 2021 · 7 comments
Assignees

Comments

@AntoineAugusti
Copy link
Member

Nous avons l'ambition d'avoir un validateur GBFS sur le PAN. Un outil web, une API, une redirection vers d'autres outils, de la documentation uniquement, on ne sait pas encore.

Cette issue listera ce que j'ai fait et trouvé concernant cette fonctionnalité.

Première étape, j'ai regardé la liste des outils GBFS qui ne comporte qu'un seul validateur, MobilityData/gbfs-validator.

J'ai demandé si on pouvait l'utiliser en CLI ou en API MobilityData/gbfs-validator#53

@AntoineAugusti AntoineAugusti self-assigned this Nov 2, 2021
@AntoineAugusti
Copy link
Member Author

J'ai testé gbfs-validator via l'API "cachée", voici ce que j'obtiens.

Extraction des données

Première étape, sortir une liste des gbfs.json des ressources que l'on a. On a 28 vélos et trottinettes en libre-service sur le site. Certains JDD listent des ressources avec station_(information|status).json en plus de gbfs.json. Le validateur attend comme point d'entrée le gbfs.json.

select r.dataset_id, d.datagouv_id, d.slug, r.url
from dataset d
join resource r on d.id = r.dataset_id
where d.type = 'bike-scooter-sharing' and d.is_active
  and (r.url like '%gbfs.json' or r.format = 'gbfs') and not r.url ~ 'station|free_bike'

me donne 23 lignes sur les 28 jeux de données, sans doublon de dataset_id. En regardant "à la main" les JDD qui ne sont pas dans la liste, il n'y a pas de moyen automatique simple de récupérer des gbfs.json car la ressource n'existe pas ou ce sont des URLs OpenDataSoft.

J'enregistre ceci dans un urls.csv

Appel de l'API

Je fais le code Python 🐍 suivant (pas taper)

import requests
import csv


def is_valid_gbfs(url):
    response = requests.post(
        "https://gbfs-validator.netlify.app/.netlify/functions/validator",
        json={"url": url},
        headers={"user-agent": "[email protected]"},
    )
    try:
        response.raise_for_status()
    except requests.RequestException as e:
        print(f"request failed {str(e)}")
        return
    return response.json()["summary"]


with open("urls.csv") as f:
    reader = csv.DictReader(f)
    for row in reader:
        print(row["url"])
        print(is_valid_gbfs(row["url"]))

et j'obtiens l'output suivant en quelques seconds

https://vannes-gbfs.klervi.net/gbfs/gbfs.json
{'version': {'detected': '1.0', 'validated': '1.0'}, 'hasErrors': False, 'errorsCount': 0}
https://velib-metropole-opendata.smoove.pro/opendata/Velib_Metropole/gbfs.json
request failed 502 Server Error: Bad Gateway for url: https://gbfs-validator.netlify.app/.netlify/functions/validator
None
https://transport.data.gouv.fr/gbfs/creteil/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://data.mobilites-m.fr/api/gbfs/pony_grenoble/gbfs
{'version': {'detected': '2.1', 'validated': '2.1'}, 'hasErrors': True, 'errorsCount': 7}
https://data.mobilites-m.fr/api/gbfs/tier_grenoble/gbfs
{'version': {'detected': '2.2', 'validated': '2.2'}, 'hasErrors': True, 'errorsCount': 9}
https://transport.data.gouv.fr/gbfs/rouen/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/lyon/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/amiens/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/vcub/gbfs.json
{'version': {'detected': '2.0', 'validated': '2.0'}, 'hasErrors': True, 'errorsCount': 549}
https://api.gbfs.v1.ecovelo.mobi/gbfs/velyceo
{'version': {'detected': '1.0', 'validated': '1.0'}, 'hasErrors': True, 'errorsCount': 13}
https://gbfs.getapony.com/v1/grenoble/fr/gbfs.json
{'version': {'detected': '2.1', 'validated': '2.1'}, 'hasErrors': True, 'errorsCount': 14}
https://gbfs.getapony.com/v1/bordeaux/fr/gbfs.json
{'version': {'detected': '2.1', 'validated': '2.1'}, 'hasErrors': True, 'errorsCount': 14}
https://gbfs.getapony.com/v1/paris/fr/gbfs.json
{'version': {'detected': '2.1', 'validated': '2.1'}, 'hasErrors': True, 'errorsCount': 14}
https://gbfs.getapony.com/v1/angers/fr/gbfs.json
{'version': {'detected': '2.1', 'validated': '2.1'}, 'hasErrors': True, 'errorsCount': 14}
https://transport.data.gouv.fr/gbfs/toulouse/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/cergy-pontoise/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/mulhouse/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/nancy/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/marseille/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://transport.data.gouv.fr/gbfs/nantes/gbfs.json
{'version': {'detected': '1.1', 'validated': '1.1'}, 'hasErrors': False, 'errorsCount': 0}
https://gateway.prod.zoov.io/gbfs/2.2/saclay/en/gbfs.json?key=NGFlMjU3MDUtNDk5My00MTM4LTk1ZjctNmNlNDM1MWQ0NjE1
{'version': {'detected': '2.2', 'validated': '2.2'}, 'hasErrors': True, 'errorsCount': 1}
https://transport.data.gouv.fr/gbfs/vlille/gbfs.json
{'version': {'detected': '2.0', 'validated': '2.0'}, 'hasErrors': True, 'errorsCount': 252}
https://gateway.prod.zoov.io/gbfs/2.2/bordeaux/en/gbfs.json?key=NGFlMjU3MDUtNDk5My00MTM4LTk1ZjctNmNlNDM1MWQ0NjE1
{'version': {'detected': '2.2', 'validated': '2.2'}, 'hasErrors': True, 'errorsCount': 1}

plutôt satisfaisant !

@AntoineAugusti
Copy link
Member Author

J'en profite pour signaler l'erreur de timeout pour le GBFS de Smoove à Paris MobilityData/gbfs-validator#55

@AntoineAugusti
Copy link
Member Author

J'ai ouvert des issues pour les flux GBFS que le PAN diffuse et où il y a actuellement des erreurs de validation #1895 #1896

@AntoineAugusti
Copy link
Member Author

J'ai contacté par email Pony pour les erreurs GBFS pour les URLS https://gbfs.getapony.com/v1/*

@AntoineAugusti
Copy link
Member Author

J'ai ouvert une PR MobilityData/gbfs-validator#56 pour pouvoir passer directement une URL de GBFS au validateur web (par exemple https://gbfs-validator.netlify.app/?url=https://transport.data.gouv.fr/gbfs/amiens/gbfs.json).

On pourrait s'en servir pour afficher un nombre d'erreurs sur le PAN et faire un lien vers le validateur GBFS, dans un premier temps.

@AntoineAugusti
Copy link
Member Author

J'ai envoyé un email à Grenoble pour les informer des erreurs sur les flux GBFS de Tier et Pony

@AntoineAugusti
Copy link
Member Author

Fait dans la PR citée !

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

No branches or pull requests

1 participant