Collection as an ETL pipeline; runs_clean.csv from every source; Report a run
- collection/pipeline.yaml declares every source (extract kind, transform, privacy rules, load target, run source); `python -m collection update|build` - extract keeps data/raw/<source>/current + previous only (git-ignored); data/manifest.json records the current raw checksum and change date - transforms are pure; validate checks runs against data/dictionary.yaml before load; load writes byte-stable files only when they change - data/public/runs_clean.csv: every run from every source with a new `source` column (reddit spreadsheet, reddit thread, reported, bot, reddit pdf); the sheet's own row label moves to `entry`; run_id is text - bot importer ported to Python (same output as bot.js on the fixture); labels and crosswalk in collection/specs/bot.yaml, written into graph.js - Reddit through the official API (result links to add by hand); the 12 result pages move to collection/manual/reddit_results.yaml - "Report a run": a GitHub issue form generated from collection/specs/report_form.yaml, collected as source "reported", plus a site tab pointing to it, the community spreadsheet and the megathread - analysis and the route model read runs_clean.csv (sources in measures.yaml); stats.json and policy.json unchanged apart from the factor's new name - daily workflow runs the pipeline; the raw store is kept between runs in the Actions cache, encrypted with RAW_ARCHIVE_KEY Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
61bc50583c
commit
3b24a11f5a
@@ -0,0 +1,60 @@
|
||||
"""The "Report a run" GitHub issue form, written from collection/specs/report_form.yaml, and the parser for the
|
||||
issues it creates (GitHub renders each answer as "### <question>" followed by the answer)."""
|
||||
import re
|
||||
|
||||
import yaml
|
||||
|
||||
from .common import read_yaml
|
||||
|
||||
|
||||
class _Dumper(yaml.SafeDumper):
|
||||
pass
|
||||
|
||||
|
||||
def _str(dumper, s):
|
||||
# multi-line text (the intro) as a readable block
|
||||
return dumper.represent_scalar("tag:yaml.org,2002:str", s, style="|" if "\n" in s else None)
|
||||
|
||||
|
||||
_Dumper.add_representer(str, _str)
|
||||
|
||||
SPEC_PATH = "collection/specs/report_form.yaml"
|
||||
TEMPLATE = ".github/ISSUE_TEMPLATE/report-a-run.yml"
|
||||
NOT_SURE = "Not sure"
|
||||
NO_RESPONSE = {"", "_No response_", "None", NOT_SURE}
|
||||
|
||||
|
||||
def spec():
|
||||
return read_yaml(SPEC_PATH)
|
||||
|
||||
|
||||
def render(s=None):
|
||||
s = s or spec()
|
||||
body = [{"type": "markdown", "attributes": {"value": s["intro"]}}]
|
||||
for f in s["fields"]:
|
||||
if f.get("type") == "integer":
|
||||
item = {"type": "input", "id": f["id"], "attributes": {"label": f["label"], "placeholder": "e.g. 3"}}
|
||||
else:
|
||||
opts = list(f["options"])
|
||||
if not f.get("required"):
|
||||
opts.append(NOT_SURE)
|
||||
item = {"type": "dropdown", "id": f["id"], "attributes": {"label": f["label"], "options": opts}}
|
||||
item["validations"] = {"required": bool(f.get("required"))}
|
||||
body.append(item)
|
||||
form = {"name": s["name"], "description": s["description"], "title": s["title"], "labels": [s["label"]], "body": body}
|
||||
head = f"# Written by collection/etl/report_form.py from {SPEC_PATH}: edit that file, then run `python -m collection build`.\n"
|
||||
return head + yaml.dump(form, Dumper=_Dumper, sort_keys=False, allow_unicode=True, width=1000)
|
||||
|
||||
|
||||
def parse_body(body, s=None):
|
||||
"""Issue body -> {field id: chosen option label or text}. Unanswered questions are left out."""
|
||||
s = s or spec()
|
||||
by_label = {f["label"].strip(): f["id"] for f in s["fields"]}
|
||||
out = {}
|
||||
for block in re.split(r"^### ", body or "", flags=re.M)[1:]:
|
||||
q, _, a = block.partition("\n")
|
||||
fid = by_label.get(q.strip())
|
||||
a = a.strip()
|
||||
if fid and a not in NO_RESPONSE:
|
||||
out[fid] = a
|
||||
return out
|
||||
Reference in New Issue
Block a user