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

Errors from post_analysis are not reported in API logs #1149

Closed
carlfischerjba opened this issue Dec 4, 2024 · 0 comments · Fixed by #1164
Closed

Errors from post_analysis are not reported in API logs #1149

carlfischerjba opened this issue Dec 4, 2024 · 0 comments · Fixed by #1164
Assignees

Comments

@carlfischerjba
Copy link
Collaborator

**IMPORTANT: Please apply the relevant labels, for example if this issue is needed as a backported fix add the label LTS fix (Long term support fix)

Issue Description

If an error occurs in a custom post analysis hook, the traceback from the post analysis hook is not exposed in NRMC (presumably due to the way the Oasis API works but not sure). The MDK shows it but the logs in NRMC only show the final log message without the traceback.

Steps to Reproduce (Bugs only)

  1. Raise an exception in the post analysis run method.
  2. Run an analysis via the API.
  3. See that the traceback is not included in any logs.

Version / Environment information

  • oasislmf 2.3.10
  • Oasis Platform 2.3.10

Example data / logs

run_traceback.log - no error shown

...
COMPLETED: oasislmf.computation.generate.losses.run in 6.67s
RUNNING: oasislmf.computation.hooks.post_analysis.run
Store file: /var/log/oasis/tasks/analysis_1_5aeb6b5f-7552-4c5d-8e10-4d476e2851c8.log -> /shared-fs/287717fb68e243288cc78470305f66dd.log

oasislmf model run - stacktrace is visible

...
2024-12-04 10:45:36,256 [INFO] oasislmf.computation.base losses@771:run [2705397] Losses generated in .../test_constant_damage_ratio0/run
COMPLETED: oasislmf.computation.generate.losses.run in 6.61s
2024-12-04 10:45:36,257 [INFO] oasislmf log@128:wrapper [2705397] COMPLETED: oasislmf.computation.generate.losses.run in 6.61s
 80%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                     | 4/5 [00:09<00:02,  2.60s/it]RUNNING: oasislmf.computation.hooks.post_analysis.run
2024-12-04 10:45:36,260 [INFO] oasislmf log@104:wrapper [2705397] RUNNING: oasislmf.computation.hooks.post_analysis.run
 80%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                     | 4/5 [00:09<00:02,  2.34s/it]
Traceback (most recent call last):
  File "/home/me/venvs/my_venv/bin/oasislmf", line 8, in <module>
    sys.exit(main())
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/cli/root.py", line 54, in main
    sys.exit(RootCmd().run())
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/cli/root.py", line 42, in run
    return super(OasisBaseCommand, self).run(args=args)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/argparsetree/cmd.py", line 159, in run
    return cmd_cls(sub_command_name).run(args)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/argparsetree/cmd.py", line 159, in run
    return cmd_cls(sub_command_name).run(args)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/argparsetree/cmd.py", line 161, in run
    return self.action(args) or 0
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/cli/command.py", line 150, in action
    manager_method(**_kwargs)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/utils/log.py", line 123, in wrapper
    result = func(*args, **kwargs)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/manager.py", line 94, in interface
    return computation_cls(**kwargs).run()
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/utils/log.py", line 123, in wrapper
    result = func(*args, **kwargs)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/computation/run/model.py", line 99, in run
    cmd[0](**cmd[1]).run()
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/utils/log.py", line 123, in wrapper
    result = func(*args, **kwargs)
  File "/home/me/venvs/my_venv/lib/python3.10/site-packages/oasislmf/computation/hooks/post_analysis.py", line 48, in run
    _class(**kwargs).run()
  File "/home/me/repos/mypackage/mypackage/oasis/postanalysis.py", line 25, in run
    raise Exception("Error!!!!!!!!!")
Exception: Error!!!!!!!!!
@sambles sambles moved this to In Progress in Oasis Dev Team Tasks Dec 4, 2024
@sambles sambles self-assigned this Dec 4, 2024
@sambles sambles linked a pull request Feb 5, 2025 that will close this issue
@benhayes21 benhayes21 moved this from In Progress to Done in Oasis Dev Team Tasks Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants