forked from enviPath/enviPy
adjusted migration
Initial bayer app Show Pack Classification Adjusted docker compose to bayer specifics Adjusted Dockerfile for Bayer Adding secret flags to group, add secret pools to packages Adjusted View for Package creation Prep configs, added Package Create Modal wip More on PES wip wip Wip minor PW interactions API PES wip Make Select Widget reflect required make required generallay available Update UI if pathway mode is set to build Added ais circle adjustments Initial Zoom, fix AD Creation wip auth log, bb4g fix missing import Added viz hint if PES is part of reaction Add Edge check for pes flip boolean ... pes Added extra ... In / Out Edges Viz, Submitting Button Text ...
This commit is contained in:
@ -19,6 +19,7 @@ from sentry_sdk import capture_exception
|
||||
|
||||
from utilities.chem import FormatConverter, IndigoUtils
|
||||
from utilities.decorators import package_permission_required
|
||||
from .exceptions import InvalidSMILESException
|
||||
|
||||
from .logic import (
|
||||
EPDBURLParser,
|
||||
@ -388,6 +389,9 @@ def get_base_context(request, for_user=None) -> Dict[str, Any]:
|
||||
"debug": s.DEBUG,
|
||||
"external_databases": ExternalDatabase.get_databases(),
|
||||
"site_id": s.MATOMO_SITE_ID,
|
||||
# EDIT START
|
||||
"secret_groups": Group.objects.filter(secret=True),
|
||||
# EDIT END
|
||||
},
|
||||
}
|
||||
|
||||
@ -587,10 +591,38 @@ def packages(request):
|
||||
"package-description", s.DEFAULT_VALUES["description"]
|
||||
)
|
||||
|
||||
# EDIT START
|
||||
data_pool = None
|
||||
package_classification = request.POST.get("package-classification")
|
||||
classification = Package.Classification(int(package_classification))
|
||||
# For SECRET we'll need a data pool which will be an additional perm check later
|
||||
if classification == Package.Classification.SECRET:
|
||||
package_data_pool = request.POST.get("package-data-pool")
|
||||
|
||||
if package_data_pool is None:
|
||||
return error(request, "Invalid data pool.", "Data Pool is required!")
|
||||
|
||||
data_pool = GroupManager.get_group_by_url(current_user, package_data_pool)
|
||||
|
||||
if data_pool is None:
|
||||
return error(request, "Invalid data pool.", "Data Pool does not exist or no access!")
|
||||
|
||||
if not data_pool.secret:
|
||||
return error(request, "Invalid data pool.", "Data Pool is not a secret group!")
|
||||
|
||||
created_package = PackageManager.create_package(
|
||||
current_user, package_name, package_description
|
||||
)
|
||||
|
||||
created_package.classification_level = classification
|
||||
|
||||
# Set previously determined data pool
|
||||
if classification == Package.Classification.SECRET:
|
||||
created_package.data_pool = data_pool
|
||||
|
||||
created_package.save()
|
||||
# EDIT END
|
||||
|
||||
return redirect(created_package.url)
|
||||
|
||||
elif request.method == "OPTIONS":
|
||||
@ -753,6 +785,10 @@ def models(request):
|
||||
{"Home": s.SERVER_URL},
|
||||
{"Model": s.SERVER_URL + "/model"},
|
||||
]
|
||||
context["entity_type"] = "model"
|
||||
context["api_endpoint"] = f"{s.SERVER_PATH}/api/v1/models/"
|
||||
context["per_page"] = s.API_PAGINATION_DEFAULT_PAGE_SIZE
|
||||
context["list_title"] = "models"
|
||||
|
||||
# Keep model_types for potential modal/action use
|
||||
context["model_types"] = {
|
||||
@ -766,12 +802,14 @@ def models(request):
|
||||
"requires_rule_packages": True,
|
||||
"requires_data_packages": True,
|
||||
},
|
||||
"EnviFormer": {
|
||||
}
|
||||
|
||||
if s.ENVIFORMER_PRESENT:
|
||||
context["model_types"]["EnviFormer"] = {
|
||||
"type": "enviformer",
|
||||
"requires_rule_packages": False,
|
||||
"requires_data_packages": True,
|
||||
},
|
||||
}
|
||||
|
||||
if s.FLAGS.get("PLUGINS", False):
|
||||
for k, v in s.CLASSIFIER_PLUGINS.items():
|
||||
@ -779,6 +817,9 @@ def models(request):
|
||||
"type": k,
|
||||
"requires_rule_packages": v.requires_rule_packages(),
|
||||
"requires_data_packages": v.requires_data_packages(),
|
||||
"additional_parameters": v.Config.__name__.lower()
|
||||
if v.Config.__name__ != ""
|
||||
else None,
|
||||
}
|
||||
for k, v in s.PROPERTY_PLUGINS.items():
|
||||
context["model_types"][v.display()] = {
|
||||
@ -787,12 +828,6 @@ def models(request):
|
||||
"requires_data_packages": v.requires_data_packages(),
|
||||
}
|
||||
|
||||
# Context for paginated template
|
||||
context["entity_type"] = "model"
|
||||
context["api_endpoint"] = f"{s.SERVER_PATH}/api/v1/models/"
|
||||
context["per_page"] = s.API_PAGINATION_DEFAULT_PAGE_SIZE
|
||||
context["list_title"] = "models"
|
||||
|
||||
return render(request, "collections/models_paginated.html", context)
|
||||
|
||||
elif request.method == "POST":
|
||||
@ -906,12 +941,14 @@ def package_models(request, package_uuid):
|
||||
"requires_rule_packages": True,
|
||||
"requires_data_packages": True,
|
||||
},
|
||||
"EnviFormer": {
|
||||
}
|
||||
|
||||
if s.ENVIFORMER_PRESENT:
|
||||
context["model_types"]["EnviFormer"] = {
|
||||
"type": "enviformer",
|
||||
"requires_rule_packages": False,
|
||||
"requires_data_packages": True,
|
||||
},
|
||||
}
|
||||
|
||||
if s.FLAGS.get("PLUGINS", False):
|
||||
for k, v in s.CLASSIFIER_PLUGINS.items():
|
||||
@ -1087,6 +1124,9 @@ def package_model(request, package_uuid, model_uuid):
|
||||
}
|
||||
)
|
||||
|
||||
# Sort data by prob desc
|
||||
res["pred"] = sorted(res["pred"], key=lambda x: x["probability"], reverse=True)
|
||||
|
||||
return JsonResponse(res, safe=False)
|
||||
|
||||
elif half_life:
|
||||
@ -2328,7 +2368,10 @@ def package_pathway_nodes(request, package_uuid, pathway_uuid):
|
||||
node_description = request.POST.get("node-description")
|
||||
|
||||
node_smiles = request.POST.get("node-smiles").strip()
|
||||
current_pathway.add_node(node_smiles, name=node_name, description=node_description)
|
||||
try:
|
||||
current_pathway.add_node(node_smiles, name=node_name, description=node_description)
|
||||
except InvalidSMILESException as e:
|
||||
return error(request, "Node creation failed!", f"Given SMILES ({node_smiles}) is invalid")
|
||||
|
||||
return redirect(current_pathway.url)
|
||||
|
||||
@ -2968,9 +3011,15 @@ def settings(request):
|
||||
new_default = request.POST.get("prediction-setting-new-default", "off") == "on"
|
||||
|
||||
# min 2, max s.DEFAULT_MAX_NUMBER_OF_NODES
|
||||
temp_max_nodes = request.POST.get("prediction-setting-max-nodes")
|
||||
if temp_max_nodes is None or temp_max_nodes == "" or int(temp_max_nodes) == -1:
|
||||
temp_max_nodes = s.DEFAULT_MAX_NUMBER_OF_NODES
|
||||
else:
|
||||
temp_max_nodes = int(request.POST.get("prediction-setting-max-nodes", 1))
|
||||
|
||||
max_nodes = min(
|
||||
max(
|
||||
int(request.POST.get("prediction-setting-max-nodes", 1)),
|
||||
temp_max_nodes,
|
||||
2,
|
||||
),
|
||||
s.DEFAULT_MAX_NUMBER_OF_NODES,
|
||||
@ -2991,6 +3040,7 @@ def settings(request):
|
||||
|
||||
model_uuid = model_url.split("/")[-1]
|
||||
params["model"] = EPModel.objects.get(uuid=model_uuid)
|
||||
# TODO Check if removed if request contains "" or not at all
|
||||
params["model_threshold"] = request.POST.get(
|
||||
"model-based-prediction-setting-threshold", s.DEFAULT_MODEL_THRESHOLD
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user