Skip to content

Commit ea1ffc2

Browse files
committed
Fix resultsPath and checkpointPath not updating
1 parent c5884fc commit ea1ffc2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def save(results, checkpoint):
9696
except PermissionError:
9797
time.sleep(0.01)
9898
else:
99-
print("Warning: Could not save results due to persistent PermissionError.")
99+
raise PermissionError("Could not save results due to persistent PermissionError.")
100100

101101
with open(checkpointPath + '.tmp', 'wb') as file:
102102
pickle.dump(checkpoint, file)
@@ -107,7 +107,7 @@ def save(results, checkpoint):
107107
except PermissionError:
108108
time.sleep(0.01)
109109
else:
110-
print("Warning: Could not save checkpoint due to persistent PermissionError.")
110+
raise PermissionError("Could not save checkpoint due to persistent PermissionError.")
111111

112112
def loadResults():
113113
if os.path.exists(resultsPath):
@@ -135,9 +135,13 @@ def importConfigModule():
135135

136136
def getWorkingDir():
137137
global working_dir
138+
global resultsPath
139+
global checkpointPath
138140
while True:
139141
working_dir = os.path.abspath(input("Enter the working directory: ").strip())
140142
if os.path.isdir(working_dir):
143+
resultsPath = os.path.join(working_dir, 'results.pkl')
144+
checkpointPath = os.path.join(working_dir, 'checkpoint.pkl')
141145
return working_dir
142146
else:
143147
print(f"Directory {working_dir} does not exist. Please try again.")
@@ -191,8 +195,6 @@ def simulatePrisoners():
191195
working_dir = getWorkingDir()
192196
config = importConfigModule()
193197
cfg = config.getConfig()
194-
resultsPath = os.path.join(working_dir, 'results.pkl')
195-
checkpointPath = os.path.join(working_dir, 'checkpoint.pkl')
196198

197199
while True:
198200
print(f"\nWorking directory: {working_dir}")

0 commit comments

Comments
 (0)