2 Commits

Author SHA1 Message Date
421d33dddc adjusted migration
Some checks failed
CI / test (pull_request) Failing after 17s
API CI / api-tests (pull_request) Failing after 24s
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

...

Make PES Link clickable

Return proper http response instead of error

Fixed error return, removed unused options

Fix PES Link HTML for other entities

Fixed molfile assignment, adjusted Export

Package Export/Import cycle

highlight Description links

implemented non persistent

Harmonised proposed field in Json output

Added pesLink field to PW Api output

PES Fields in API Output

removed debug

Fix Classification import, Fix PES Deserialization

underline pes link in templates

Fix alter name/desc for node, make /node /edge funcitonal

provide setting link and copy button

Implemented Compound Names / Reaction Names View Option

Unconnected Nodes

Make links thicker, reduce timeout trigger time

Show proposed info in popover

Pathway Build no stereo removal

Include probs in reaction name option viz

Detect clicks outside nodes/edges
2026-07-15 22:17:40 +02:00
72a63b4876 [Feature] Sync Features from Client Repo (#425)
- New PackageImporter
- Fix persisting Molfile on Structure creation
- Add NonPersistent Prediction
- Pathway View Options
- Edit Node Fix

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#425
2026-07-16 07:50:46 +12:00
12 changed files with 94 additions and 133 deletions

View File

@ -8,4 +8,3 @@ class InvalidMolfileException(Exception):
class PackageImportException(Exception): class PackageImportException(Exception):
pass pass

View File

@ -2412,17 +2412,12 @@ class NonPersistent(Schema):
@router.post("/util", response={200: Any, 403: Error}) @router.post("/util", response={200: Any, 403: Error})
def predict(request, np: Form[NonPersistent]): def predict(request, np: Form[NonPersistent]):
try: try:
print(request.user)
print(np.setting_url)
setting = SettingManager.get_setting_by_url(request.user, np.setting_url)
from epdb.logic import SPathway from epdb.logic import SPathway
setting = SettingManager.get_setting_by_url(request.user, np.setting_url)
spw = SPathway(prediction_setting=setting, root_nodes=[np.smiles]) spw = SPathway(prediction_setting=setting, root_nodes=[np.smiles])
spw.predict() spw.predict()
return spw.to_json() return spw.to_json()
except ValueError: except ValueError:
return 403, { return 403, {
"message": f"Getting Setting with id {np.setting_url} failed due to insufficient rights!" "message": f"Getting Setting with id {np.setting_url} failed due to insufficient rights!"

View File

@ -1834,7 +1834,7 @@ class Reaction(
r = Reaction() r = Reaction()
r.package = package r.package = package
if r is not None: if name is not None:
r.name = name r.name = name
if description is not None and description.strip() != "": if description is not None and description.strip() != "":
@ -2414,14 +2414,14 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
def get_name(self, include_suffix=True): def get_name(self, include_suffix=True):
non_generic_name = True non_generic_name = True
if self.name == "no name": if self.name is None or self.name == "no name":
non_generic_name = False non_generic_name = False
if non_generic_name: if non_generic_name:
return self.name return self.name
else: else:
if include_suffix: if include_suffix:
f"{self.default_node_label.name} (taken from underlying structure)" return f"{self.default_node_label.name} (taken from underlying structure)"
else: else:
return self.default_node_label.name return self.default_node_label.name
@ -2556,8 +2556,8 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
def is_proposed_intermediate(self): def is_proposed_intermediate(self):
collected = defaultdict(dict) collected = defaultdict(dict)
for ai in self.additional_information.filter( for ai in self.additional_information.filter(
type__in=["ProposedIntermediate", "TransformationProductImportance", "Confidence"] type__in=["ProposedIntermediate", "TransformationProductImportance", "Confidence"],
, scenario__isnull=False scenario__isnull=False,
): ):
collected[str(ai.scenario.uuid)]["scenarioId"] = ai.scenario.url collected[str(ai.scenario.uuid)]["scenarioId"] = ai.scenario.url
collected[str(ai.scenario.uuid)]["scenarioName"] = ai.scenario.name collected[str(ai.scenario.uuid)]["scenarioName"] = ai.scenario.name
@ -2569,7 +2569,9 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
collected[str(ai.scenario.uuid)]["Confidence"] = ai.get().level collected[str(ai.scenario.uuid)]["Confidence"] = ai.get().level
if ai.type == "TransformationProductImportance": if ai.type == "TransformationProductImportance":
collected[str(ai.scenario.uuid)]["Transformation product importance"] = ai.get().importance.value collected[str(ai.scenario.uuid)]["Transformation product importance"] = (
ai.get().importance.value
)
return list(collected.values()) return list(collected.values())

View File

@ -2506,13 +2506,17 @@ def package_pathway_node(request, package_uuid, pathway_uuid, node_uuid):
current_node.name = new_node_name current_node.name = new_node_name
if new_node_description is not None and new_node_description.strip() != "": if new_node_description is not None and new_node_description.strip() != "":
new_node_description = nh3.clean(new_node_description.strip(), tags=s.ALLOWED_HTML_TAGS).strip() new_node_description = nh3.clean(
new_node_description.strip(), tags=s.ALLOWED_HTML_TAGS
).strip()
current_node.description = new_node_description current_node.description = new_node_description
current_node.save() current_node.save()
return redirect(current_node.url) return redirect(current_node.url)
return error(request, "Node update failed!", "No changes were made to the node") return error(request, "Node update failed!", "No changes were made to the node")
else: else:
return HttpResponseNotAllowed(["GET", "POST"]) return HttpResponseNotAllowed(["GET", "POST"])

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -122,7 +122,8 @@ document.addEventListener('alpine:init', () => {
return this.items.slice(start, end); return this.items.slice(start, end);
} }
})); })
);
Alpine.data('remotePaginatedList', (options = {}) => ({ Alpine.data('remotePaginatedList', (options = {}) => ({
items: [], items: [],

View File

@ -161,6 +161,7 @@ function draw(pathway, elem) {
linkText linkText
.attr("x", d => (d.source.x + d.target.x) / 2) .attr("x", d => (d.source.x + d.target.x) / 2)
.attr("y", d => (d.source.y + d.target.y) / 2); .attr("y", d => (d.source.y + d.target.y) / 2);
} }
function dragstarted(event, d) { function dragstarted(event, d) {
@ -542,7 +543,6 @@ function draw(pathway, elem) {
} }
if("Confidence" in n.proposed[prop]){ if("Confidence" in n.proposed[prop]){
popupContent += "Confidence: " + n.proposed[prop]["Confidence"] + "<br>"; popupContent += "Confidence: " + n.proposed[prop]["Confidence"] + "<br>";
} }
if("Transformation product importance" in n.proposed[prop]){ if("Transformation product importance" in n.proposed[prop]){
popupContent += "Transformation product importance: " + n.proposed[prop]["Transformation product importance"] + "<br>"; popupContent += "Transformation product importance: " + n.proposed[prop]["Transformation product importance"] + "<br>";
@ -623,7 +623,7 @@ function draw(pathway, elem) {
.attr("pointer-events", "all") .attr("pointer-events", "all")
.style("cursor", "grab"); .style("cursor", "grab");
// Click on empty SVG space (not on a node or link) // Click on empty SVG space (not on a node or link)
rect.on("click", function(event) { rect.on("click", function(event) {
// Only treat it as a background click if the direct target is the rect itself // Only treat it as a background click if the direct target is the rect itself
// (clicks on nodes/links bubble up but originate from different elements) // (clicks on nodes/links bubble up but originate from different elements)
@ -637,7 +637,6 @@ function draw(pathway, elem) {
target.closest("path.link") !== null || target.closest("path.link") !== null ||
target.closest("path.link_no_arrow") !== null target.closest("path.link_no_arrow") !== null
); );
if (!isNode && !isLink) { if (!isNode && !isLink) {
// console.log("Clicked outside a node or link"); // console.log("Clicked outside a node or link");
// Clear all highlights // Clear all highlights
@ -694,7 +693,7 @@ function draw(pathway, elem) {
.force("center", d3.forceCenter(width / 2, height / 4)) .force("center", d3.forceCenter(width / 2, height / 4))
.on("tick", ticked); .on("tick", ticked);
// Kanten zeichnen // Draw Edges
const linkGroup = zoomable.append("g") const linkGroup = zoomable.append("g")
.selectAll("g") .selectAll("g")
.data(links) .data(links)
@ -754,7 +753,7 @@ function draw(pathway, elem) {
} }
var suffix = ""; var suffix = "";
if ("reaction_probability" in d) { if ("reaction_probability" in d && d["reaction_probability"] !== null) {
suffix = " (p= " + d["reaction_probability"].toFixed(2) + ")" suffix = " (p= " + d["reaction_probability"].toFixed(2) + ")"
} }
return d.plain_name + suffix; return d.plain_name + suffix;
@ -779,7 +778,7 @@ function draw(pathway, elem) {
pop_add(link, "Reaction", edge_popup); pop_add(link, "Reaction", edge_popup);
// Knoten zeichnen // Draw Nodes
const node = zoomable.append("g") const node = zoomable.append("g")
.selectAll("g") .selectAll("g")
.data(nodes) .data(nodes)

View File

@ -63,7 +63,6 @@
<div class="collapse-content">{{ node.description }}</div> <div class="collapse-content">{{ node.description }}</div>
</div> </div>
{% endif %} {% endif %}
{% epdb_slot_templates "epdb.objects.node.viz" as viz_templates %} {% epdb_slot_templates "epdb.objects.node.viz" as viz_templates %}
{% for tpl in viz_templates %} {% for tpl in viz_templates %}

View File

@ -22,7 +22,6 @@
stroke: #999; stroke: #999;
stroke-opacity: 0.6; stroke-opacity: 0.6;
stroke-width: 1.5px; stroke-width: 1.5px;
/* marker-end: url(#arrow); */
} }
.link_no_arrow { .link_no_arrow {
@ -182,46 +181,46 @@
<li> <li>
<a id="compound-names-toggle-button" class="cursor-pointer"> <a id="compound-names-toggle-button" class="cursor-pointer">
<svg <svg
id="compound-names-icon" id="compound-names-icon"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="16" width="16"
height="16" height="16"
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
stroke="currentColor" stroke="currentColor"
stroke-width="2" stroke-width="2"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
class="lucide lucide-eye" class="lucide lucide-eye"
> >
<path <path
d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"
/> />
<circle cx="12" cy="12" r="3" /> <circle cx="12" cy="12" r="3" />
</svg> </svg>
Compound Names Compound Names
</a> </a>
</li> </li>
<li> <li>
<a id="reaction-names-toggle-button" class="cursor-pointer"> <a id="reaction-names-toggle-button" class="cursor-pointer">
<svg <svg
id="reaction-names-icon" id="reaction-names-icon"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
width="16" width="16"
height="16" height="16"
viewBox="0 0 24 24" viewBox="0 0 24 24"
fill="none" fill="none"
stroke="currentColor" stroke="currentColor"
stroke-width="2" stroke-width="2"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
class="lucide lucide-eye" class="lucide lucide-eye"
> >
<path <path
d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z" d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"
/> />
<circle cx="12" cy="12" r="3" /> <circle cx="12" cy="12" r="3" />
</svg> </svg>
Reaction Names Reaction Names
</a> </a>
</li> </li>
@ -584,22 +583,22 @@
descContent.innerHTML = newDesc; descContent.innerHTML = newDesc;
} }
const compoundNamesBtn = document.getElementById("compound-names-toggle-button"); const compoundNamesBtn = document.getElementById(
"compound-names-toggle-button",
);
if (compoundNamesBtn) { if (compoundNamesBtn) {
compoundNamesBtn.addEventListener("click", function () { compoundNamesBtn.addEventListener("click", function () {
compoundNamesViewEnabled = !compoundNamesViewEnabled; compoundNamesViewEnabled = !compoundNamesViewEnabled;
const icon = document.getElementById("compound-names-icon"); const icon = document.getElementById("compound-names-icon");
if (compoundNamesViewEnabled) { if (compoundNamesViewEnabled) {
// Change to eye-off icon // Change to eye-off icon
icon.innerHTML = icon.innerHTML =
'<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>'; '<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>';
nodes.forEach((x) => { nodes.forEach((x) => {
if (x.name) { if (x.name) {
d3.select(x.el) d3.select(x.el)
.append("text") .append("text")
.text(d => d.name) .text((d) => d.plain_name)
.attr("text-anchor", "middle") .attr("text-anchor", "middle")
.attr("y", -20) .attr("y", -20)
.style("font-size", "4px"); .style("font-size", "4px");
@ -609,38 +608,29 @@
// Change back to eye icon // Change back to eye icon
icon.innerHTML = icon.innerHTML =
'<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>'; '<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>';
nodes.forEach((x) => { nodes.forEach((x) => {
d3.select(x.el) d3.select(x.el).select("text").remove();
.select("text") });
.remove()
})
} }
}); });
} }
const reactionNamesBtn = document.getElementById(
const reactionNamesBtn = document.getElementById("reaction-names-toggle-button"); "reaction-names-toggle-button",
);
if (reactionNamesBtn) { if (reactionNamesBtn) {
reactionNamesBtn.addEventListener("click", function () { reactionNamesBtn.addEventListener("click", function () {
reactionNamesViewEnabled = !reactionNamesViewEnabled; reactionNamesViewEnabled = !reactionNamesViewEnabled;
const icon = document.getElementById("reaction-names-icon"); const icon = document.getElementById("reaction-names-icon");
if (reactionNamesViewEnabled) { if (reactionNamesViewEnabled) {
// Change to eye-off icon // Change to eye-off icon
icon.innerHTML = icon.innerHTML =
'<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>'; '<path d="M9.88 9.88a3 3 0 1 0 4.24 4.24"/><path d="M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68"/><path d="M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61"/><line x1="2" x2="22" y1="2" y2="22"/>';
d3.selectAll(".link-label").style("display", null);
d3.selectAll(".link-label")
.style("display", null);
} else { } else {
// Change back to eye icon // Change back to eye icon
icon.innerHTML = icon.innerHTML =
'<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>'; '<path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>';
d3.selectAll(".link-label").style("display", "none");
d3.selectAll(".link-label")
.style("display", "none");
} }
}); });
} }

View File

@ -72,8 +72,10 @@ class PackageViewTest(TestCase):
def test_import_package(self): def test_import_package(self):
file = SimpleUploadedFile( file = SimpleUploadedFile(
"Fixture_Package.json", "EAWAG-BBD_32de3cf4-e3e6-4168-956e-32fa5ddb0ce1.json",
open(s.FIXTURE_DIRS[0] / "Fixture_Package.json", "rb").read(), open(
s.FIXTURE_DIRS[0] / "EAWAG-BBD_32de3cf4-e3e6-4168-956e-32fa5ddb0ce1.json", "rb"
).read(),
content_type="application/json", content_type="application/json",
) )
@ -86,10 +88,11 @@ class PackageViewTest(TestCase):
p = Package.objects.get(url=package_url) p = Package.objects.get(url=package_url)
self.assertEqual(p.pathways.count(), 22) self.assertEqual(p.pathways.count(), 219)
self.assertEqual(p.rules.count(), 45) self.assertEqual(p.rules.count(), 498)
self.assertEqual(p.compounds.count(), 223) self.assertEqual(p.compounds.count(), 1399)
self.assertEqual(p.reactions.count(), 212) self.assertEqual(p.reactions.count(), 1480)
self.assertEqual(p.scenarios.count(), 1914)
upp = UserPackagePermission.objects.get(package=p, user=self.user1) upp = UserPackagePermission.objects.get(package=p, user=self.user1)
self.assertEqual(upp.permission, Permission.ALL[0]) self.assertEqual(upp.permission, Permission.ALL[0])

View File

@ -9,7 +9,6 @@ from datetime import datetime
from typing import Any, Dict, List, Optional, TYPE_CHECKING from typing import Any, Dict, List, Optional, TYPE_CHECKING
from django.conf import settings as s from django.conf import settings as s
from django.db import transaction
from ninja import Schema from ninja import Schema
from pydantic import HttpUrl, ValidationError from pydantic import HttpUrl, ValidationError
@ -20,23 +19,15 @@ from epdb.models import (
Compound, Compound,
CompoundStructure, CompoundStructure,
Edge, Edge,
EnviFormer,
EPModel,
ExternalDatabase,
ExternalIdentifier,
License, License,
MLRelativeReasoning,
Node, Node,
ParallelRule, ParallelRule,
Pathway, Pathway,
Reaction, Reaction,
Rule, Rule,
RuleBasedRelativeReasoning,
Scenario, Scenario,
Setting, Setting,
SimpleAmbitRule, SimpleAmbitRule,
SimpleRDKitRule,
SimpleRule, Group,
) )
from utilities.chem import FormatConverter from utilities.chem import FormatConverter
@ -353,7 +344,6 @@ class PackageExporter:
class PackageImporter: class PackageImporter:
def __init__(self, package: Dict[str, Any], preserve_uuids: bool = False): def __init__(self, package: Dict[str, Any], preserve_uuids: bool = False):
self.preserve_uuids = preserve_uuids self.preserve_uuids = preserve_uuids
self._raw_package = package self._raw_package = package
@ -412,11 +402,7 @@ class PackageImporter:
new_c.default_structure = self._cache[c.default_structure.uuid] new_c.default_structure = self._cache[c.default_structure.uuid]
new_c.save() new_c.save()
def _import_simple_rules( def _import_simple_rules(self, package: Package, rules: List[RuleExportSchema]):
self,
package: Package,
rules: List[RuleExportSchema]
):
for r in rules: for r in rules:
new_r = SimpleAmbitRule() new_r = SimpleAmbitRule()
new_r.uuid = str(uuid.uuid4()) if not self.preserve_uuids else r.uuid new_r.uuid = str(uuid.uuid4()) if not self.preserve_uuids else r.uuid
@ -431,11 +417,7 @@ class PackageImporter:
self._cache[r.uuid] = new_r self._cache[r.uuid] = new_r
def _import_composite_rules( def _import_composite_rules(self, package: Package, rules: List[ParallelRuleExportSchema]):
self,
package: Package,
rules: List[ParallelRuleExportSchema]
):
for r in rules: for r in rules:
new_r = ParallelRule() new_r = ParallelRule()
new_r.uuid = str(uuid.uuid4()) if not self.preserve_uuids else r.uuid new_r.uuid = str(uuid.uuid4()) if not self.preserve_uuids else r.uuid
@ -451,9 +433,9 @@ class PackageImporter:
self._cache[r.uuid] = new_r self._cache[r.uuid] = new_r
def _import_reactions( def _import_reactions(
self, self,
package: Package, package: Package,
reactions: List[ReactionExportSchema], reactions: List[ReactionExportSchema],
): ):
for r in reactions: for r in reactions:
new_r = Reaction() new_r = Reaction()
@ -477,11 +459,7 @@ class PackageImporter:
self._cache[r.uuid] = new_r self._cache[r.uuid] = new_r
def _import_pathways( def _import_pathways(self, package: Package, pathways: List[PathwayExportSchema]):
self,
package: Package,
pathways: List[PathwayExportSchema]
):
for pw in pathways: for pw in pathways:
new_pw = Pathway() new_pw = Pathway()
new_pw.uuid = str(uuid.uuid4()) if not self.preserve_uuids else pw.uuid new_pw.uuid = str(uuid.uuid4()) if not self.preserve_uuids else pw.uuid
@ -529,27 +507,21 @@ class PackageImporter:
self._cache[e.uuid] = new_e self._cache[e.uuid] = new_e
def _import_scenarios( def _import_scenarios(self, package: Package, scenarios: List[ScenarioExportSchema]):
self, for scen in scenarios:
package: Package,
scenarios: List[ScenarioExportSchema]
):
for s in scenarios:
new_s = Scenario() new_s = Scenario()
new_s.uuid = str(uuid.uuid4()) if not self.preserve_uuids else s.uuid new_s.uuid = str(uuid.uuid4()) if not self.preserve_uuids else scen.uuid
new_s.package = package new_s.package = package
new_s.name = s.name new_s.name = scen.name
new_s.description = s.description new_s.description = scen.description
new_s.scenario_date = s.scenario_date new_s.scenario_date = scen.scenario_date
new_s.scenario_type = s.scenario_type new_s.scenario_type = scen.scenario_type
new_s.save() new_s.save()
self._cache[s.uuid] = new_s self._cache[scen.uuid] = new_s
def _import_additional_information( def _import_additional_information(
self, self, package: Package, additional_information: List[AdditionalInformationExportSchema]
package: Package,
additional_information: List[AdditionalInformationExportSchema]
): ):
for ai in additional_information: for ai in additional_information:
new_ai = AdditionalInformation() new_ai = AdditionalInformation()
@ -582,12 +554,11 @@ class PackageImporter:
for coll in collections: for coll in collections:
for elem in coll: for elem in coll:
elem_obj = self._cache[elem.uuid] elem_obj = self._cache[elem.uuid]
for s in elem.scenarios: for scen in elem.scenarios:
elem_obj.scenarios.add(self._cache[s.uuid]) elem_obj.scenarios.add(self._cache[scen.uuid])
def _import_package_from_json( def _import_package_from_json(
self, self,
) -> Package: ) -> Package:
try: try:
parsed = PackageExportSchema.model_validate(self._raw_package) parsed = PackageExportSchema.model_validate(self._raw_package)
@ -602,8 +573,6 @@ class PackageImporter:
package_license = License.objects.get(link=parsed.license.link) if parsed.license else None package_license = License.objects.get(link=parsed.license.link) if parsed.license else None
package_classification_level = Package.Classification[parsed.classification_level.upper()] package_classification_level = Package.Classification[parsed.classification_level.upper()]
print(parsed.classification_level, "->", package_classification_level)
package = Package() package = Package()
package.uuid = package_uuid package.uuid = package_uuid
package.name = f"{parsed.name} - Imported at {datetime.now()}" package.name = f"{parsed.name} - Imported at {datetime.now()}"