forked from enviPath/enviPy
[Feature] Show Multi Gen Eval + Batch Prediction (#267)
Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#267
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
from datetime import datetime
|
||||
|
||||
from django.conf import settings as s
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
@ -23,6 +25,46 @@ class MultiGenTest(TestCase):
|
||||
cls.PW_WITH_INTERMEDIATE_NAME = "1,1,1-Trichloroethane (an/aerobic)"
|
||||
cls.PW_WITHOUT_INTERMEDIATE_NAME = "Caffeine"
|
||||
|
||||
def test_batch_predict(self):
|
||||
from epdb.tasks import batch_predict
|
||||
|
||||
pred_data = [
|
||||
["CN1C=NC2=C1C(=O)N(C(=O)N2C)C", "Caffeine"],
|
||||
["CC(C)CC1=CC=C(C=C1)C(C)C(=O)O", "Ibuprofen"],
|
||||
]
|
||||
|
||||
batch_predict_setting = self.user.prediction_settings()
|
||||
|
||||
target_package = PackageManager.create_package(
|
||||
self.user,
|
||||
f"Autogenerated Package for Batch Prediction {datetime.now()}",
|
||||
"This Package was generated automatically for the batch prediction task.",
|
||||
)
|
||||
|
||||
num_tps = 50
|
||||
res = batch_predict(
|
||||
pred_data,
|
||||
batch_predict_setting.pk,
|
||||
target_package.pk,
|
||||
num_tps=num_tps,
|
||||
)
|
||||
|
||||
self.assertTrue(res.startswith("Pathway URL,"))
|
||||
# Min 3 lines (1 header, 2 root nodes)
|
||||
self.assertGreaterEqual(len(res.split("\n")), 3)
|
||||
self.assertEqual(target_package.pathways.count(), 2)
|
||||
|
||||
pw = target_package.pathways.first()
|
||||
|
||||
self.assertEqual(
|
||||
pw.setting_with_overrides.max_depth,
|
||||
f"{num_tps} (this is an override for this particular pathway)",
|
||||
)
|
||||
self.assertEqual(
|
||||
pw.setting_with_overrides.max_nodes,
|
||||
f"{num_tps} (this is an override for this particular pathway)",
|
||||
)
|
||||
|
||||
def test_engineer_pathway(self):
|
||||
from epdb.tasks import engineer_pathways
|
||||
|
||||
|
||||
Reference in New Issue
Block a user