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

Gracefully handle errors when scan file is no longer valid #7

Open
padraic-shafer opened this issue Apr 25, 2023 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@padraic-shafer
Copy link
Collaborator

Issue

When an input scan file is modified after the scan is run, the data file can no longer rely on the scan file for recreating its scan parameters. There is no robust way to track when the scan file is no longer consistent with data file, until an error is found by comparing their contents.

In addition to logical errors (mismatched values or columns),als.bcs.scans.import_scan_file() and als.bcs.scans.get_scan_line_numbers() can raise exceptions when the following are true:

  • The scan file has been modified
  • There are more data files (file_number) than there are "file" commands in the scan file
  • If there are multiple blank lines after a "file" command, als.bcs.scans.import_scan_file() will import an empty dataframe when it should have ignored the blank lines
    • Symptom: "AttributeError: float has no attribute strip..."
  • If there is one or blank line (or none) after a "file" command, als.bcs.scans.import_scan_file() will fail trying to read the empty line when it should have ignored the blank line
    • Symptom: "EmptyDataError: 'No columns to parse...'"

Background

The scan parameters can be recreated from the data file values, but some assumptions must be made about:

  • The motors that were controlled
  • The precision of the values that were requested
  • The number of scan lines that correspond to the data file (for flying scans).

Recommendations

  • Should probably verify that data file output matches scan file input; the fallback response could be to infer values from the data file (possibly using the scan file motor names)
  • Should gracefully report that data file number exceeds the bounds of the scan file outputs
  • Raise an IndexError (or a subclass) instead of AttributeError or EmptyDataError; include message "data file number exceeds the bounds of the scan file outputs"
  • Should ignore blank lines when parsing scan file; treat them as comment lines
    • BCS appears to ignore them when running a scan
@padraic-shafer padraic-shafer added the bug Something isn't working label Apr 25, 2023
@padraic-shafer padraic-shafer self-assigned this Apr 25, 2023
@padraic-shafer
Copy link
Collaborator Author

This also applies when a data file's scan file is not found.

@padraic-shafer
Copy link
Collaborator Author

Created branch feature/0007/invalid-scan-file.

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

No branches or pull requests

1 participant