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

Enhanced error handling and design of parse_data #30

Conversation

asgibson
Copy link
Contributor

@asgibson asgibson commented Sep 5, 2023

FileNotFoundError when config file path results in 0 read files

Data influx now denoted as required and optional in comments

  • required data will stop execution with error
  • required data was updated with error handling
  • optional data does not stop execution
  • optional data retained its original behaviors:
    • booleans are optional, but become None not False when missing
    • benchmark data sets until fail then passes in a "don't care" fashion

KeyError catch for required data now extends original key error

  • includes config_filepath
  • includes key value that failed

Updated and added approprate unit tests

  • needed return values with length for config.read call
  • added error handling tests

FileNotFoundError when config file path results in 0 read files
Data influx now denoted as required and optional in comments
  required data will stop execution with error
  required data was updated with error handling
  optional data does not stop execution
  optional data reatained its original behaviors:
    booleans are optional, but become None not False when missing
    benchmark data sets until fail then passes in a "don't care" fashion
KeyError catch for required data now extends original key error
  includes config_filepath
  includes key value that failed
Updated and added approprate unit tests
  needed return values with length for config.read call
  added error handling tests
@asgibson asgibson added the bug Something isn't working label Sep 5, 2023
@asgibson asgibson added this to the OnAIR 1.0 refactor milestone Sep 5, 2023
@asgibson asgibson self-assigned this Sep 5, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #30 (0873b5d) into main (7552b33) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main       #30   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           25        25           
  Lines         1164      1169    +5     
  Branches       155       156    +1     
=========================================
+ Hits          1164      1169    +5     
Files Changed Coverage Δ
onair/src/run_scripts/execution_engine.py 100.00% <100.00%> (ø)

@asgibson
Copy link
Contributor Author

asgibson commented Sep 5, 2023

Tested by altering config file used by driver.py.

Missing output:
...
File ".../OnAIR/onair/src/run_scripts/execution_engine.py", line 67, in parse_configs
raise FileNotFoundError(f"Config file at '{config_filepath}' could not be read.")
FileNotFoundError: Config file at './onair/config/missing_config.ini' could not be read.

Missing required key:
...
File ".../python3.9/configparser.py", line 1257, in __getitem__
raise KeyError(key)
KeyError: 'MetaFiles'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
...
File ".../OnAIR/onair/src/run_scripts/execution_engine.py", line 82, in parse_configs
raise KeyError(new_message) from e
KeyError: "Config file: './onair/config/missing_key_config.ini', missing key: MetaFiles"

Copy link
Contributor

@the-other-james the-other-james left a comment

Choose a reason for hiding this comment

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

Confirmed the new error message on my machine, and unit test coverage 100%. Code looks good. Thanks!

@asgibson asgibson merged commit 7372f2a into main Sep 6, 2023
2 checks passed
@asgibson asgibson deleted the 17-create-an-accurate-error-message-for-when-a-config-file-is-not-set-or-is-no-set-correctly branch September 6, 2023 14:21
the-other-james added a commit to dennisafa/OnAIR that referenced this pull request Feb 23, 2024
…parser_util-py-to-100-percent' into 'main'

Updates for testing parser_util.py

Closes nasa#30

See merge request cFS_lab/raisr_nos3/raisr-2.0!18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an accurate error message for when a config file is not set (or is no set correctly)
3 participants