You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2025/04/03 14:49:40 UTC
(tooling-trusted-release) branch main updated: Make path checks more efficient and increase date resolutions
This is an automated email from the ASF dual-hosted git repository.
sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-release.git
The following commit(s) were added to refs/heads/main by this push:
new 290089e Make path checks more efficient and increase date resolutions
290089e is described below
commit 290089e115d79dbb771732c290cf3a7851afab49
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Apr 3 15:47:13 2025 +0100
Make path checks more efficient and increase date resolutions
- Makes path checks more efficient by checking for existence against
the cached list of paths instead of checking the filesystem again.
- Increases the resolution of all displayed dates in the user
interface to the nearest second from the nearest minute.
- Allows workers to process up to ten tasks before they exit, to
improve the performance in the user interface of batched background
tasks.
---
atr/routes/draft.py | 13 ++++++++++++-
atr/tasks/checks/paths.py | 35 +++++++++++++++++++++--------------
atr/templates/candidate-resolve.html | 10 +++++-----
atr/templates/candidate-vote.html | 2 +-
atr/templates/draft-promote.html | 2 +-
atr/templates/draft-review-path.html | 4 ++--
atr/templates/draft-review.html | 16 +++++++++++++++-
atr/templates/draft-tools.html | 2 +-
atr/templates/phase-viewer.html | 2 +-
atr/templates/preview-promote.html | 2 +-
atr/templates/preview-review.html | 2 +-
atr/templates/release-review.html | 2 +-
atr/worker.py | 9 +++++++--
13 files changed, 69 insertions(+), 32 deletions(-)
diff --git a/atr/routes/draft.py b/atr/routes/draft.py
index 81b9e4c..b70df80 100644
--- a/atr/routes/draft.py
+++ b/atr/routes/draft.py
@@ -495,8 +495,17 @@ async def review(session: routes.CommitterSession, project_name: str, version_na
release_name=release.name, path=str(path), status=models.CheckResultStatus.FAILURE
).all()
- delete_file_form = await DeleteFileForm.create_form()
+ # # TODO: This is only accurate to a second
+ # oldest_check_result = None
+ # latest_check_result = None
+ # for path_success in path_successes:
+ # for check_result in path_successes[path_success]:
+ # if (oldest_check_result is None) or (check_result.created < oldest_check_result):
+ # oldest_check_result = check_result.created
+ # if (latest_check_result is None) or (check_result.created > latest_check_result):
+ # latest_check_result = check_result.created
+ delete_file_form = await DeleteFileForm.create_form()
return await quart.render_template(
"draft-review.html",
asf_id=session.uid,
@@ -505,6 +514,8 @@ async def review(session: routes.CommitterSession, project_name: str, version_na
release=release,
paths=paths,
server_domain=session.host,
+ # oldest_check_result=oldest_check_result,
+ # latest_check_result=latest_check_result,
templates=path_templates,
substitutions=path_substitutions,
artifacts=path_artifacts,
diff --git a/atr/tasks/checks/paths.py b/atr/tasks/checks/paths.py
index b4465e5..f74f190 100644
--- a/atr/tasks/checks/paths.py
+++ b/atr/tasks/checks/paths.py
@@ -37,7 +37,9 @@ class Check(pydantic.BaseModel):
base_release_dir: str = pydantic.Field(..., description="Absolute path to the base directory of the release draft")
-async def _check_artifact_rules(base_path: pathlib.Path, relative_path: pathlib.Path, errors: list[str]) -> None:
+async def _check_artifact_rules(
+ base_path: pathlib.Path, relative_path: pathlib.Path, relative_paths: set[str], errors: list[str]
+) -> None:
"""Check rules specific to artifact files."""
full_path = base_path / relative_path
@@ -47,16 +49,21 @@ async def _check_artifact_rules(base_path: pathlib.Path, relative_path: pathlib.
errors.append(f"Missing corresponding signature file ({relative_path}.asc)")
# RDP requires one of .sha256 or .sha512
- sha256_path = full_path.with_suffix(full_path.suffix + ".sha256")
- sha512_path = full_path.with_suffix(full_path.suffix + ".sha512")
- has_sha256 = await aiofiles.os.path.exists(sha256_path)
- has_sha512 = await aiofiles.os.path.exists(sha512_path)
+ relative_sha256_path = relative_path.with_suffix(relative_path.suffix + ".sha256")
+ relative_sha512_path = relative_path.with_suffix(relative_path.suffix + ".sha512")
+ has_sha256 = str(relative_sha256_path) in relative_paths
+ has_sha512 = str(relative_sha512_path) in relative_paths
if not (has_sha256 or has_sha512):
- errors.append(f"Missing corresponding checksum file ({relative_path}.sha256 or .sha512)")
+ errors.append(f"Missing corresponding checksum file ({relative_path}.sha256 or {relative_path}.sha512)")
async def _check_metadata_rules(
- base_path: pathlib.Path, relative_path: pathlib.Path, ext_metadata: str, errors: list[str], warnings: list[str]
+ _base_path: pathlib.Path,
+ relative_path: pathlib.Path,
+ relative_paths: set[str],
+ ext_metadata: str,
+ errors: list[str],
+ warnings: list[str],
) -> None:
"""Check rules specific to metadata files (.asc, .sha*, etc.)."""
suffixes = set(relative_path.suffixes)
@@ -81,6 +88,11 @@ async def _check_metadata_rules(
if ext_metadata not in {".asc", ".sha256", ".sha512", ".md5", ".sha", ".sha1"}:
warnings.append("The use of this metadata file is discouraged")
+ # Check whether the corresponding artifact exists
+ artifact_path_base = str(relative_path).removesuffix(ext_metadata)
+ if artifact_path_base not in relative_paths:
+ errors.append(f"Metadata file exists but corresponding artifact '{artifact_path_base}' is missing")
+
async def _check_path_process_single(
base_path: pathlib.Path,
@@ -114,15 +126,10 @@ async def _check_path_process_single(
if ext_artifact:
_LOGGER.info("Checking artifact rules for %s", full_path)
- await _check_artifact_rules(base_path, relative_path, errors)
+ await _check_artifact_rules(base_path, relative_path, relative_paths, errors)
elif ext_metadata:
_LOGGER.info("Checking metadata rules for %s", full_path)
- await _check_metadata_rules(base_path, relative_path, ext_metadata, errors, warnings)
-
- # Check whether the corresponding artifact exists
- artifact_path_base = str(relative_path).removesuffix(ext_metadata)
- if artifact_path_base not in relative_paths:
- errors.append(f"Metadata file exists but corresponding artifact '{artifact_path_base}' is missing")
+ await _check_metadata_rules(base_path, relative_path, relative_paths, ext_metadata, errors, warnings)
else:
_LOGGER.info("Checking general rules for %s", full_path)
allowed_top_level = {"LICENSE", "NOTICE", "README", "CHANGES"}
diff --git a/atr/templates/candidate-resolve.html b/atr/templates/candidate-resolve.html
index 6f76771..f417c0e 100644
--- a/atr/templates/candidate-resolve.html
+++ b/atr/templates/candidate-resolve.html
@@ -38,7 +38,7 @@
<div class="d-flex flex-wrap gap-3 pb-3 mb-2 border-bottom text-secondary fs-6">
<span class="atr-candidate-meta-item">Stage: {{ candidate.stage.value.upper() }}</span>
<span class="atr-candidate-meta-item">Phase: {{ candidate.phase.value.upper() }}</span>
- <span class="atr-candidate-meta-item">Created: {{ candidate.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="atr-candidate-meta-item">Created: {{ candidate.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
{% set vote_task = candidate_vote_tasks[candidate.name] %}
@@ -46,11 +46,11 @@
{% if vote_task %}
{% if vote_task.status.value == "completed" %}
<p class="mb-0 text-success fw-semibold">
- <i class="bi bi-check-circle-fill me-1"></i> Vote email sent: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M UTC") }}
+ <i class="bi bi-check-circle-fill me-1"></i> Vote email sent: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M:%S UTC") }}
</p>
{% elif vote_task.status.value == "failed" %}
<p class="mb-1 text-danger fw-semibold">
- <i class="bi bi-x-octagon-fill me-1"></i> Vote email failed: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M UTC") }}
+ <i class="bi bi-x-octagon-fill me-1"></i> Vote email failed: {{ vote_task.completed.strftime("%Y-%m-%d %H:%M:%S UTC") }}
</p>
<div class="alert alert-danger mt-2 mb-0 p-2" role="alert">
<p class="mb-0 p-2 text-danger">{{ vote_task.error }}</p>
@@ -59,9 +59,9 @@
<p class="mb-0 text-warning fw-semibold">
<i class="bi bi-hourglass-split me-1"></i> Vote email status: {{ vote_task.status.value.upper() }}
{% if vote_task.started %}
- (Started: {{ vote_task.started.strftime("%Y-%m-%d %H:%M UTC") }})
+ (Started: {{ vote_task.started.strftime("%Y-%m-%d %H:%M:%S UTC") }})
{% else %}
- (Added: {{ vote_task.added.strftime("%Y-%m-%d %H:%M UTC") }})
+ (Added: {{ vote_task.added.strftime("%Y-%m-%d %H:%M:%S UTC") }})
{% endif %}
</p>
{% endif %}
diff --git a/atr/templates/candidate-vote.html b/atr/templates/candidate-vote.html
index 6f4bdf2..d3b2461 100644
--- a/atr/templates/candidate-vote.html
+++ b/atr/templates/candidate-vote.html
@@ -44,7 +44,7 @@
<span class="candidate-meta-item">Stage: {{ candidate.stage.value.upper() }}</span>
<span class="candidate-meta-item">Phase: {{ candidate.phase.value.upper() }}</span>
<!-- <span class="candidate-meta-item">Project: {{ candidate.project.name if candidate.project else "unknown" }}</span> -->
- <span class="candidate-meta-item">Created: {{ candidate.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="candidate-meta-item">Created: {{ candidate.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
<div class="d-flex gap-3 align-items-center pt-2">
<a class="btn btn-primary"
diff --git a/atr/templates/draft-promote.html b/atr/templates/draft-promote.html
index 0df0466..904d604 100644
--- a/atr/templates/draft-promote.html
+++ b/atr/templates/draft-promote.html
@@ -51,7 +51,7 @@
<div class="d-flex flex-wrap gap-3 text-secondary fs-6">
<span class="atr-candidate-meta-item">Stage: {{ candidate_draft.stage.value.upper() }}</span>
<span class="atr-candidate-meta-item">Phase: {{ candidate_draft.phase.value.upper() }}</span>
- <span class="atr-candidate-meta-item">Created: {{ candidate_draft.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="atr-candidate-meta-item">Created: {{ candidate_draft.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
</div>
</div>
diff --git a/atr/templates/draft-review-path.html b/atr/templates/draft-review-path.html
index 57a52f7..28ea931 100644
--- a/atr/templates/draft-review-path.html
+++ b/atr/templates/draft-review-path.html
@@ -21,7 +21,7 @@
<strong>Size:</strong> {{ format_file_size(package.bytes_size) }}
</p>
<p class="mb-0">
- <strong>Uploaded:</strong> {{ package.uploaded.strftime("%Y-%m-%d %H:%M UTC") }}
+ <strong>Uploaded:</strong> {{ package.uploaded.strftime("%Y-%m-%d %H:%M:%S UTC") }}
</p>
</div>
@@ -106,7 +106,7 @@
</div>
<div class="small">
<div>
- Checked: {{ check_result.created.strftime("%Y-%m-%d %H:%M UTC") if check_result.created else "Not checked" }}
+ Checked: {{ check_result.created.strftime("%Y-%m-%d %H:%M:%S UTC") if check_result.created else "Not checked" }}
</div>
{% if check_result.message %}<div class="mt-2">{{ check_result.message }}</div>{% endif %}
diff --git a/atr/templates/draft-review.html b/atr/templates/draft-review.html
index b83ce01..0945b39 100644
--- a/atr/templates/draft-review.html
+++ b/atr/templates/draft-review.html
@@ -41,7 +41,7 @@
<strong>Phase:</strong> <span class="badge bg-info">{{ release.phase.value.upper() }}</span>
</p>
<p>
- <strong>Created:</strong> {{ release.created.strftime("%Y-%m-%d %H:%M") }}
+ <strong>Created:</strong> {{ release.created.strftime("%Y-%m-%d %H:%M:%S") }}
</p>
</div>
</div>
@@ -110,6 +110,20 @@
</table>
</div>
+ <!--
+ {% if oldest_check_result or latest_check_result %}
+ <p class="text-muted mt-3 small fst-italic">
+ {% if oldest_check_result %}
+ Checks first ran: {{ oldest_check_result.strftime("%Y-%m-%d %H:%M:%S UTC") }}
+ {% endif %}
+ {% if oldest_check_result and latest_check_result %}|{% endif %}
+ {% if latest_check_result %}
+ Checks last ran: {{ latest_check_result.strftime("%Y-%m-%d %H:%M:%S UTC") }}
+ {% endif %}
+ </p>
+ {% endif %}
+ -->
+
<details>
<summary>Debugging information</summary>
<div class="table-responsive mt-4">
diff --git a/atr/templates/draft-tools.html b/atr/templates/draft-tools.html
index d48e4ba..377dd53 100644
--- a/atr/templates/draft-tools.html
+++ b/atr/templates/draft-tools.html
@@ -21,7 +21,7 @@
<strong>Size:</strong> {{ format_file_size(file_data.bytes_size) }}
</p>
<p class="mb-0">
- <strong>Uploaded:</strong> {{ file_data.uploaded.strftime("%Y-%m-%d %H:%M UTC") }}
+ <strong>Uploaded:</strong> {{ file_data.uploaded.strftime("%Y-%m-%d %H:%M:%S UTC") }}
</p>
</div>
diff --git a/atr/templates/phase-viewer.html b/atr/templates/phase-viewer.html
index 416cb5e..ad5f000 100644
--- a/atr/templates/phase-viewer.html
+++ b/atr/templates/phase-viewer.html
@@ -39,7 +39,7 @@
<strong>Phase:</strong> <span class="badge bg-info">{{ release.phase.value.upper() }}</span>
</p>
<p>
- <strong>Created:</strong> {{ release.created.strftime("%Y-%m-%d %H:%M") }}
+ <strong>Created:</strong> {{ release.created.strftime("%Y-%m-%d %H:%M:%S") }}
</p>
</div>
</div>
diff --git a/atr/templates/preview-promote.html b/atr/templates/preview-promote.html
index 0ef78fa..1dc916e 100644
--- a/atr/templates/preview-promote.html
+++ b/atr/templates/preview-promote.html
@@ -51,7 +51,7 @@
<div class="d-flex flex-wrap gap-3 pb-3 mb-3 border-bottom text-secondary fs-6">
<span class="atr-preview-meta-item">Stage: {{ preview.stage.value.upper() }}</span>
<span class="atr-preview-meta-item">Phase: {{ preview.phase.value.upper() }}</span>
- <span class="atr-preview-meta-item">Created: {{ preview.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="atr-preview-meta-item">Created: {{ preview.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
<div class="row mt-3">
diff --git a/atr/templates/preview-review.html b/atr/templates/preview-review.html
index 982b915..bfd081d 100644
--- a/atr/templates/preview-review.html
+++ b/atr/templates/preview-review.html
@@ -37,7 +37,7 @@
<span class="preview-meta-item">Version: {{ preview.version }}</span>
<span class="preview-meta-item">Stage: {{ preview.stage.value.upper() }}</span>
<span class="preview-meta-item">Phase: {{ preview.phase.value.upper() }}</span>
- <span class="preview-meta-item">Created: {{ preview.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="preview-meta-item">Created: {{ preview.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
<div class="d-flex gap-3 align-items-center pt-2">
<a class="btn btn-outline-primary"
diff --git a/atr/templates/release-review.html b/atr/templates/release-review.html
index 6385f2a..442f018 100644
--- a/atr/templates/release-review.html
+++ b/atr/templates/release-review.html
@@ -35,7 +35,7 @@
<span class="release-meta-item">Version: {{ release.version }}</span>
<span class="release-meta-item">Stage: {{ release.stage.value.upper() }}</span>
<span class="release-meta-item">Phase: {{ release.phase.value.upper() }}</span>
- <span class="release-meta-item">Created: {{ release.created.strftime("%Y-%m-%d %H:%M UTC") }}</span>
+ <span class="release-meta-item">Created: {{ release.created.strftime("%Y-%m-%d %H:%M:%S UTC") }}</span>
</div>
<div class="d-flex gap-3 align-items-center pt-2">
<a class="btn btn-outline-primary"
diff --git a/atr/worker.py b/atr/worker.py
index ffc142c..769d08a 100644
--- a/atr/worker.py
+++ b/atr/worker.py
@@ -219,15 +219,20 @@ async def _task_process(task_id: int, task_type: str, task_args: list[str] | dic
async def _worker_loop_run() -> None:
"""Main worker loop."""
+ processed = 0
+ max_to_process = 10
while True:
try:
task = await _task_next_claim()
if task:
task_id, task_type, task_args = task
await _task_process(task_id, task_type, task_args)
- # Only process one task and then exit
+ processed += 1
+ # Only process max_to_process tasks and then exit
# This prevents memory leaks from accumulating
- break
+ # Another worker will be started automatically when one exits
+ if processed >= max_to_process:
+ break
else:
# No tasks available, wait 100ms before checking again
await asyncio.sleep(0.1)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org