From 5e56143b9823d5e91c0c56be89657829f1dcbb05 Mon Sep 17 00:00:00 2001 From: psrok1 Date: Thu, 16 May 2024 17:24:57 +0200 Subject: [PATCH 1/2] Karton v5.4.0 optimizations --- karton/dashboard/__version__.py | 2 +- karton/dashboard/app.py | 10 +++++++--- karton/dashboard/templates/analysis.html | 2 +- karton/dashboard/templates/crashed.html | 2 +- karton/dashboard/templates/queue.html | 2 +- karton/dashboard/templates/task.html | 4 ++-- requirements.txt | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/karton/dashboard/__version__.py b/karton/dashboard/__version__.py index 0f228f2..e4adfb8 100644 --- a/karton/dashboard/__version__.py +++ b/karton/dashboard/__version__.py @@ -1 +1 @@ -__version__ = "1.5.1" +__version__ = "1.6.0" diff --git a/karton/dashboard/app.py b/karton/dashboard/app.py index 23591c0..829a01c 100644 --- a/karton/dashboard/app.py +++ b/karton/dashboard/app.py @@ -75,6 +75,10 @@ def __init__(self, task: Task) -> None: def headers(self) -> Dict[str, Any]: return self._task.headers + @property + def task_uid(self): + return self._task.task_uid + @property def uid(self) -> str: return self._task.uid @@ -104,7 +108,7 @@ def last_update_delta(self) -> str: return pretty_delta(self.last_update) def to_dict(self) -> Dict[str, Any]: - return json.loads(self._task.serialize()) + return self._task.to_dict() def to_json(self, indent=None) -> str: return self._task.serialize(indent=indent) @@ -384,8 +388,8 @@ def get_analysis(root_id): @blueprint.route("/api/analysis/", methods=["GET"]) def get_analysis_api(root_id): state = KartonState(karton.backend) - analysis = state.analyses.get(root_id) - if not analysis: + analysis = state.get_analysis(root_id) + if not analysis.tasks: return jsonify({"error": "Analysis doesn't exist"}), 404 return jsonify(AnalysisView(analysis).to_dict()) diff --git a/karton/dashboard/templates/analysis.html b/karton/dashboard/templates/analysis.html index 358d269..3f949c4 100644 --- a/karton/dashboard/templates/analysis.html +++ b/karton/dashboard/templates/analysis.html @@ -35,7 +35,7 @@

Tasks

{{identity}} - {{ task.uid }} + {{ task.task_uid }} {% if task.priority.value != 'normal' %} diff --git a/karton/dashboard/templates/crashed.html b/karton/dashboard/templates/crashed.html index c2a3518..d460566 100644 --- a/karton/dashboard/templates/crashed.html +++ b/karton/dashboard/templates/crashed.html @@ -28,7 +28,7 @@

{% for task in queue.crashed_tasks|sort(attribute='last_update', reverse=True) %} - {{ task.uid }} + {{ task.task_uid }}
{{ task.last_update|render_timestamp }}
diff --git a/karton/dashboard/templates/queue.html b/karton/dashboard/templates/queue.html index bfd468b..dd8ca61 100644 --- a/karton/dashboard/templates/queue.html +++ b/karton/dashboard/templates/queue.html @@ -23,7 +23,7 @@

{% for task in queue.pending_tasks|sort(attribute='last_update', reverse=True) %} - {{ task.uid }} + {{ task.task_uid }}
{{ task.last_update|render_timestamp }}
diff --git a/karton/dashboard/templates/task.html b/karton/dashboard/templates/task.html index 5a648f8..aa66684 100644 --- a/karton/dashboard/templates/task.html +++ b/karton/dashboard/templates/task.html @@ -2,7 +2,7 @@ {% block title %}karton task {{ task.uid }}{% endblock %} {% block content %}
-

task {{ task.uid }}

+

task {{ task.task_uid }}

Status
@@ -11,7 +11,7 @@

task {{ task.uid }}

{{task.priority.value}}
Last status change
{{task.last_update}} ({{task.last_update_delta}})
-
UID
+
Full UID
{{task.uid}}
Parent UID
{{task.parent_uid}}
diff --git a/requirements.txt b/requirements.txt index b62d18e..6a0bbbf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Flask==3.0.0 -karton-core>=5.1.0,<6.0.0 +karton-core>=5.4.0,<6.0.0 mistune<3.0.0 prometheus_client==0.11.0 networkx==2.6.3 From 7f9425c727fee92a68675e4319231cf0ef0f0355 Mon Sep 17 00:00:00 2001 From: psrok1 Date: Thu, 16 May 2024 17:27:04 +0200 Subject: [PATCH 2/2] Use get_analysis in non-API endpoint as well --- karton/dashboard/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/karton/dashboard/app.py b/karton/dashboard/app.py index 829a01c..7bab6fd 100644 --- a/karton/dashboard/app.py +++ b/karton/dashboard/app.py @@ -376,8 +376,8 @@ def get_task_api(task_id): @blueprint.route("/analysis/", methods=["GET"]) def get_analysis(root_id): state = KartonState(karton.backend) - analysis = state.analyses.get(root_id) - if not analysis: + analysis = state.get_analysis(root_id) + if not analysis.tasks: return jsonify({"error": "Analysis doesn't exist"}), 404 return render_template(