-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateAndRunCampaign.py
58 lines (45 loc) · 1.66 KB
/
CreateAndRunCampaign.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import sys
import shutil
import pickle
from pathlib import Path
import outputManager
# cleans-up cache directories
from cleanCachefiles import main as cleanCachedirs
import importlib
from runCampaign2 import main as runCampaign
def CreateAndRunCampaign(campaign_name,
create_campaign_python_file,
create_function_args,
randomseed,
outdir,
visualizationfiles):
dirpath = os.getcwd()
#print(dirpath)
sys.path.insert(0, dirpath + '/goal_tether_functions')
sys.path.insert(0, dirpath + '/predictive_modelers')
sys.path.insert(0, dirpath + '/predictive_modelers/assessment_resources')
sys.path.insert(0, dirpath + '/active_learners')
sys.path.insert(0, dirpath + '/data_acquisition')
dtbsExt = '.hdf5'
if not os.path.exists(outdir):
os.makedirs(outdir)
os.chdir(outdir)
# creates campaign
create_campaign_module = importlib.import_module(create_campaign_python_file)
campaignObject = create_campaign_module.main(*create_function_args)
setattr(campaignObject, 'randoseed', randomseed)
# run campaign(s)
runCampaign(campaignObject)
# clean-up
# save the full campaign object to a pickle file
pickle.dump(campaignObject.__dict__, open(campaign_name + '_Seed=' + str(randomseed) + ".p", "wb"))
os.chdir(dirpath)
#print(campaignObject.plotting.intDir)
filesep = os.path.sep
outd = Path(outdir + filesep + campaignObject.plotting.intDir)
visualizations = [list(outd.glob(glob)) for glob in visualizationfiles]
#print(visualizations)
visualizations = sum(visualizations, []) # flatten nested list
cleanCachedirs()
return visualizations