Skip to content

Commit 1446630

Browse files
committed
Updated so python creates instance directory
1 parent cf50c5d commit 1446630

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

workflows/p2b1_mlrMBO/swift/workflow3.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ string param_set = argv("param_set_file");
2121
string code_template =
2222
"""
2323
import p2b1_runner
24-
import json
24+
import json, os
25+
26+
outdir = '%s'
27+
28+
if not os.path.exists(outdir):
29+
os.makedirs(outdir)
2530
2631
hyper_parameter_map = json.loads('%s')
2732
hyper_parameter_map['framework'] = 'keras'
33+
hyper_parameter_map['save'] = '{}/output'.format(outdir)
34+
hyper_parameter_map['instance_directory'] = outdir
2835
29-
hyper_parameter_map['save'] = '%s/output'
30-
hyper_parameter_map['instance_directory'] = '%s'
3136
3237
validation_loss = p2b1_runner.run(hyper_parameter_map)
3338
""";
@@ -42,8 +47,8 @@ max.budget = %d, max.iterations = %d, design.size=%d, propose.points=%d, param.s
4247

4348
(string obj_result) obj(string params, string iter_indiv_id) {
4449
string outdir = "%s/run_%s" % (turbine_output, iter_indiv_id);
45-
string code = code_template % (params, outdir, outdir);
46-
make_dir(outdir) =>
50+
string code = code_template % (outdir, params);
51+
//make_dir(outdir) =>
4752
obj_result = python_persist(code, "str(validation_loss)");
4853
printf(obj_result);
4954
}

workflows/p3b1_mlrMBO/swift/workflow3.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ string param_set = argv("param_set_file");
2121
string code_template =
2222
"""
2323
import p3b1_runner
24-
import json
24+
import json, os
25+
26+
outdir = '%s'
27+
28+
if not os.path.exists(outdir):
29+
os.makedirs(outdir)
2530
2631
hyper_parameter_map = json.loads('%s')
2732
hyper_parameter_map['framework'] = 'keras'
28-
29-
hyper_parameter_map['save'] = '%s/output'
30-
hyper_parameter_map['instance_directory'] = '%s'
33+
hyper_parameter_map['save'] = '{}/output'.format(outdir)
34+
hyper_parameter_map['instance_directory'] = outdir
3135
3236
validation_loss = p3b1_runner.run(hyper_parameter_map)
3337
""";
@@ -42,8 +46,8 @@ max.budget = %d, max.iterations = %d, design.size=%d, propose.points=%d, param.s
4246

4347
(string obj_result) obj(string params, string iter_indiv_id) {
4448
string outdir = "%s/run_%s" % (turbine_output, iter_indiv_id);
45-
string code = code_template % (params, outdir, outdir);
46-
make_dir(outdir) =>
49+
string code = code_template % (outdir, params);
50+
//make_dir(outdir) =>
4751
obj_result = python_persist(code, "str(validation_loss)");
4852
printf(obj_result);
4953
}

0 commit comments

Comments
 (0)