sailormars18 commited on
Commit
d272f5c
·
1 Parent(s): 9ceb8d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -46
app.py CHANGED
@@ -1,49 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- """nlpapp_4900.ipynb
3
-
4
- Automatically generated by Colaboratory.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1QE4TN1ipB5SwIVy2a7D6_bTPujHMBoDu
8
- """
9
-
10
- # Import required modules for auto-reconnecting to the Colab runtime
11
- # Set up auto-reconnect
12
- import IPython
13
- from google.colab import output
14
-
15
- # Configure the JS code to automatically reconnect
16
- def restart_runtime():
17
- output.clear()
18
- print('Restarting runtime...')
19
- display(IPython.display.Javascript('''
20
- const outputArea = this;
21
- const kernel = IPython.notebook.kernel;
22
- const command = 'notebook_utils.restart_runtime()';
23
- kernel.execute(command).then(() => {
24
- outputArea.clear_output();
25
- console.log('Runtime restarted. Running all cells...');
26
- IPython.notebook.execute_all_cells();
27
- });
28
- '''))
29
-
30
- # Set the number of minutes of inactivity before auto-reconnecting
31
-
32
- minutes = 30 #@param {type: "slider", min: 1, max: 180, step: 1} # define a slider widget to set the time before auto-reconnecting
33
-
34
- # Register the auto-reconnect function
35
- import time
36
- def auto_reconnect():
37
- while True:
38
- print(f'Auto-reconnect in {minutes} minute(s)...')
39
- time.sleep(minutes * 60 - 5) # Subtract 5 seconds to give the reconnect JS code time to run
40
- restart_runtime()
41
-
42
- # Start the auto-reconnect loop in the background
43
- import threading
44
- auto_reconnect_thread = threading.Thread(target=auto_reconnect)
45
- auto_reconnect_thread.start()
46
-
47
  # Python equivalent syntax of the Colab Notebook
48
 
49
  import subprocess
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Python equivalent syntax of the Colab Notebook
2
 
3
  import subprocess