Skip to content

feat: add decorator to check if las file is written correctly#194

Open
nlenglet-ign wants to merge 5 commits into
devfrom
feat_check_las
Open

feat: add decorator to check if las file is written correctly#194
nlenglet-ign wants to merge 5 commits into
devfrom
feat_check_las

Conversation

@nlenglet-ign

Copy link
Copy Markdown
Contributor

No description provided.

@nlenglet-ign nlenglet-ign marked this pull request as ready for review June 22, 2026 12:18
@nlenglet-ign nlenglet-ign requested review from blecordix and yoann-apel and removed request for blecordix June 22, 2026 12:18
Comment thread pdaltools/check_las.py Outdated
@@ -0,0 +1,80 @@
"""Check if a LAS file is written correcty and can be opened by PDAL"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Je trouve pas ce commentaire utile, le nom du fichier check_las est assez explicite

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fait

Comment thread pdaltools/check_las.py Outdated
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::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

: en trop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fait

Comment thread pdaltools/check_las.py Outdated
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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tu peux enlever la mention à TScan stp ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fait

Comment thread pdaltools/check_las.py Outdated

@functools.wraps(fn)
def wrapper(*args, **kwargs):
if when == "before":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Effectivement, pas besoin d'exécuter le décorateur avant la fonction décorée, j'ai juste laissé le comportement "after"

Comment thread pdaltools/check_las.py Outdated

def resolve_filepath(*args, **kwargs) -> str:
bound = sig.bind_partial(*args, **kwargs)
param_name = filepath_param or first_param

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)

Comment thread pdaltools/check_las.py
Comment on lines +32 to +40
# 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])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code mort à enlever

Comment thread test/test_check_las.py

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pou garder des tests rapides, je pense que tu peux mettre 1s au lieu de 10 dans tes tests

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

Successfully merging this pull request may close these issues.

3 participants