From d2c4dd0f651205c826f73be015226cec987b4c06 Mon Sep 17 00:00:00 2001 From: Chris ter Beke Date: Thu, 25 Feb 2021 12:12:38 +0100 Subject: [PATCH 1/2] Fix cluster print job constraints typing and optionality --- ...raint.py => ClusterPrintJobConstraints.py} | 2 +- .../src/Models/Http/ClusterPrintJobStatus.py | 29 +++++++++++++------ 2 files changed, 21 insertions(+), 10 deletions(-) rename plugins/UM3NetworkPrinting/src/Models/Http/{ClusterPrintJobConstraint.py => ClusterPrintJobConstraints.py} (94%) diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraint.py b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraints.py similarity index 94% rename from plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraint.py rename to plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraints.py index 5271130dd6..b72e9ecb1e 100644 --- a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraint.py +++ b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobConstraints.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from typing import Optional diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py index 6e46c12cf0..e818da45b1 100644 --- a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py +++ b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Ultimaker B.V. +# Copyright (c) 2021 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from typing import List, Optional, Union, Dict, Any @@ -8,7 +8,7 @@ from .ClusterBuildPlate import ClusterBuildPlate from .ClusterPrintJobConfigurationChange import ClusterPrintJobConfigurationChange from .ClusterPrintJobImpediment import ClusterPrintJobImpediment from .ClusterPrintCoreConfiguration import ClusterPrintCoreConfiguration -from .ClusterPrintJobConstraint import ClusterPrintJobConstraints +from .ClusterPrintJobConstraints import ClusterPrintJobConstraints from ..UM3PrintJobOutputModel import UM3PrintJobOutputModel from ..ConfigurationChangeModel import ConfigurationChangeModel from ..BaseModel import BaseModel @@ -18,13 +18,24 @@ from ...ClusterOutputController import ClusterOutputController class ClusterPrintJobStatus(BaseModel): """Model for the status of a single print job in a cluster.""" - def __init__(self, created_at: str, force: bool, machine_variant: str, name: str, started: bool, status: str, - time_total: int, uuid: str, + def __init__(self, + created_at: str, + force: bool, + machine_variant: str, + name: str, + started: bool, + status: str, + time_total: int, + uuid: str, configuration: List[Union[Dict[str, Any], ClusterPrintCoreConfiguration]], - constraints: List[Union[Dict[str, Any], ClusterPrintJobConstraints]], - last_seen: Optional[float] = None, network_error_count: Optional[int] = None, - owner: Optional[str] = None, printer_uuid: Optional[str] = None, time_elapsed: Optional[int] = None, - assigned_to: Optional[str] = None, deleted_at: Optional[str] = None, + constraints: Optional[Union[Dict[str, Any], ClusterPrintJobConstraints]] = None, + last_seen: Optional[float] = None, + network_error_count: Optional[int] = None, + owner: Optional[str] = None, + printer_uuid: Optional[str] = None, + time_elapsed: Optional[int] = None, + assigned_to: Optional[str] = None, + deleted_at: Optional[str] = None, printed_on_uuid: Optional[str] = None, configuration_changes_required: List[ Union[Dict[str, Any], ClusterPrintJobConfigurationChange]] = None, @@ -66,7 +77,7 @@ class ClusterPrintJobStatus(BaseModel): self.assigned_to = assigned_to self.configuration = self.parseModels(ClusterPrintCoreConfiguration, configuration) - self.constraints = self.parseModels(ClusterPrintJobConstraints, constraints) + self.constraints = self.parseModel(ClusterPrintJobConstraints, constraints) self.created_at = created_at self.force = force self.last_seen = last_seen From aac004cd2bee5fe0b6b88a237ae526e532ff74dd Mon Sep 17 00:00:00 2001 From: Chris ter Beke Date: Thu, 25 Feb 2021 12:20:32 +0100 Subject: [PATCH 2/2] Fix case where constraints is None --- .../src/Models/Http/ClusterPrintJobStatus.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py index e818da45b1..987ca9fab1 100644 --- a/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py +++ b/plugins/UM3NetworkPrinting/src/Models/Http/ClusterPrintJobStatus.py @@ -74,10 +74,9 @@ class ClusterPrintJobStatus(BaseModel): printer :param preview_url: URL to the preview image (same as wou;d've been included in the ufp). """ - self.assigned_to = assigned_to self.configuration = self.parseModels(ClusterPrintCoreConfiguration, configuration) - self.constraints = self.parseModel(ClusterPrintJobConstraints, constraints) + self.constraints = self.parseModel(ClusterPrintJobConstraints, constraints) if constraints else None self.created_at = created_at self.force = force self.last_seen = last_seen @@ -94,7 +93,6 @@ class ClusterPrintJobStatus(BaseModel): self.deleted_at = deleted_at self.printed_on_uuid = printed_on_uuid self.preview_url = preview_url - self.configuration_changes_required = self.parseModels(ClusterPrintJobConfigurationChange, configuration_changes_required) \ if configuration_changes_required else []