Run Google Colab regularly with Chrome extension

This article is for people who want to run Google Colab regularly with Chrome extensions .

Google Colaboratory that can use GPU almost without environment construction is really amazing.

So, to get the most out of this amazing tool, we’ll show you how to run it automatically on a regular basis.

I use 3 Chrome extensions.

I also considered automatic execution with “Selenium + python", but I could not log in to my Google account with Chrome opened as a robot browser, so I thought of another method.

Display execution time list on Google Colab

Any program can be executed periodically, but I will introduce a code that displays a list of execution times in Google Colaboratory so that you can see the time when it was executed periodically.

  1. Go to Google Colab .
  2. Select “New".
  3. Enter your python code.
import datetime as dt

# Obtaining the current time
now = dt.datetime.now()

# Output current time to file
with open("./result.txt","a") as f:
  f.write(str(now)+"\n")

# Output a list of execution times
with open("./result.txt","r") as f:
  print(f.read())

PythonCopy

4. Press “▶️” to execute.

If you execute it multiple times, the list of execution times will be displayed. We will run this program regularly.

Automate with UI. Vision RPA

Use UI.Vision RPA to automatically operate Chrome. The procedure is as follows.

1.  Install UI.Vision RPA .

2. Open UI.Vision RPA.

3. Click +Macro.

4. Click Record.

5. Click the “▶️" button on Google Colab in chrome to record a macro.

When you run it, you can confirm that the operation is automatically recorded.

6. Click Stop Record.

7. Click “Play Macro” and confirm that it will run automatically.

8. Save the created Macro as html.

You can confirm that it is executed just by opening this saved HTML. This feature was not in Selenium, so it’s an excellent feature.

Regular execution with cronTab

You should be able to run Google Colab just by opening the HTML file saved up to this point. After that, if the HTML file can be opened at the specified time, regular execution will be possible. The extension used there is cronTab . By using this function, you can open a specific path (URL, etc.) periodically. The procedure is as follows.

1.  Install cronTab .

2. Open cronTab.

3. Make settings to open the HTML file from earlier. Enter the location (path) of the file in the URL. By adding “?direct=1" at the end here, you can eliminate the need to press “OK" after opening the HTML file and automate it. Conversely, if this postscript is not present, it is necessary to press the “OK" button, and automatic execution cannot be performed. In addition, the example below is an example of automatic execution every 2 minutes.

Automatically close tabs with Tab Wrangler

cronTab will automatically open a new tab. Therefore, tabs will be generated more and more unless they are closed automatically. So, let me show you how to automatically close tabs in Tab Wrangler.

1.  Install Tab Wrangler .

2. Open Tab Wrangler and configure it. I think the settings are a matter of personal preference.

That’s it, you can run Google Colab regularly with just the Chrome extension. Now you can study Deep Learning regularly, and your research will progress. Of course, it is also possible to forecast time-series data on a regular basis. AlgoAI regularly predicted and tweeted time series data. 

Follow me on Twitter if you 'd like.