Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing error in parameters_filters.yaml causes file to be over-written #238

Open
hillsandales opened this issue Jun 19, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@hillsandales
Copy link
Contributor

Given this custom file:

parameters_filters.yaml

Capacitors:
- Value
- Rated Voltage
- Tolerance
- Package Type
- Temperature Grade
Circuit Protections:
- Value
Connectors:
- Value
Crystals and Oscillators:
- Value
- Package Type
- Package Size
- Temperature Range
Diodes:
- Value
Inductors:
- Value
- Rated Current
- Package Type
- Package Size
- Temperature Range
Integrated Circuits:
- Value
Mechanicals:
- Value
Modules:
- null
Power Management:
- Value
Printed-Circuit Boards:
- null
RF:
- Value
Resistors:
- Value
- Tolerance
- Rated Power
- Package Type
- Temperature Range
Transistors:
- Value
- Collector Gate Voltage
- ECCN
- Footprint
- Frequency
- Function Type
- Gain (hFE)
- Maximum Gate Voltage
- Mounting Type
- Package Type
- Packaging
- Rated Current
- Rated Power
- Rated Voltage
- RDS On Resistance
- Symbol
- Temperature Range

If there's a formatting error on the first item in the list under a category, it causes the entire file to be overwritten by the default file.

If by accident, the file changes like this for one category:

Transistors:
   - Value
- Collector Gate Voltage
- ECCN
- Footprint
- Frequency
- Function Type
- Gain (hFE)
- Maximum Gate Voltage
- Mounting Type
- Package Type
- Packaging
- Rated Current
- Rated Power
- Rated Voltage
- RDS On Resistance
- Symbol
- Temperature Range

When the program is re-launched, and the file is checked, the file is over-written and looks like this:

Capacitors:
- Value
- Rated Voltage
- Tolerance
- Package Type
- Temperature Grade
Circuit Protections:
- Value
Connectors:
- Value
Crystals and Oscillators:
- Value
- Package Type
- Package Size
- Temperature Range
Diodes:
- Value
Inductors:
- Value
- Rated Current
- Package Type
- Package Size
- Temperature Range
Integrated Circuits:
- Value
Mechanicals:
- Value
Modules:
- null
Power Management:
- Value
Printed-Circuit Boards:
- null
RF:
- Value
Resistors:
- Value
- Tolerance
- Rated Power
- Package Type
- Temperature Range
Transistors:
- Value

All custom settings are lost. I ran this same test, and added a parameter under a separate category as well. If an error shows up, that other category was also wiped

If an item further down the list is indented by accident like:

Transistors:
- Value
- Collector Gate Voltage
- ECCN
- Footprint
- Frequency
- Function Type
- Gain (hFE)
- Maximum Gate Voltage
- Mounting Type
- Package Type
   - Packaging
- Rated Current
- Rated Power
- Rated Voltage
- RDS On Resistance
- Symbol
- Temperature Range

The new file when relaunched looks like this:

Transistors:
- Value
- Collector Gate Voltage
- ECCN
- Footprint
- Frequency
- Function Type
- Gain (hFE)
- Maximum Gate Voltage
- Mounting Type
- Package Type - Packaging
- Rated Current
- Rated Power
- Rated Voltage
- RDS On Resistance
- Symbol
- Temperature Range

The item is moved up to the previous row, but the rest of the file is not over-written.

The terminal reported things like this:

$ poetry run python -m kintree_gui
while parsing a block mapping
  in "C:\Users\user\kintree\user\parameters_filters.yaml", line 1, column 1
expected <block end>, but found '-'
  in "C:\Users\user\kintree\user\parameters_filters.yaml", line 44, column 1

So it appears to know where in the file something is formatted incorrectly.

Question: Why does the program automatically rewrite or reformat these config files? Is that necessary? Could it instead catch a format exception for the YAML and just exit before launching? If it doesn't launch due to a formatting error, it would allow the formatting error to be fixed and not lose custom settings.

I was changing a lot of these config files trying to get my parameters to populate when creating a part (which is proving difficult as the terminal reports they were not added but I can't figure out why from the output, but not related to this bug), and lost all my custom configured settings. :-(

@T0jan
Copy link
Collaborator

T0jan commented Jun 21, 2024

Rn there is one single function to load all different kinds of config files, resulting in overwriting the user file with the template if anything goes wrong during the load. Due to #228 the handling will most likely change in the future, probably resulting in a slightly different handling of program settings and parameter settings, solving this aspect here too.

I am not sure what would be the best way here instead of overwriting, either starting the program with an visible error message but still being able to create new parts without the functionality or just an error and closing the program right away. I tend to the first one.

@eeintech eeintech added the enhancement New feature or request label Jun 21, 2024
@eeintech
Copy link
Contributor

eeintech commented Jun 21, 2024

@hillsandales Thanks for reporting, it does sound like a niche case scenario and hadn't really ran into it before. Sorry for the data loss... hopefully you got this going after all your effort. It is for sure a feature that needs a bit more polishing and I would appreciate any help improving it 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants