feat: add decorator to check if las file is written correctly#194
feat: add decorator to check if las file is written correctly#194nlenglet-ign wants to merge 5 commits into
Conversation
edefac5 to
4e407a1
Compare
| @@ -0,0 +1,80 @@ | |||
| """Check if a LAS file is written correcty and can be opened by PDAL""" | |||
There was a problem hiding this comment.
Je trouve pas ce commentaire utile, le nom du fichier check_las est assez explicite
| function runs. Set ``filepath_param`` to use another parameter (e.g. ``"output_file"``). | ||
| Set ``when="after"`` to validate the file after the decorated function returns. | ||
|
|
||
| Usage:: |
| if check_pdal_can_open_file(filepath): | ||
| return True | ||
| else: | ||
| # Sometimes TScan has not fully written the output file yet when we parse the report. |
There was a problem hiding this comment.
tu peux enlever la mention à TScan stp ?
|
|
||
| @functools.wraps(fn) | ||
| def wrapper(*args, **kwargs): | ||
| if when == "before": |
There was a problem hiding this comment.
je pense que tu t'es compliqué la vie, yu a pas besoin de faire le check avant de lancer la fonction (ou si ?), j'aurais mis ça seulement après avoir exécuté la fonction décorée
There was a problem hiding this comment.
Effectivement, pas besoin d'exécuter le décorateur avant la fonction décorée, j'ai juste laissé le comportement "after"
|
|
||
| def resolve_filepath(*args, **kwargs) -> str: | ||
| bound = sig.bind_partial(*args, **kwargs) | ||
| param_name = filepath_param or first_param |
There was a problem hiding this comment.
c'est pour gérer quel cas le principe de supposer que le fichier de sortie est le 1er paramètre ? (j'ai l'impression que le comportement où tu donnes le nom de ton paramètre de fichier de sortie suffit)
| # sig = inspect.signature(fn) | ||
| # first_param = next(iter(sig.parameters)) | ||
|
|
||
| def resolve_filepath(*args, **kwargs) -> str: | ||
| bound = sig.bind_partial(*args, **kwargs) | ||
| param_name = filepath_param or first_param | ||
| if param_name not in bound.arguments: | ||
| bound.apply_defaults() | ||
| return str(bound.arguments[param_name]) | ||
| # def resolve_filepath(*args, **kwargs) -> str: | ||
| # bound = sig.bind_partial(*args, **kwargs) | ||
| # param_name = filepath_param or first_param | ||
| # if param_name not in bound.arguments: | ||
| # bound.apply_defaults() | ||
| # return str(bound.arguments[param_name]) |
|
|
||
| def test_check_pdal_can_open_file_with_retry(): | ||
| filepath = os.path.join(INPUT_DIR, "Semis_2022_0906_6665_LA93_IGN69_ok.laz") | ||
| assert check_pdal_can_open_file_with_retry(filepath, 10) |
There was a problem hiding this comment.
pou garder des tests rapides, je pense que tu peux mettre 1s au lieu de 10 dans tes tests
No description provided.