neptune-client icon indicating copy to clipboard operation
neptune-client copied to clipboard

Mark run as failed in case of error using ctx manager

Open AleksanderWWW opened this issue 1 year ago • 2 comments

Before submitting checklist

  • [x] Did you update the CHANGELOG? (not for test updates, internal changes/refactors or CI/CD setup)
  • [ ] Did you ask the docs owner to review all the user-facing changes?

AleksanderWWW avatar Apr 24 '24 09:04 AleksanderWWW

Codecov Report

Attention: Patch coverage is 60.00000% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 81.04%. Comparing base (d4d7fdd) to head (bfe96fa).

Files Patch % Lines
...ptune/internal/utils/uncaught_exception_handler.py 62.50% 9 Missing :warning:
.../neptune/metadata_containers/metadata_container.py 0.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           dev/1.x    #1755      +/-   ##
===========================================
- Coverage    81.16%   81.04%   -0.12%     
===========================================
  Files          304      304              
  Lines        15359    15365       +6     
===========================================
- Hits         12466    12453      -13     
- Misses        2893     2912      +19     
Flag Coverage Δ
e2e ?
e2e-management ?
e2e-s3 ?
e2e-s3-gcs ?
e2e-standard ?
macos 75.27% <60.00%> (-5.57%) :arrow_down:
py3.10 ?
py3.11 ?
py3.12 ?
py3.7 74.98% <60.00%> (-5.62%) :arrow_down:
py3.8 75.27% <60.00%> (-5.74%) :arrow_down:
py3.9 ?
ubuntu 74.85% <60.00%> (-6.11%) :arrow_down:
unit 75.59% <60.00%> (-0.05%) :arrow_down:
windows 73.88% <60.00%> (-6.71%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Apr 24 '24 09:04 codecov[bot]

What this PR does

The issue is that the __exit__ method in the MetadataContainer takes precedence over the traceback background job. The result is that this:

run = neptune.init_run()
raise some_exception

marks the run as failed, but this

with neptune.init_run():
    raise some_exception

does not, because the __exit__ doesn't contain any logic that would fail the run.

The proposition is to add the same logic as is present in the traceback job, but to avoid repeating the logic - move it to the MetadataContainer instead and use in the traceback job from there, instead of creating it in that place locally.

AleksanderWWW avatar Apr 24 '24 09:04 AleksanderWWW