[Chore] Linted Files (#150)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#150
This commit is contained in:
2025-10-09 07:25:13 +13:00
parent 22f0bbe10b
commit afeb56622c
50 changed files with 5616 additions and 4408 deletions

View File

@ -2,55 +2,57 @@ import logging
from typing import Optional
from celery import shared_task
from epdb.models import Pathway, Node, Edge, EPModel, Setting
from epdb.models import Pathway, Node, EPModel, Setting
from epdb.logic import SPathway
logger = logging.getLogger(__name__)
@shared_task(queue='background')
@shared_task(queue="background")
def mul(a, b):
return a * b
@shared_task(queue='predict')
@shared_task(queue="predict")
def predict_simple(model_pk: int, smiles: str):
mod = EPModel.objects.get(id=model_pk)
res = mod.predict(smiles)
return res
@shared_task(queue='background')
@shared_task(queue="background")
def send_registration_mail(user_pk: int):
pass
@shared_task(queue='model')
@shared_task(queue="model")
def build_model(model_pk: int):
mod = EPModel.objects.get(id=model_pk)
mod.build_dataset()
mod.build_model()
@shared_task(queue='model')
@shared_task(queue="model")
def evaluate_model(model_pk: int):
mod = EPModel.objects.get(id=model_pk)
mod.evaluate_model()
@shared_task(queue='model')
@shared_task(queue="model")
def retrain(model_pk: int):
mod = EPModel.objects.get(id=model_pk)
mod.retrain()
@shared_task(queue='predict')
def predict(pw_pk: int, pred_setting_pk: int, limit: Optional[int] = None, node_pk: Optional[int] = None) -> Pathway:
@shared_task(queue="predict")
def predict(
pw_pk: int, pred_setting_pk: int, limit: Optional[int] = None, node_pk: Optional[int] = None
) -> Pathway:
pw = Pathway.objects.get(id=pw_pk)
setting = Setting.objects.get(id=pred_setting_pk)
pw.kv.update(**{'status': 'running'})
pw.kv.update(**{"status": "running"})
pw.save()
try:
@ -74,12 +76,10 @@ def predict(pw_pk: int, pred_setting_pk: int, limit: Optional[int] = None, node_
else:
raise ValueError("Neither limit nor node_pk given!")
except Exception as e:
pw.kv.update({'status': 'failed'})
pw.kv.update({"status": "failed"})
pw.save()
raise e
pw.kv.update(**{'status': 'completed'})
pw.save()
pw.kv.update(**{"status": "completed"})
pw.save()