Created
October 8, 2022 01:45
-
-
Save twobob/7e04491f5e7f93945600730d9aacd4fd to your computer and use it in GitHub Desktop.
print how long you have left in your daily colab session. Naive counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, json | |
from dateutil.parser import parse | |
from datetime import datetime, timezone, timedelta | |
with open("/var/colab/app.log", 'r') as fileData: | |
for textline in fileData: | |
if " started" in textline: | |
time = parse (json.loads(textline)['time']) | |
now = datetime.now(time.tzinfo) | |
later = time + timedelta(hours=4) | |
print(now-time, "session started") | |
print(later - now, "left, based on the 4 hours a day free plan,\nthis does not include any other time used today") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment