File size: 951 Bytes
a06056d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import subprocess

def run_command(command):
  try:
    result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
    return result.stdout.strip()
  except subprocess.CalledProcessError as e:
    error_message = e.stderr.decode('utf-8') if hasattr(e.stderr, 'decode') else str(e.stderr)
    return f"Error: {error_message.strip()}"

if __name__ == "__main__":
  pip_actions = [
    "install --upgrade pip",
    "install torch",
    "install transformers",
    "install flask",
    "install tensorflow",
  ]
  commands = []

  for command in pip_actions:
    print(f"Executing pip action: {command}")
    result = run_command(f"TMPDIR=/home/container/cache python3 -m pip {command}") # IF IT DOESNT WORK MAKE A CACHE DIR
    print(f"Result:\n{result}\n{'='*40}\n")
    
  for command in commands:
    print(f"Running command: {command}")
    result = run_command(f"{command}")
    print(f"Result:\n{result}\n{'='*40}\n")