-
Notifications
You must be signed in to change notification settings - Fork 37
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
(BSR)[API] feat: extract import_deposit_csv command logic for reuse p… #15151
Conversation
) -> None: | ||
if not os.path.exists(path): | ||
logger.error("The given file does not exist") | ||
return |
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.
Peut-être on peut raiser dans ce cas ? Histoire d'avoir une gestion d'erreur consistante (et qui remonte jusqu'a l'execution github action). Sinon on risque de passer a coté d'erreur
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.
pourquoi pas en effet
educational_year = educational_repository.get_educational_year_beginning_at_given_year(year) | ||
except educational_exceptions.EducationalYearNotFound: | ||
logger.error("Educational year not found for year %s", year) | ||
return |
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.
Idem
headers = csv_rows.fieldnames | ||
if not headers or ("UAICode" not in headers and "UAI" not in headers): | ||
logger.error("UAICode or depositAmount missing in CSV headers") | ||
return |
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.
Idem
amount = Decimal(row["Effectif"]) * Decimal(row["montant par élève"]) | ||
else: | ||
logger.error("Now way to get the amount found") | ||
return |
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.
Idem (a mon d'accepter un import partiel)
if not_found_uais: | ||
logger.error("UAIs not found in adage: %s", not_found_uais) | ||
return |
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 cela correspond aux cas que tu as remonté ? Si oui, peut-être on change la logique pour en faire des warnings et les ignorer (non bloquant pour la reste)
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.
Sur les tests staging, on a eu 2 cas : des établissements récemment fermés et un UAI qui avait une faute de frappe
Du coup je pense qu'il vaut mieux s'arrêter dans ce cas, remonter les UAI sur le channel Adage et aviser
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.
Typiquement pour le cas de l'UAI avec une faute, il faut mettre la bonne valeur dans le fichier et relancer
@@ -127,6 +190,8 @@ def import_deposit_institution_data( | |||
|
|||
if commit: | |||
db.session.commit() | |||
else: | |||
db.session.flush() |
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 pense qu'un log final avec notamment les montant importés facilitera validation/debug
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.
Genre la somme des amount ? Dans la doc du job console on a :
Il est interdit de print ou logger.* données à caractère personnel, pour cela [utiliser des outputs via [OUTPUT_DIRECTORY]
Je sais pas si c'est une donnée "sensible"
Les autres logs sont sur des UAIs qui sont publics, ça m'a paru OK
…lus small improvements
266fa0a
to
c185003
Compare
…lus small improvements
But de la pull request
Ticket Jira (ou description si BSR) : extraction de la logique de la commande Flask
import_deposit_csv
pour pouvoir réutiliser (dans un script par exemple) + petites améliorations (log au lieu de print, check de tous les UAIs du fichier avant de return)Vérifications