test_networkml_train_sos() depends upon the model generated by test_networkml_test_onelayer().
@@ -17,7 +17,7 @@ def copy_model(model, tempdir):
def run_networkml(args, expected_code=0,
- savew=False,
+ savew=None,
model='networkml/trained_models/onelayer/OneLayerModel.pkl',
sos_model='networkml/trained_models/sos/SoSmodel'):
tempdir = tempfile.TemporaryDirectory()
@@ -27,8 +27,8 @@ def run_networkml(args, expected_code=0,
if sos_model:
test_model = copy_model(sos_model, tempdir)
args.extend(['-s', test_model])
- if savew:
- args.extend(['-w', '%s/model_save' % tempdir.name])
+ if savew is not None:
+ args.extend(['-w', savew])
sys.argv = ['bin/networkml'] + args
if expected_code:
with pytest.raises(SystemExit) as pytest_wrapped_e:
@@ -63,7 +63,9 @@ def test_networkml_eval_sos():
def test_networkml_train_onelayer():
- run_networkml(['-p', 'tests/', '-o', 'train'], expected_code=1, savew=True)
+ tempdir = tempfile.TemporaryDirectory()
+ savew = os.path.join(tempdir.name, 'not.used')
+ run_networkml(['-p', 'tests/', '-o', 'train'], expected_code=1, savew=savew)
def test_networkml_train_randomforest():
@@ -74,20 +76,26 @@ def test_networkml_train_randomforest():
def test_networkml_train_sos():
+ tempdir = tempfile.TemporaryDirectory()
+ savew = os.path.join(tempdir.name, 'intermediate.model')
netml = run_networkml(
['-p', 'tests/', '-o', 'train', '-a', 'sos'],
- model='networkml/trained_models/sos/SoSmodel')
+ model='networkml/trained_models/sos/SoSmodel',
+ savew=savew)
assert not netml.model.feature_list
-
-
-def test_networkml_test_onelayer():
- run_networkml(['-p', 'tests/', '-o', 'test'], expected_code=1, savew=True)
+ # TODO: this was test_networkml_test_onelayer(); however it depends
+ # upon the mode generated by test_networkml_train_sos()
+ run_networkml(
+ ['-p', 'tests/', '-o', 'test'],
+ model=savew, expected_code=1, savew=savew)
def test_networkml_test_randomforest():
os.environ['POSEIDON_PUBLIC_SESSIONS'] = ''
+ tempdir = tempfile.TemporaryDirectory()
+ savew = os.path.join(tempdir.name, 'not.used')
netml = run_networkml(
['-p', 'tests/', '-o', 'test', '-a', 'randomforest'],
- savew=True,
+ savew=savew,
model='networkml/trained_models/randomforest/RandomForestModel.pkl')
assert netml.model.feature_list
