Skip to content

Conversation

@Frosty2500
Copy link
Contributor

@Frosty2500 Frosty2500 commented Apr 17, 2025

Previously, the failsafe parameter, allowing to skip errors and only log them as warnings instead, only existed for JSON and XML (de-)serialization.

This PR extends the feature to also be included when reading and writing AASX files.
For this, we add the failsafe boolean attribute to the AASXReader and AASXWriter classes in adapter.aasx.
If failsafe is True, the document is parsed in a failsafe way: Missing attributes and elements are logged instead of causing exceptions. Defect objects are skipped. The default value is False, keeping the existing behavior.

Furthermore, we do a little code-style clean up on string-formatting in the adapter.aasx module, updating all occurrences from (historically) different syntaxes to the more modern f-string syntax.

Fixes #228

Copy link
Contributor

@s-heppner s-heppner left a comment

Choose a reason for hiding this comment

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

Thank you! I see two things that still need some discussion:

  • Do we really need the new class FailsafeConfigurable? It is a very shallow class with only one boolean parameter. I get that it standardizes the interface of how to interact with the failsafe configuration, but on the other hand, it adds additional complexity to each of the classes that inherit from it, for what could also be a simple attribute that "by chance" (our design) is the same across all of them.
  • We could think about in some cases to return a logger.error instead of logger.warning, This still doesn't cause an exception, but for example when no AASX could be found, this could be seen as a more severe problem than just awarning.

Let's talk about this in our next meeting.

@Frosty2500
Copy link
Contributor Author

I adapted one logger.warning to a logger.error but I am not sure about the rest. You can also gladly just write here what you think about them.
For the AASX I think it is ok to only give a warning when there are no AAS since one could have a process that automatically generates AASX and sometimes generates empty ones. Expect if we want to discourage this type of behaviour.

Copy link
Contributor

@s-heppner s-heppner left a comment

Choose a reason for hiding this comment

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

Can you go through the adapter.aasx one more time, adapting all the different string formatting syntaxes to only use "f-strings" (e.g. f"Submodel {submodel} could not be found or similar)?

When this was first written, f-strings did not exist yet and imo it's a bit messy that different syntax styles are used within one project, so this is a good opportunity to start cleaning this up, at least for aasx now.

Copy link
Contributor

@s-heppner s-heppner left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you very much!

@s-heppner s-heppner merged commit e043960 into eclipse-basyx:develop May 31, 2025
15 checks passed
@s-heppner s-heppner deleted the add_failsafe branch May 31, 2025 10:24
zrgt pushed a commit to rwth-iat/basyx-python-sdk that referenced this pull request Nov 18, 2025
…yx#378)

Previously, the `failsafe` parameter, allowing to skip errors and only 
log them as warnings instead, only existed for JSON and XML 
(de-)serialization. 

This PR extends the feature to also be included when reading and 
writing AASX files. For this, we add the `failsafe` boolean attribute 
to the `AASXReader` and `AASXWriter` classes in `adapter.aasx`. 
If `failsafe` is `True`, the document is parsed in a failsafe way: 
Missing attributes and elements are logged instead of causing 
exceptions. Defect objects are skipped. The default value is `False`, 
keeping the existing behavior.

Furthermore, we do a little code-style clean up on string-formatting 
in the `adapter.aasx` module, updating all occurrences from 
(historically) different syntaxes to the more modern f-string syntax.

Fixes eclipse-basyx#228
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.

2 participants