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

[BUG] Confusing traceback on invalid file #686

Open
oerc0122 opened this issue Feb 27, 2025 · 0 comments
Open

[BUG] Confusing traceback on invalid file #686

oerc0122 opened this issue Feb 27, 2025 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@oerc0122
Copy link
Collaborator

oerc0122 commented Feb 27, 2025

Description of the error
On providing an invalid file to any IJob, the traceback refers to an KeyError in selection_length rather than stating the file doesn't exist. While this is reported in the logs, so MDANSE apparantly knows.

Describe the expected result
A FileNotFoundError raised with a useful message.

Describe the actual result

Log
Could not use xxxx as input trajectory
IJob did not find 'write_logs' in output_files
Job failed with traceback: Traceback (most recent call last):
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/IJob.py", line 395, in run
    self.initialize()
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/VelocityAutoCorrelationFunction.py", line 114, in initialize
    self.numberOfSteps = self.configuration["atom_selection"]["selection_length"]
KeyError: 'selection_length'

Traceback (most recent call last):
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/IJob.py", line 395, in run
    self.initialize()
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/VelocityAutoCorrelationFunction.py", line 114, in initialize
    self.numberOfSteps = self.configuration["atom_selection"]["selection_length"]
KeyError: 'selection_length'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jacob/MDANSE/MDANSE/Tests/UnitTests/Analysis/tmp.py", line 15, in <module>
    vacf.run(parameters, status=True)
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/IJob.py", line 418, in run
    raise JobError(self, tb)
MDANSE.Framework.Jobs.IJob.JobError: Traceback (most recent call last):
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/IJob.py", line 395, in run
    self.initialize()
  File "/home/jacob/MDANSE/MDANSE/Src/MDANSE/Framework/Jobs/VelocityAutoCorrelationFunction.py", line 114, in initialize
    self.numberOfSteps = self.configuration["atom_selection"]["selection_length"]
KeyError: 'selection_length'

Suggested fix
If trying to load a necessary file, raise early.

Additional details

MWE
from MDANSE.Framework.Jobs.IJob import IJob

temp_name = "output"

parameters = {
    "frames": (0, 10, 1, 5),
    "interpolation_order": 1,
    "output_files": (temp_name, ("MDAFormat",), "INFO"),
    "running_mode": ("single-core",),
    "normalize": True,
    "trajectory": "xxxx",
}

vacf = IJob.create("VelocityAutoCorrelationFunction")
vacf.run(parameters, status=True)
@oerc0122 oerc0122 added bug Something isn't working enhancement New feature or request labels Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant