ctfy.sdk.admin_resources.prewarm

client.admin.prewarm -- whether a competition's images are warm on the nodes that could host it, and the "warm now" button (#2129).

 1"""``client.admin.prewarm`` -- whether a competition's images are warm on the
 2nodes that could host it, and the "warm now" button (#2129)."""
 3
 4from __future__ import annotations
 5
 6from ctfy.sdk._helpers import _raise_for_status
 7from ctfy.sdk.base import BaseHttpClient
 8from ctfy.server.models import AdminTaskInfo, CompetitionPrewarm
 9
10
11class AdminPrewarmResource:
12    """Per node x challenge image readiness for one competition. For its
13    organisers (global admins and the event's own competition admins)."""
14
15    def __init__(self, http: BaseHttpClient) -> None:
16        self._http = http
17
18    def get(self, competition_id: str) -> CompetitionPrewarm:
19        """Readiness of every challenge on every eligible node, read off the
20        nodes themselves, plus where the pre-warm window stands."""
21        resp = self._http.request("GET", f"/admin/competitions/{competition_id}/prewarm")
22        _raise_for_status(resp)
23        return CompetitionPrewarm.model_validate(resp.json())
24
25    def run(self, competition_id: str) -> AdminTaskInfo:
26        """Submit the "warm this competition" task (#2089) and return its record.
27
28        Freezes any corpus challenge whose Layer 2 image the registry lacks,
29        then asks every node that would run the competition to pull it. The
30        outcome of each node x challenge is in the task's ``result.outcomes``
31        and log; the task is red if anything failed. Idempotent. Wraps
32        ``POST /admin/competitions/{id}/prewarm``.
33        """
34        resp = self._http.request("POST", f"/admin/competitions/{competition_id}/prewarm")
35        _raise_for_status(resp)
36        return AdminTaskInfo.model_validate(resp.json())
class AdminPrewarmResource:
12class AdminPrewarmResource:
13    """Per node x challenge image readiness for one competition. For its
14    organisers (global admins and the event's own competition admins)."""
15
16    def __init__(self, http: BaseHttpClient) -> None:
17        self._http = http
18
19    def get(self, competition_id: str) -> CompetitionPrewarm:
20        """Readiness of every challenge on every eligible node, read off the
21        nodes themselves, plus where the pre-warm window stands."""
22        resp = self._http.request("GET", f"/admin/competitions/{competition_id}/prewarm")
23        _raise_for_status(resp)
24        return CompetitionPrewarm.model_validate(resp.json())
25
26    def run(self, competition_id: str) -> AdminTaskInfo:
27        """Submit the "warm this competition" task (#2089) and return its record.
28
29        Freezes any corpus challenge whose Layer 2 image the registry lacks,
30        then asks every node that would run the competition to pull it. The
31        outcome of each node x challenge is in the task's ``result.outcomes``
32        and log; the task is red if anything failed. Idempotent. Wraps
33        ``POST /admin/competitions/{id}/prewarm``.
34        """
35        resp = self._http.request("POST", f"/admin/competitions/{competition_id}/prewarm")
36        _raise_for_status(resp)
37        return AdminTaskInfo.model_validate(resp.json())

Per node x challenge image readiness for one competition. For its organisers (global admins and the event's own competition admins).

AdminPrewarmResource(http: ctfy.sdk.base.BaseHttpClient)
16    def __init__(self, http: BaseHttpClient) -> None:
17        self._http = http
def get( self, competition_id: str) -> ctfy.server.models.CompetitionPrewarm:
19    def get(self, competition_id: str) -> CompetitionPrewarm:
20        """Readiness of every challenge on every eligible node, read off the
21        nodes themselves, plus where the pre-warm window stands."""
22        resp = self._http.request("GET", f"/admin/competitions/{competition_id}/prewarm")
23        _raise_for_status(resp)
24        return CompetitionPrewarm.model_validate(resp.json())

Readiness of every challenge on every eligible node, read off the nodes themselves, plus where the pre-warm window stands.

def run(self, competition_id: str) -> ctfy.server.models.AdminTaskInfo:
26    def run(self, competition_id: str) -> AdminTaskInfo:
27        """Submit the "warm this competition" task (#2089) and return its record.
28
29        Freezes any corpus challenge whose Layer 2 image the registry lacks,
30        then asks every node that would run the competition to pull it. The
31        outcome of each node x challenge is in the task's ``result.outcomes``
32        and log; the task is red if anything failed. Idempotent. Wraps
33        ``POST /admin/competitions/{id}/prewarm``.
34        """
35        resp = self._http.request("POST", f"/admin/competitions/{competition_id}/prewarm")
36        _raise_for_status(resp)
37        return AdminTaskInfo.model_validate(resp.json())

Submit the "warm this competition" task (#2089) and return its record.

Freezes any corpus challenge whose Layer 2 image the registry lacks, then asks every node that would run the competition to pull it. The outcome of each node x challenge is in the task's result.outcomes and log; the task is red if anything failed. Idempotent. Wraps POST /admin/competitions/{id}/prewarm.