teksi / wastewater

[DEV] Future TEKSI wastewater module, adapted data model to fit VSA-DSS 2020 new standard
https://teksi.github.io/wastewater
GNU General Public License v3.0
2 stars 5 forks source link

DeduplicatedLogger._log() got an unexpected keyword argument stacklevel #471

Open sjib opened 2 days ago

sjib commented 2 days ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Exact steps to reproduce the behavior:

  1. Go to 'INTERLIS Export'
  2. Choose SIA405 Abwasser 2020.1
  3. Start export
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Variable {val} exeeds expected lenght - creates error message with stacklevel, that is not supported

Screenshots / data If applicable, add screenshots or data to help explain your problem. grafik

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

sjib commented 2 days ago

Locks similar to this stacklevel error we had before: https://github.com/teksi/wastewater/issues/172 and that was fixed

    def truncate(self, val, max_length):
        """
        Raises a warning if values gets truncated
        """
        if val is None:
            return None
        if len(val) > max_length:
            logger.warning(f"Value '{val}' exceeds expected length ({max_length})", stacklevel=2)
        return val[0:max_length]
sjib commented 2 days ago

Or is it just creating too many logger.warnings and therefore overflows the variable {var} - what do you think @ponceta

@PeterZamudio and Sandro:

ponceta commented 2 days ago

I can't figure out what's wrong with python but from what I see you have remark fields that are over the limit of 80 characters.

Maybe that's indeed the {val} or {max_length} which is creating trouble.

What I see here is that we have a warning which makes the application crash, this is not great in terms of stability.

@domi4484 add a unit test for this stacklevel argument in https://github.com/QGEP/qgepqwat2ili/pull/170#issuecomment-2421849552 so it should not fail so easily.

We should maybe create such errors in an INTERLIS and a demodata file (with and without errors) to check that the application is handling well these error scenarii as we did with QGEP.

domi4484 commented 2 days ago

Is that with the latest version of the plugin? looking at the line numbers in the stack trace I would say not

ponceta commented 2 days ago

I tried with latest release and it works as expected :

2024-10-25T16:29:21        teksi_wastewater.utils:Value 'Alte Bezeichnung: SH1 AND a very very very very very ververy very very very very ververy very very very very ververy very very very very ververy very very very very very long remark' exceeds expected length (80)