Skip to content

Commit b19bee2

Browse files
committed
Fixed scoping issue on the profiles exec
1 parent c7eb4d3 commit b19bee2

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

interpreter/terminal_interface/profiles/defaults/local.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,17 @@
44
import sys
55
import time
66
import inquirer
7+
import psutil
8+
import wget
79
from interpreter import interpreter
810

9-
1011
def get_ram():
11-
import psutil
12-
1312
total_ram = psutil.virtual_memory().total / (
1413
1024 * 1024 * 1024
1514
) # Convert bytes to GB
1615
return total_ram
1716

1817
def download_model(models_dir, models, interpreter):
19-
# For some reason, these imports need to be inside the function
20-
import inquirer
21-
import psutil
22-
import wget
23-
2418
# Get RAM and disk information
2519
total_ram = get_ram()
2620
free_disk_space = psutil.disk_usage("/").free / (

interpreter/terminal_interface/profiles/profiles.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def visit_Assign(self, node):
145145

146146
def apply_profile(interpreter, profile, profile_path):
147147
if "start_script" in profile:
148-
exec(profile["start_script"])
148+
scope = {"interpreter": interpreter}
149+
exec(profile["start_script"], scope, scope)
149150

150151
if (
151152
"version" not in profile or profile["version"] != OI_VERSION

0 commit comments

Comments
 (0)