Skip to content

Added use fast yaml loader option#77

Merged
JeanLucPons merged 2 commits intomainfrom
add-fast-yaml-loader-option
Nov 18, 2025
Merged

Added use fast yaml loader option#77
JeanLucPons merged 2 commits intomainfrom
add-fast-yaml-loader-option

Conversation

@JeanLucPons
Copy link
Copy Markdown
Contributor

This PR adds an option to use fast yaml loader:

#        use_fast_loader : bool
#            Use fast yaml loader. When specified, no line number are reported in case of error, 
#           only the element name that triggered the error will be reported in the exception)
sr = Accelerator.load("tests/config/EBSOrbit.yaml",use_fast_loader=True)

Copy link
Copy Markdown
Contributor

@gubaidulinvadim gubaidulinvadim left a comment

Choose a reason for hiding this comment

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

For me, this is good. It passes all the tests. The only thing I do not understand is if we have a fast c-loader, what is the point of having a slow loader (and the slow one being the default option)?

@JeanLucPons
Copy link
Copy Markdown
Contributor Author

JeanLucPons commented Nov 18, 2025

For me, this is good. It passes all the tests. The only thing I do not understand is if we have a fast c-loader, what is the point of having a slow loader (and the slow one being the default option)?

As mentioned in the doc, the slow loader prevents to get the line number informations.

Using Fast loader:

pyaml.common.exception.PyAMLConfigException: 'powerconverters': Field required, 'powerconvertes': Extra inputs are not permitted,  for object: 'pyaml.magnet.linear_cfm_model' 

Using slow loader:

pyaml.common.exception.PyAMLConfigException: 'powerconverters': Field required, 'powerconvertes': Extra inputs are not permitted /home/esrf/pons/pyaml/tests/config/EBSOrbit.yaml at line 4739, colum 7,  for object: 'pyaml.magnet.linear_cfm_model' /home/esrf/pons/pyaml/tests/config/EBSOrbit.yaml at line 4724, column 5.

A possible hack for this is to use by default the fast loader and if an errors occurs then reparse using the slow loader.

@JeanLucPons JeanLucPons merged commit 2ac3ded into main Nov 18, 2025
2 checks passed
@JeanLucPons JeanLucPons deleted the add-fast-yaml-loader-option branch November 18, 2025 12:11
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