Skip to content
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
7 changes: 5 additions & 2 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,11 @@ values the usage at what renting the GPU would have cost.
else the catalog). A day keeps the price it was first valued at; a day without a price gets one when Krater has
one. An admin changes the GPU or price from the project page (`admin_change_ospool_valuation`), for later days only.
OSG doesn't record which GPU a job used, so the value is an estimate, shown as one.
- **Display.** The project shows *Approved · OSPool*. Its page has an OSPool card (totals, worth, the last 30 days
with usage, when it was last read), seen by anyone who can see the project. `/admin` lists every grant. The funder
- **Display.** The project shows *Approved · Partner grant*. Its page has a *Partner grant* card (totals, worth, the
last 30 days with usage, when it was last read), seen by anyone who can see the project.
- **Not named outside admin pages.** What members and reviewers see (the badge, the card, the project's Slack
channel, the residency line, the review queue and the public Help guides) says "partner" and never OSPool or OSG. Admin pages, the audit log, the funder packet and the two OSPool guides on Help
(listed and served to admins only) keep the name. `/admin` lists every grant. The funder
packet's *OSPool usage* field (ticked at first) adds the totals and worth for a project with a grant.

## Admin overrides
Expand Down
7 changes: 5 additions & 2 deletions docs/guides/ospool-grants.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ accounting shows it. The rules are in [SPEC.md](../SPEC.md) "OSPool grants".
`PatchworkLabs_Ganymede01`, with an adult Patchwork staff member as its PI.
- The project is approved in Krater. Approving it *awaiting 3rd party review* keeps its budget from being added while
you wait for OSPool.
- Every team member is a verified US resident in Weave. The project page's "Not OSPool-ready" line says who isn't.
- Every team member is a verified US resident in Weave. The project page's "Not all US residents" line says who isn't.
- The project holds no Krater budget. If it has some, reclaim it first from the Admin card.

## Record the grant
Expand All @@ -26,7 +26,10 @@ accounting shows it. The rules are in [SPEC.md](../SPEC.md) "OSPool grants".
6. Give a reason and choose **Record OSPool grant**.

Krater cancels the project's held budget and clears its funding hold, since the OSPool funds it instead. Nothing goes
to the ledger or Quilt. The project now shows *Approved · OSPool*, and a post in its channel says what you did.
to the ledger or Quilt. The project now shows *Approved · Partner grant*, and a post in its channel says what you did.

Members and reviewers never see OSPool or OSG named: the badge, the project's card and the channel post all say
"partner grant". Your **reason** goes in the channel as you typed it, so leave the name out of it.

## Read the usage

Expand Down
28 changes: 14 additions & 14 deletions docs/guides/reviewing-and-admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Members' side of all this: [Using Krater](using-krater.md) and [Running jobs and
- [Admin overrides](#admin-overrides)
- [Compute settings](#compute-settings)
- [Watching compute](#watching-compute)
- [Funders and OSPool](#funders-and-ospool)
- [Funders](#funders)
- [Alerts](#alerts)

## Reviewing
Expand Down Expand Up @@ -104,7 +104,7 @@ Approve a project before Patchwork can pay for it with **Fund it now?** on the w

- **Yes:** the budget is added once the team is verified (the usual case);
- **No: approve as awaiting funding**: the money isn't there yet;
- **No: approve as awaiting 3rd party review**: a funder (OSPool, say) has to review it first.
- **No: approve as awaiting 3rd party review**: a funder has to review it first.

While a hold is set, the project is approved and reads *Approved · awaiting funding* (or *· awaiting 3rd party
review*). Every grant is held, nothing reaches the ledger or Quilt, and no compute starts. Machines already running
Expand Down Expand Up @@ -137,16 +137,16 @@ nothing else may change the project's budget: no amendment, adjustment or reclai
| --- | --- |
| Status counts | How many projects are in each status |
| **Budget held** | Every held grant: the amount, and who or what it's waiting on |
| **OSPool grants** | Every project with an OSPool grant |
| **Partner grants** | Every project a partner funds outside Krater's budget |
| **All projects** | Search by title or the lead's Patchwork ID, filter by status; ceiling, spend and remaining for each |
| **Recent activity** | The latest audit events. **All activity** (`/admin/activity`) has the full log, and per project the budget ledger |
| **Approval policy** | The policy in force |
| **Public gallery** | How the gallery names members under 18: full name, first name only (the default), or not named |
| **Delivery to Quilt** | Whether budget and submission events have reached Quilt, Patchwork's finance system, with retry and dismiss for any it refused |

Its other pages: **Live compute** (`/admin/live`, every queued and running job and box), **Images**
(`/admin/images`, every image members used, and inspecting one), **Share with OSPool** (`/admin/funders/ospool`)
and **Compute settings** (`/admin/compute`).
(`/admin/images`, every image members used, and inspecting one), the funder page (a
button at the top of `/admin`) and **Compute settings** (`/admin/compute`).

## Admin overrides

Expand All @@ -161,7 +161,7 @@ project's Slack channel so reviewers see it.
| **Funding hold** | Set, change or clear the project's hold |
| **Hourly cap** | The most any one machine of the project may cost per hour, or back to the default ($5) |
| **Withdraw project (admin)** | Close it: unspent budget reclaimed, machines destroyed, channels archived a week later |
| **Record an OSPool grant** | See [OSPool grants](ospool-grants.md) |
| **Record a partner grant** | For a project a partner funds instead of Krater's budget. Admins: see the grant guide on Help |

**Your own project** (you lead it, are on its team or are invited): you can't decide it, add to its budget, raise its
hourly cap or clear its funding hold. Another admin, or the normal review, has to. You can still cut, reclaim or
Expand Down Expand Up @@ -227,14 +227,14 @@ The page also shows Vast's daily search quota and any hourly spend check that di
- **Budgets:** the project's channel is warned at 80% and 95% of the ceiling, and Krater stops the project's
machines just before 100%.

## Funders and OSPool
## Funders

- **Share with OSPool** (`/admin/funders/ospool`) lists every project and proposal, newest first, each saying whether
its whole team are verified US residents (OSPool takes only those). Tick the projects and the fields to include,
and download a PDF to send. It never includes emails, Patchwork IDs, demographics or secrets, names members under 18
as the gallery setting says, asks Weave again on each download, and is audited.
- **OSPool grants** let a project run on the OSPool instead of Krater's budget: [OSPool grants](ospool-grants.md) and
[Share with OSPool](share-with-ospool.md).
- The **funder page** (admins) lists every project and proposal, newest first, each saying whether its whole team
are verified US residents. Tick the projects and the fields to include, and download a PDF to send. It never
includes emails, Patchwork IDs, demographics or secrets, names members under 18 as the gallery setting says, asks
Weave again on each download, and is audited.
- **Partner grants** let a partner fund a project's compute instead of Krater's budget. Signed in as an admin, Help
lists the guides for both.

## Alerts

Expand All @@ -244,7 +244,7 @@ root cause (a DNS lookup, a connection refused or timed out ...). The Problems c
failure of the last 24 hours, kept for 14 days. It covers:

- a background task that keeps failing: the compute scheduler, spend reconciliation, cleaning up unfinished uploads,
recording Vast's prices, releasing held grants, syncing admins' SSH keys to boxes, importing OSPool usage, delivery
recording Vast's prices, releasing held grants, syncing admins' SSH keys to boxes, importing partner-grant usage, delivery
to Quilt, archiving in Stash, and Slack tasks;
- Quilt's outbox backing up;
- Stash archive requests backing up;
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/share-with-ospool.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ only whether every member is a verified US resident.

## A team isn't OSPool-ready

The project page tells reviewers and admins who on the team isn't a verified US resident (the "Not OSPool-ready"
The project page tells reviewers and admins who on the team isn't a verified US resident (the "Not all US residents"
line). Each member does the residency check on Weave's verification page. You can still send the project; the PDF
says its team isn't all verified US residents.
6 changes: 3 additions & 3 deletions docs/guides/using-krater.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You can withdraw a project at any point before it's completed.
| **Approved** | You have a budget and can run compute (once your team is verified) |
| **Approved · awaiting verification** | Approved, but the budget waits until every team member is verified in Weave |
| **Approved · awaiting funding** or **· awaiting 3rd party review** | Approved, but Patchwork can't fund it yet. An admin releases it |
| **Approved · OSPool** | Your compute runs on the OSPool instead of Krater's budget (see [OSPool grants](ospool-grants.md)) |
| **Approved · Partner grant** | A partner funds your compute outside Krater's budget. Krater only shows what you used |
| **Pending completion review** | You've submitted your final write-up |
| **Completion changes requested** | Reviewers asked for changes to the write-up |
| **Completed** | Done. Published in the gallery |
Expand Down Expand Up @@ -281,8 +281,8 @@ your amount with it.
**Can someone outside Patchwork join my team?** They need a Patchwork account first, then you invite them by
Patchwork ID.

**Can I use my own computer's GPU or another cloud?** Krater only tracks compute it rents. For OSPool, see
[OSPool grants](ospool-grants.md).
**Can I use my own computer's GPU or another cloud?** Krater only tracks compute it rents, and compute a partner
grant funds.

**Who sees my project?** Your team, reviewers and admins while it's in progress. The public sees it only once it's
completed, in the gallery.
4 changes: 3 additions & 1 deletion krater/services/funding_holds.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def parse(value: str | None) -> FundingHold | None:


#: An approved project the OSPool funds outside Krater (`krater.services.ospool_grants`): shown, never a hold.
OSPOOL = "OSPool"
#: Shown on the status badge, which never names the partner (docs/SPEC.md "OSPool grants"). Admins see the name on
#: their own pages (the admin index's grant list, Share with OSPool).
OSPOOL = "Partner grant"


def approval_label(project: Project, *, verification_held: bool, ospool: bool = False) -> str | None:
Expand Down
6 changes: 6 additions & 0 deletions krater/services/ospool_grants.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

AUDIT_RECORD = "admin_record_ospool_grant"
AUDIT_VALUATION = "admin_change_ospool_valuation"
#: What the project's Slack channel is told for each. Its team reads it, so it never names OSPool (docs/SPEC.md
#: "OSPool grants"). The audit log keeps the actions above.
SLACK_RECORD = "admin_record_partner_grant"
SLACK_VALUATION = "admin_change_partner_grant_valuation"
#: `OspoolUsageDay.rate_source` for the grant's own price.
SOURCE_ADMIN = "admin"
#: How many recent days each import reads again, since OSG corrects them.
Expand Down Expand Up @@ -411,6 +415,8 @@ def rate_text(grant: OspoolGrant) -> str:
__all__ = [
"AUDIT_RECORD",
"AUDIT_VALUATION",
"SLACK_RECORD",
"SLACK_VALUATION",
"REIMPORT_DAYS",
"SOURCE_ADMIN",
"Summary",
Expand Down
11 changes: 9 additions & 2 deletions krater/web/help_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Guide:
slug: str
summary: str
audience: str # "members" or "admins"
#: Listed and served only to admins: the guides that name OSPool (docs/SPEC.md "OSPool grants").
admins_only: bool = False


#: The Help index, in the order shown.
Expand Down Expand Up @@ -56,8 +58,13 @@ class Guide:
"alerts.",
"admins",
),
Guide("ospool-grants", "Record a grant that runs on the OSPool, and report what the team used.", "admins"),
Guide("share-with-ospool", "Send OSPool the projects you choose, as a PDF.", "admins"),
Guide(
"ospool-grants",
"Record a grant that runs on the OSPool, and report what the team used.",
"admins",
admins_only=True,
),
Guide("share-with-ospool", "Send OSPool the projects you choose, as a PDF.", "admins", admins_only=True),
Guide(
"compute-runbook",
"The stop switch, and what to do about each compute alert: spend, unknown charges, credit, storage.",
Expand Down
23 changes: 17 additions & 6 deletions krater/web/routers/help_pages.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
"""Krater's Help pages (`/help`): the guides in docs/guides, rendered. Public, so a member can read them before
signing in or applying."""
signing in or applying. A guide marked `admins_only` is listed and served only to an admin (others get 404)."""

from __future__ import annotations

from fastapi import APIRouter, HTTPException, Request, status
from typing import Annotated

from fastapi import APIRouter, Depends, HTTPException, Request, status
from fastapi.responses import HTMLResponse

from krater.models import User
from krater.services import users as user_service
from krater.web import help_docs
from krater.web.deps import current_user
from krater.web.templates import templates

router = APIRouter()


def _is_admin(user: User | None) -> bool:
# Display only (cached roles), like the top bar: these pages change nothing.
return user is not None and user_service.cached_actor(user).is_admin


@router.get("/help", response_class=HTMLResponse)
def help_index(request: Request) -> HTMLResponse:
guides = help_docs.index()
def help_index(request: Request, user: Annotated[User | None, Depends(current_user)]) -> HTMLResponse:
is_admin = _is_admin(user)
guides = [g for g in help_docs.index() if is_admin or not g.guide.admins_only]
return templates.TemplateResponse(
request,
"help/index.html",
Expand All @@ -26,8 +37,8 @@ def help_index(request: Request) -> HTMLResponse:


@router.get("/help/{slug}", response_class=HTMLResponse)
def help_guide(request: Request, slug: str) -> HTMLResponse:
def help_guide(request: Request, slug: str, user: Annotated[User | None, Depends(current_user)]) -> HTMLResponse:
rendered = help_docs.render(slug)
if rendered is None:
if rendered is None or (rendered.guide.admins_only and not _is_admin(user)):
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not found")
return templates.TemplateResponse(request, "help/guide.html", {"rendered": rendered})
6 changes: 3 additions & 3 deletions krater/web/routers/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1330,10 +1330,10 @@ def admin_record_ospool_grant(
def _notify() -> None:
slack_post_admin_override.defer(
project_id=str(project.id),
action=ospool_grants.AUDIT_RECORD,
action=ospool_grants.SLACK_RECORD,
actor_sub=actor.user.weave_sub,
reason=reason,
extra=f"OSPool project {name}, usage from {since}, valued at {rate_line}.",
extra=f"Partner grant under the project name {name}, usage from {since}, valued at {rate_line}.",
)

message = f"OSPool grant recorded. Usage under {name} shows here after the next daily import."
Expand Down Expand Up @@ -1389,7 +1389,7 @@ def admin_ospool_valuation(
def _notify() -> None:
slack_post_admin_override.defer(
project_id=str(project.id),
action=ospool_grants.AUDIT_VALUATION,
action=ospool_grants.SLACK_VALUATION,
actor_sub=actor.user.weave_sub,
reason=reason,
extra=f"Usage from now on valued at {rate_line}.",
Expand Down
6 changes: 3 additions & 3 deletions krater/web/templates/_macros.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{# `hold`: what an approved project waits on (`funding_holds.approval_label`), shown after its status. #}
{% macro status_badge(status, hold=none) %}
{%- if hold == "OSPool" -%}
{#- Funded by an OSPool grant (`funding_holds.OSPOOL`): not a hold, so the status's own colour. -#}
<span class="badge badge--{{ status.value }}">{{ status.value.replace('_', ' ') | capitalize }} · OSPool</span>
{%- if hold == "Partner grant" -%}
{#- Funded by a partner (an OSPool grant, `funding_holds.OSPOOL`; not named outside admin pages): not a hold, so the status's own colour. -#}
<span class="badge badge--{{ status.value }}">{{ status.value.replace('_', ' ') | capitalize }} · Partner grant</span>
{%- elif hold -%}
<span class="badge badge--funding-hold">{{ status.value.replace('_', ' ') | capitalize }} · {{ hold | lower }}</span>
{%- else -%}
Expand Down
2 changes: 1 addition & 1 deletion krater/web/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h2 id="ospool-grants">OSPool grants</h2>
<tbody>
{% for grant, totals in ospool %}
<tr>
<td class="cell-title"><a href="/projects/{{ grant.project.id }}#ospool">{{ grant.project.title or "Untitled proposal" }}</a></td>
<td class="cell-title"><a href="/projects/{{ grant.project.id }}#partner-grant">{{ grant.project.title or "Untitled proposal" }}</a></td>
<td><code>{{ grant.ospool_project_name }}</code></td>
<td class="num">{{ "{:,.1f}".format(totals.gpu_hours) }}</td>
<td class="num">{{ "{:,.1f}".format(totals.core_hours) }}</td>
Expand Down
14 changes: 8 additions & 6 deletions krater/web/templates/projects/_ospool.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{# The project's OSPool grant (`krater.services.ospool_grants`): usage from OSG's accounting, valued at rent prices. #}
{# The project's OSPool grant (`krater.services.ospool_grants`): usage from OSG's accounting, valued at rent prices.
The team sees this card, so it says "partner" and never names OSPool or OSG (docs/SPEC.md "OSPool grants"). #}
{% set totals = ospool_summary %}
<section class="card" id="ospool">
<h2>OSPool grant</h2>
<section class="card" id="partner-grant">
<h2>Partner grant</h2>
<p>
The OSPool funds this project outside Krater. The team runs on the OSPool with its own OSG accounts, under the
OSPool project <code>{{ ospool_grant.ospool_project_name }}</code>. Krater only reports the usage.
A partner funds this project's compute outside Krater's budget. The team runs on the partner's machines with
its own accounts there, under the project name <code>{{ ospool_grant.ospool_project_name }}</code>. Krater only
reports the usage.
</p>
<dl class="stats">
<div class="stat stat--accent"><dt>GPU-hours</dt><dd>{{ "{:,.1f}".format(totals.gpu_hours) }}</dd></div>
Expand All @@ -19,7 +21,7 @@ <h2>OSPool grant</h2>
{{ "have" if totals.unvalued_days != 1 else "has" }} no price yet, so {{ "they're" if totals.unvalued_days != 1 else "it's" }} left out.{% endif %}
</p>
<p class="muted">
From OSG's public accounting, which runs about a day behind and corrects recent days.
From the partner's accounting, which runs about a day behind and corrects recent days.
{% if ospool_grant.last_imported_at %}Last read {{ ospool_grant.last_imported_at.strftime("%Y-%m-%d %H:%M") }} UTC.{% else %}Not read yet: the first daily import fills this in.{% endif %}
</p>
{% if ospool_grant.last_import_error and is_admin %}
Expand Down
8 changes: 4 additions & 4 deletions krater/web/templates/projects/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ <h1>{{ project.title or "Untitled proposal" }} {{ macros.status_badge(project.st

{% if show_residency %}
{% if team_residency is none %}
<p class="residency-line">OSPool: Krater couldn't reach Weave to check the team's US residency.</p>
<p class="residency-line">Krater couldn't reach Weave to check the team's US residency.</p>
{% elif team_residency.all_residents %}
<p class="residency-line"><span class="badge badge--good">US residents</span> Every team member is a verified
US resident in Weave, so this project can be sent to OSPool.</p>
US resident in Weave.</p>
{% else %}
<div class="residency-line">
<p><span class="badge badge--info">Not OSPool-ready</span> OSPool is open only to US residents. These team
members are not verified US residents in Weave:</p>
<p><span class="badge badge--info">Not all US residents</span> These team members are not verified US
residents in Weave:</p>
<ul>
{% for member in team_residency.others %}
<li>{{ member.label }}: {{ member.reason }}</li>
Expand Down
Loading
Loading