Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karton v5.4.0 optimizations #83

Merged
merged 2 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion karton/dashboard/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.5.1"
__version__ = "1.6.0"
14 changes: 9 additions & 5 deletions karton/dashboard/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -372,8 +376,8 @@ def get_task_api(task_id):
@blueprint.route("/analysis/<root_id>", 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(
Expand All @@ -384,8 +388,8 @@ def get_analysis(root_id):
@blueprint.route("/api/analysis/<root_id>", 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())
Expand Down
2 changes: 1 addition & 1 deletion karton/dashboard/templates/analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h4>Tasks</h4>
<a href="{{ url_for('dashboard.get_queue', queue_name=identity) }}">{{identity}}</a>
</td>
<td>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.uid }}</a>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.task_uid }}</a>
</td>
<td>
{% if task.priority.value != 'normal' %}
Expand Down
2 changes: 1 addition & 1 deletion karton/dashboard/templates/crashed.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h4>
{% for task in queue.crashed_tasks|sort(attribute='last_update', reverse=True) %}
<tr>
<td>
<a href="{{url_for('dashboard.get_task', task_id=task.uid)}}">{{ task.uid }}</a>
<a href="{{url_for('dashboard.get_task', task_id=task.uid)}}">{{ task.task_uid }}</a>
</td>
<td><pre>{{ task.last_update|render_timestamp }}</pre></td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion karton/dashboard/templates/queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h4>
{% for task in queue.pending_tasks|sort(attribute='last_update', reverse=True) %}
<tr>
<td>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.uid }}</a>
<a href="{{ url_for('dashboard.get_task', task_id=task.uid) }}">{{ task.task_uid }}</a>
</td>
<td><pre>{{ task.last_update|render_timestamp }}</pre></td>
<td>
Expand Down
4 changes: 2 additions & 2 deletions karton/dashboard/templates/task.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% block title %}karton task {{ task.uid }}{% endblock %}
{% block content %}
<div class="bs-component" style="padding-top: 10px">
<h3 class="text-center">task <code>{{ task.uid }}</code></h3>
<h3 class="text-center">task <code>{{ task.task_uid }}</code></h3>

<dl class="row">
<dt class="col-3">Status</dt>
Expand All @@ -11,7 +11,7 @@ <h3 class="text-center">task <code>{{ task.uid }}</code></h3>
<dd class="col-9"><span class="badge bg-dark">{{task.priority.value}}</span></dd>
<dt class="col-3">Last status change</dt>
<dd class="col-9">{{task.last_update}} ({{task.last_update_delta}})</dd>
<dt class="col-3">UID</dt>
<dt class="col-3">Full UID</dt>
<dd class="col-9">{{task.uid}}</dd>
<dt class="col-3">Parent UID</dt>
<dd class="col-9">{{task.parent_uid}}</dd>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading