Skip to content

Instantly share code, notes, and snippets.

@twobob
Created October 8, 2022 01:45
Show Gist options
  • Save twobob/7e04491f5e7f93945600730d9aacd4fd to your computer and use it in GitHub Desktop.
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
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