MoseleyBioinformaticsLab / gpu_tracker

Context manager and CLI that tracks the computational-resource-usage of a code block or shell command, particularly the GPU usage.
Other
4 stars 1 forks source link

Add try/except/finally example to tutorial #31

Closed erikhuck closed 1 month ago

erikhuck commented 3 months ago

We can add this as a recommended pattern if the user wishes to report resource usage results even if their script crashes.


try:
    with Tracker() as tracker:
        example_function()
except Exception as error:
    print(error)
finally:
    print(tracker)
hunter-moseley commented 3 months ago

Yes, add this as an example.

On Mon, Apr 15, 2024 at 11:05 AM Erik Huckvale @.***> wrote:

We can add this as a recommended pattern if the user wishes to report resource usage results even if their script crashes. If we are not already doing so, we'll want to make sure the same is happening with the CLI i.e. make sure resource usage is still reported even if the subprocess ends with a non-zero exit code or if some exception is raised.

try: with Tracker() as tracker: example_function() except Exception as error: print(error) finally: print(tracker)

— Reply to this email directly, view it on GitHub https://github.com/MoseleyBioinformaticsLab/gpu_tracker/issues/31, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEP7B7E7U4TANKTIRGCDO3Y5PUB3AVCNFSM6AAAAABGHRQQ7GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI2DGOJRHAYTONQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Hunter Moseley, Ph.D. -- Univ. of Kentucky Professor, Dept. of Molec. & Cell. Biochemistry / Markey Cancer Center / Institute for Biomedical Informatics / UK Superfund Research Center Not just a scientist, but a fencer as well. My foil is sharp, but my mind sharper still.

Email: @. (work) @. (personal) Phone: 859-218-2964 (office) 859-218-2965 (lab) 859-257-7715 (fax) Web: http://bioinformatics.cesb.uky.edu/ Address: CC434 Roach Building, 800 Rose Street, Lexington, KY 40536-0093

erikhuck commented 2 months ago

Additionally we should add an example of child process utilization in the tutorial using a couple of multiprocessing.Process objects.

erikhuck commented 1 month ago

Completed as part of #41