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

fix: better exception handling in detached mode #9183

Merged
merged 2 commits into from
Apr 18, 2024
Merged

Conversation

azhou-determined
Copy link
Contributor

@azhou-determined azhou-determined commented Apr 17, 2024

Ticket

Description

in _LogShipper and _Heartbeat, atexit handlers never get called, since _core_v2 registers an atexit on start, and on interpreter exit the latter atexit gets triggered and calls close() on _LogShipper and _Heartbeat which deregisters the handlers.

Test Plan

run a detached mode experiment that throws an error:

import random
import tempfile
from determined.experimental import core_v2


def main():
    checkpoint_storage = tempfile.mkdtemp()
    core_v2.init(
        defaults=core_v2.DefaultConfig(
            name="unmanaged-1-error",
        ),
        checkpoint_storage=checkpoint_storage,
    )

    for i in range(100):
        core_v2.train.report_training_metrics(steps_completed=i, metrics={"loss": random.random()})
        if i == 15:
            raise ValueError("oops")
        if (i + 1) % 10 == 0:
            core_v2.train.report_validation_metrics(
                steps_completed=i, metrics={"loss": random.random()}
            )
    core_v2.close()


if __name__ == "__main__":
    main()

ensure that the trial does not hang, logs show the value error, and trial/exp is terminated in an ERROR state.

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

@azhou-determined azhou-determined requested a review from a team as a code owner April 17, 2024 19:36
@cla-bot cla-bot bot added the cla-signed label Apr 17, 2024
Copy link

netlify bot commented Apr 17, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 3d25260
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/662024b65aa1d60008dee30e

Copy link

codecov bot commented Apr 17, 2024

Codecov Report

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

Project coverage is 45.47%. Comparing base (1037d83) to head (3d25260).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9183      +/-   ##
==========================================
+ Coverage   45.44%   45.47%   +0.02%     
==========================================
  Files        1197     1197              
  Lines      147558   147549       -9     
  Branches     2437     2438       +1     
==========================================
+ Hits        67051    67091      +40     
+ Misses      80275    80226      -49     
  Partials      232      232              
Flag Coverage Δ
backend 43.69% <ø> (-0.09%) ⬇️
harness 64.02% <0.00%> (+0.20%) ⬆️
web 35.41% <ø> (ø)

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

Files Coverage Δ
harness/determined/core/_log_shipper.py 35.24% <ø> (-0.19%) ⬇️
harness/determined/core/_heartbeat.py 38.37% <0.00%> (-0.52%) ⬇️

... and 8 files with indirect coverage changes

@azhou-determined azhou-determined merged commit 06586f0 into main Apr 18, 2024
76 of 88 checks passed
@azhou-determined azhou-determined deleted the core-v2-atexits branch April 18, 2024 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants