Page 7 of 8~104 min topic

Python dictionaries

Set release boundaries for the model-run dictionary

Page 7 defines what the model-run record dictionary must refuse before release—security here is not a pasted happy path.

~13 min this pageSafety and operations

1Learn the idea

Read

Threats for this artifact only

Operational risks for the model-run record dictionary center on serializing secrets (API keys) into the run record JSON, plus the earlier failure mode (KeyError on missing version, or silent overwrite of accuracy with a string). Safety lives in executable gates, allowlists, redaction, and a named owner—not in a warning paragraph under an unsafe function.

Read

Run the release gate

SECRET_KEYS={'api_key','token','password'}
def public_record(run):
    return {k:v for k,v in run.items() if k not in SECRET_KEYS}
raw={'name':'ready-v1','accuracy':0.91,'ready':True,'owner':'ml-lab','api_key':'sk-live'}
print(public_record(raw))

Expected evidence: record without api_key. A failed assertion means stop, investigate, and do not publish the model-run dictionary.

Read

Owner, retention, rollback

Name who can disable the feature, what data is retained, and how to roll back to the last known good artifact. Pin the reviewed configuration (versions, thresholds, allowlists) so “what shipped” is reconstructable for python-dictionaries.

Read

Lab notebook: release blocker

Write the release blocker as a predicate, not a feeling: “Do not ship the model-run dictionary if serializing secrets (API keys) into the run record JSON.” Pair it with a passing control that shows the reviewed configuration still works for name='ready-v1', accuracy=0.91, ready=True, owner='ml-lab'. Name an owner and a rollback handle (git tag, docs_version, previous image).

Security pages must not paste the happy-path demo. If your gate code looks like the implementation page, replace it with a deny/allow check aimed at serializing secrets (API keys) into the run record JSON.

Read

Worked judgment

State the data retention rule in one line (what is stored, for how long, who can read it). Then state the kill switch (env flag, config pin, or feature owner). The model-run dictionary is not shippable without both, even when assert required keys; .get('version','unversioned') returns a string looks healthy.

Read

Why this stage matters for the model-run dictionary

At the safety and operations stage for python-dictionaries, the job is narrower than finishing a product demo. You are creating one progressive evidence piece about name='ready-v1', accuracy=0.91, ready=True, owner='ml-lab' that later pages inherit without redefining success. Keep that fixture small enough to inspect by hand, keep outputs copy-pasteable as text, and refuse to narrate this baseline as if it were a production SLA: a handwritten field list before coding the dict.

For this page specifically, success looks like an executable deny gate for the lab-specific threat while still centering the user decision to store one training run so later code can read named fields without positional guessing. If you cannot point to a file, command, or assertion that proves that for the model-run dictionary, stay on this page instead of advancing.

ML Python starter

Previous · Next

Go deeper

Before you start

Why this matters

Write an attack or unsafe misuse specific to this lab: serializing secrets (API keys) into the run record JSON. Predict whether your current code blocks it. Then run the gate below and compare.

In the wild

See how this idea shows up as a product and a company — then come back to the lesson. Skills transfer across vendors.

Check your understanding

Page assessment

Answer from memory. Completion is saved from this evidence, not from opening the next page.

1. Is there a concrete release blocker for: serializing secrets (API keys) into the run record JSON?
2. Are retention and rollback rules explicit?
3. Can the reviewed version be identified after release?
4. Did this page use a security-specific check—not the happy-path demo?

All responses are required.