mostlyright-data 0.31.45__tar.gz → 0.31.47__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/PKG-INFO +1 -1
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/SKILL.md +38 -13
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/2-brief-two-to-four-questions-each-with-a-recommended-answer.md +7 -2
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/enriching-with-small-models.md +66 -16
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/preparing-table-search.md +7 -2
- mostlyright_data-0.31.47/src/mostlyright/data_harness/__init__.py +113 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/skill_assets.py +16 -11
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/activity.py +52 -7
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/delivery.py +202 -67
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/download.py +45 -12
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/enrichment.py +222 -14
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe.py +12 -4
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe_explain.py +21 -6
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe_test.py +22 -4
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/refresh_rehearsal.py +11 -5
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/release_check.py +5 -1
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/router.py +380 -281
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/runs.py +9 -6
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/session.py +138 -17
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/transport.py +328 -24
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/user_agent.py +9 -7
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_artifacts.py +272 -75
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_query.py +3 -3
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_runs.py +4 -2
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_search.py +253 -8
- mostlyright_data-0.31.45/src/mostlyright/data_harness/__init__.py +0 -58
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/.gitignore +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/README.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/pyproject.toml +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/scripts/hatch_build.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/agents/openai.yaml +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/1-open-the-page-and-the-link-to-it-in-the-first-message.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/3-probe-read-a-source-before-committing-to-it.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/4-decide-say-what-you-chose-what-you-refused-and-ask-one-question.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/5-draft-one-recipe-document-one-call.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/6-build-one-run-sized-to-acquire-every-measured-source-whole.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/7-interrogate-ask-the-run-what-it-actually-delivered.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/8-fix-revise-the-document-and-register-it-again.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/9-present-only-what-survived-inspection-with-caveats.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/agent-protocol.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/autonomous-delivery.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/before-the-first-tool-call.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/boundaries.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/cloud-authentication-preflight.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/commands.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/live-run.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/making-a-table-incremental.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/narrating-the-run.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/not-hosted-yet.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/one-install.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/patterns.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/predicting-with-tabular-models.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/prediction-labels.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/promote.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/readers.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/receipts.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/recipe-test.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/recording-a-stream-venue.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/recovering-an-import-failure.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/reference-pages.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/required-protocol.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/satellite-signals.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/source-credentials.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/sources.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/the-one-thing-to-say-about-the-skill-itself.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/transforms.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/user-communication-contract.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/references/writing-a-decision-record.md +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/skills/mr-data-build/scripts/write_research_notebook.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/agent_protocol.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/canonical.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/key_seam.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/page_coverage.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/part_check_evidence.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/session_probes.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/table_manifest.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/__init__.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/backoff.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/categories.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/dataset-categories-v1.json +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/dataset_layout.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/description_shape.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/fast_features.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/matching_benchmark.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/probe.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/progress_rate.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/progress_vocabulary.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe_brief.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe_forecast.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/recipe_lint.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/research.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/run_diagnose.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/run_prefix.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/stream.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/stream_venue.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/studio_capabilities.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/support.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/table_search_contract.json +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/table_view.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_catalog.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_connected.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_connections.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_dataset_covers.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_datasets.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_handoff.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_matching.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_narrative.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_public.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_public_pull.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_reader.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_search_contract.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_secrets.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_stream.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/v4_tables.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/vocabulary.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/__init__.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/attendance.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/clarification.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/cloud_auth.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/commands/__init__.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/commands/auth.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/commands/clarify.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/commands/login.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/commands/whoami.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/credential_native.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/credential_store.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/credentials.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/login.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/path_kind.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/plain_file.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/remediation.py +0 -0
- {mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/ux/render.py +0 -0
|
@@ -5,14 +5,21 @@ description: Build, inspect, repair and verify datasets using the hosted Mostly
|
|
|
5
5
|
|
|
6
6
|
# Mostly Right Data Build
|
|
7
7
|
|
|
8
|
-
Build the dataset the
|
|
8
|
+
Build the best dataset for the person's goal, verify its contents, and report its actual coverage.
|
|
9
9
|
Use hosted commands with `--json` and returned identifiers. This core workflow governs the
|
|
10
10
|
references. Load the reference for the current stage only, not the entire library before starting.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
Act as the person's data scientist, not as an order taker. Most people know their goal and do
|
|
13
|
+
not know which dataset serves it. The request is the floor, never the ceiling. Work out the
|
|
14
|
+
goal, then design the table a data scientist would want for it. Add the sources that explain
|
|
15
|
+
or complete the requested one and join them. Derive what a rule can settle. Use the small
|
|
16
|
+
models (classify, extract, standardize, match) for the judgement no rule can make. Use a prediction where a
|
|
17
|
+
column is known for some rows and wanted for others. Where more data can be joined and then
|
|
18
|
+
classified, plan all of it. Do not wait for the person to name a source, a column or a model.
|
|
19
|
+
Recommend the fuller design in the brief, in the same question form, so it costs no extra turn.
|
|
20
|
+
This holds for a new build and for a request to extend a dataset. A repair, a refresh fix or a
|
|
21
|
+
question about existing data gets exactly what was asked.
|
|
22
|
+
Steps 3, 4, 5, 8 and 10 say where, and
|
|
16
23
|
[enriching with small models](references/enriching-with-small-models.md) says how.
|
|
17
24
|
|
|
18
25
|
For application access, API queries or polling for updates, use `mr-data public api-guide TABLE_ID`. It returns table-specific requests and key setup. Use environment variables for secrets.
|
|
@@ -138,9 +145,20 @@ step 6. The stage 3 reference holds its rule. Gate 4 is step 6.
|
|
|
138
145
|
[brief reference](references/2-brief-two-to-four-questions-each-with-a-recommended-answer.md).
|
|
139
146
|
In an unattended session use the established brief, record assumptions within its scope,
|
|
140
147
|
and do not wait for an absent person.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
148
|
+
Design for the goal before you ask. Infer the goal from the request and ask about it only
|
|
149
|
+
when two readings would change the table. Run `mr-data models --json` once. Then list what
|
|
150
|
+
the goal needs beyond the literal request: a second or third source to join, columns a rule
|
|
151
|
+
derives, a label or extracted field per row, a prediction. Put that design in the brief form
|
|
152
|
+
as one single-choice scope question. Its recommended option is the full design. The option's
|
|
153
|
+
description names the parts in the person's words, the biggest gain first, within the
|
|
154
|
+
form's length limit. Another option is the request exactly as written. Leave out any part
|
|
155
|
+
that would not serve the goal. When the design adds something to the request, the scope
|
|
156
|
+
question takes one of the form's slots. It can carry the purpose question. When nothing
|
|
157
|
+
would serve the goal better, skip the question and say so in one line. In a host without a question form, write the same choice
|
|
158
|
+
in the brief message. This is part of the one brief, never a second round. When the person
|
|
159
|
+
chooses the request as written, build exactly that. In an unattended session there is no
|
|
160
|
+
one to choose: add the rules, build the request, and record the rest as offers. See
|
|
161
|
+
[enriching](references/enriching-with-small-models.md#where-the-loop-runs). A
|
|
144
162
|
judgement the request already names, such as a label per row, is part of the build.
|
|
145
163
|
|
|
146
164
|
## Research, register, build
|
|
@@ -154,6 +172,11 @@ step 6. The stage 3 reference holds its rule. Gate 4 is step 6.
|
|
|
154
172
|
would summarise, pages or documents holding facts no column holds. Sort each by
|
|
155
173
|
[the ladder](references/enriching-with-small-models.md#the-ladder-a-rule-first-a-model-for-the-rest):
|
|
156
174
|
a rule first, a model for the rest.
|
|
175
|
+
Look also for what is missing from every source in the brief: a public table that shares a
|
|
176
|
+
key, a place or a time with these rows and would explain or complete them. Probe it like any
|
|
177
|
+
other source. A join the chosen design named goes into the first revision if it keeps
|
|
178
|
+
every requested row and the agreed grain. Say so in step 5. A join the person was never
|
|
179
|
+
shown, and any join when they chose the request as written, is an offer at delivery.
|
|
157
180
|
5. State the selected sources, joins, coverage and material limitations. Ask for a decision only
|
|
158
181
|
if existing authorization does not cover it. Read the
|
|
159
182
|
[recipe reference](references/5-draft-one-recipe-document-one-call.md) before authoring fields.
|
|
@@ -165,8 +188,9 @@ step 6. The stage 3 reference holds its rule. Gate 4 is step 6.
|
|
|
165
188
|
rules. If semantic search or JEV interpretation into filters/sorts is explicitly required,
|
|
166
189
|
do not register or queue a recipe that omits it; report the capability limit and wait.
|
|
167
190
|
Do not add search to existing recipes or rebuild existing datasets without an explicit request.
|
|
168
|
-
Put the deterministic derivations found in step 4 into the first revision
|
|
169
|
-
|
|
191
|
+
Put the deterministic derivations found in step 4 into the first revision, and the joins
|
|
192
|
+
step 4 allows. Add a classify,
|
|
193
|
+
extract, standardize or match source when the brief asked for that judgement or the person accepted the offer,
|
|
170
194
|
from the binding `mr-data models` lists, and let a rule settle every row it can before the
|
|
171
195
|
model reads the rest ([writing a classify source](references/enriching-with-small-models.md#writing-a-classify-source)).
|
|
172
196
|
Register a live predict table only after a backtest table has compared it with a baseline
|
|
@@ -393,8 +417,9 @@ chat, and pass on its answer.
|
|
|
393
417
|
the observed version as [search preparation](references/preparing-table-search.md) describes.
|
|
394
418
|
Search preparation runs independently: pending or failed indexing never means the data build
|
|
395
419
|
failed, and declared metadata alone never proves observed search quality. Before delivery,
|
|
396
|
-
run a battery of at least 40 queries the table's users would type
|
|
397
|
-
|
|
420
|
+
run a battery of at least 40 queries the table's users would type in one batched
|
|
421
|
+
`mr-data search explain TABLE_ID --version VERSION_ID --queries-file queries.txt --json`
|
|
422
|
+
call (or repeatable `--query` flags) and fix every miss in the recipe
|
|
398
423
|
([query battery](references/preparing-table-search.md#run-a-query-battery-before-you-deliver)).
|
|
399
424
|
Report rows and coverage actually verified, checks, limitations and the stable dataset link.
|
|
400
425
|
End with what would make the table better: the remaining enhancements, deterministic ones
|
|
@@ -409,7 +434,7 @@ chat, and pass on its answer.
|
|
|
409
434
|
| Reader coordinate and options | [Readers](references/readers.md) |
|
|
410
435
|
| Connector or collection | [Sources](references/sources.md) |
|
|
411
436
|
| One request per row of another source, such as a decision model scoring each row | [Per-row requests](references/sources.md#authoring-a-per-row-request) |
|
|
412
|
-
| Which small models this deployment serves, the rule-first ladder, and classify, extract and translate sources | [Enriching with small models](references/enriching-with-small-models.md) |
|
|
437
|
+
| Which small models this deployment serves, the rule-first ladder, and classify, extract, standardize, match and translate sources | [Enriching with small models](references/enriching-with-small-models.md) |
|
|
413
438
|
| Activity at named places from satellite images: parking, oil storage, construction, plant heat, ships, trucks, water | [Satellite signals](references/satellite-signals.md) |
|
|
414
439
|
| Predict a column from other columns | [Predicting with tabular models](references/predicting-with-tabular-models.md) |
|
|
415
440
|
| SQL and joins | [Transforms](references/transforms.md) |
|
|
@@ -6,14 +6,19 @@ questions (up to four), two to four distinct options per question and one recomm
|
|
|
6
6
|
each. Put the tradeoffs in the option descriptions. If field validation fails, correct the
|
|
7
7
|
fields and retry. The card itself asks the questions. Only hosts without a question form
|
|
8
8
|
use a concise text brief with the same choices and recommendations. If more decisions remain, ask the four that most affect the dataset, including unresolved update behavior.
|
|
9
|
-
|
|
9
|
+
Settle the rest with defaults stated in one short sentence. Ask a second form only for a choice that would make the dataset wrong if guessed. A question with no
|
|
10
10
|
recommendation makes the user do the work; a recommendation with no question decides for them.
|
|
11
11
|
|
|
12
12
|
Resolve the following before dependent work; combine related questions and omit decisions the
|
|
13
13
|
user already supplied. Always include update behavior when it remains unresolved:
|
|
14
14
|
|
|
15
15
|
- **Purpose.** What analysis, decision or downstream use should this support? It settles every
|
|
16
|
-
ambiguous definition below
|
|
16
|
+
ambiguous definition below. Infer it from the request, and ask when two readings would change
|
|
17
|
+
the table. The scope question can carry it.
|
|
18
|
+
- **Scope.** What would a data scientist add for that purpose? Name the sources worth joining,
|
|
19
|
+
the columns a rule derives, and the labels, extracted fields or prediction a model adds.
|
|
20
|
+
Ask one single-choice question. Recommend the full design and offer the request as written
|
|
21
|
+
beside it. Most people know the goal and not the dataset, so do not wait to be asked.
|
|
17
22
|
- **Grain.** What does one row represent — an event, a company, a station-hour, a country-year?
|
|
18
23
|
Resolve raw observations against aggregates, the time frequency, and the geographic detail.
|
|
19
24
|
- **Table shape.** Default to one joined, ML-ready table at the agreed observation or prediction
|
|
@@ -7,20 +7,20 @@ could be better while you probe, say what you found, and recommend what to add.
|
|
|
7
7
|
|
|
8
8
|
### What this deployment serves
|
|
9
9
|
|
|
10
|
-
Run `mr-data models --json` once per session, before the brief message. It lists
|
|
11
|
-
whether
|
|
12
|
-
`translate
|
|
13
|
-
|
|
14
|
-
refused, so do not offer it either.
|
|
10
|
+
Run `mr-data models --json` once per session, before the brief message. It lists each enrichment
|
|
11
|
+
task and whether it is served here, read from the server's platform credential listing.
|
|
12
|
+
`standardize` and `translate` appear only where their bindings are registered; where a binding is
|
|
13
|
+
absent or its `note` says this workspace has no allowance, do not offer it.
|
|
15
14
|
|
|
16
15
|
| Task | What it does | Binding |
|
|
17
16
|
| --- | --- | --- |
|
|
18
17
|
| classify | Labels each row from a text column with yes/no or choice questions: a topic, a category, a sentiment, a flag no keyword rule decides. Each answer carries a probability per label. | `gemini-decisions` (Mostly Right Classify: Gemini Decision 1) first; `classify` (Clef, self-hosted) and `openrouter-decisions` (TypeSafe's Jev) answer the same questions |
|
|
19
18
|
| extract | Pulls named fields (names, amounts, dates, places) out of page or document text into columns. Every value appears verbatim in the input or is dropped. | `extract` (the extraction model, NuExtract-based) |
|
|
20
|
-
| match |
|
|
19
|
+
| match | Verifies whether pairs of arbitrary records (companies, people, products, addresses, etc.) represent the same entity across tables or within one. | `match` (platform `/v1/match`; [writing a match source](#writing-a-match-source)) |
|
|
21
20
|
| observe | Measures activity at a place from satellite images, one series per place: parking, oil storage, construction, stored vehicles, plant heat, truck traffic, water area, ships, crop health, snow cover. | `sat` ([writing a sat source](#writing-a-sat-source)) |
|
|
22
21
|
| predict | Predicts a column for rows where it is unknown from rows where it is known: a number with a range, or a label with class probabilities. | `predict` (TabICLv2, self-hosted; [writing a predict source](#writing-a-predict-source)) |
|
|
23
|
-
| translate | Translates a text column into English, keeping the original beside it. Listed only where served. | `translate` (
|
|
22
|
+
| translate | Translates a text column into English, keeping the original beside it. Listed only where served. | `translate` (platform `/v1/translate` or legacy Gemini OpenAI-compatible route; [writing a translate source](#writing-a-translate-source)) |
|
|
23
|
+
| standardize | Cleans and standardizes messy entity names into `canonical_name`, deterministic ASCII `match_key`, and structured components (`legal_form`, `qualifier`, `dba`). Listed only where served. | `standardize` (platform `/v1/standardize`; [writing a standardize source](#writing-a-standardize-source)) |
|
|
24
24
|
|
|
25
25
|
Each served binding comes with its route, its pinned `model`, its rate, today's usage and quota,
|
|
26
26
|
and a `request_template`. The rest of this paragraph is for per-row requests; predict is
|
|
@@ -37,8 +37,8 @@ Keep `classify` and `openrouter-decisions` for recipes already written against t
|
|
|
37
37
|
Google's token rate, about 140 rows a second with one choice question per row and about 48 with forty
|
|
38
38
|
yes/no questions, so ask few questions per row (see below); a wider recipe is slowed by 429s.
|
|
39
39
|
|
|
40
|
-
Each binding also comes with a `pages_template`: `request_timeout_seconds` 120 and `
|
|
41
|
-
Write
|
|
40
|
+
Each binding also comes with a `pages_template`: `request_timeout_seconds` 120, `retries` 3, and `min_interval_milliseconds` 25.
|
|
41
|
+
Write them into the collection's `pages`. They exist for Clef and the extraction model and cost
|
|
42
42
|
nothing on `gemini-decisions`. Clef and the extraction model scale to zero when idle,
|
|
43
43
|
and their first instance takes three to five minutes to load. The server starts loading it when the
|
|
44
44
|
run is admitted, and until the service has answered once it spreads each member's attempts over
|
|
@@ -48,9 +48,9 @@ that still fails says `it never answered, likely a 3 to 5 minute cold start` in
|
|
|
48
48
|
`ROW_REQUEST_UNAVAILABLE` detail: tell the person the model was starting up and run it again, which keeps every saved
|
|
49
49
|
answer.
|
|
50
50
|
|
|
51
|
-
A task listed `not_served` or `planned` is offered as coming, never written into a recipe.
|
|
52
|
-
`match
|
|
53
|
-
key cannot settle is coming.
|
|
51
|
+
A task listed `not_served` or `planned` is offered as coming, never written into a recipe. When
|
|
52
|
+
`match` is listed `planned` or has no allowance, join on a normalized deterministic key now and
|
|
53
|
+
say that model matching for the rows the key cannot settle is coming.
|
|
54
54
|
|
|
55
55
|
### The ladder: a rule first, a model for the rest
|
|
56
56
|
|
|
@@ -74,7 +74,9 @@ judgement no rule can make. Both are improvements to offer.
|
|
|
74
74
|
- classify: what a row's text is about, whether it states something, its sentiment or intent,
|
|
75
75
|
which of the person's categories it belongs to.
|
|
76
76
|
- extract: facts stated in prose, a page or a document that no column holds.
|
|
77
|
-
-
|
|
77
|
+
- standardize, where listed: messy entity names cleaned into `canonical_name` and deterministic
|
|
78
|
+
ASCII `match_key` (plus `legal_form`, `qualifier`, `dba`).
|
|
79
|
+
- match, where served: two records that may represent the same entity across arbitrary schemas.
|
|
78
80
|
- translate, where listed: an English column beside text in another language.
|
|
79
81
|
|
|
80
82
|
**Both together.** When a rule settles most rows, settle those in the transform and let the
|
|
@@ -85,8 +87,12 @@ also keep the rows it settled from being sent at all: see [Needs server 4.14](#n
|
|
|
85
87
|
### Where the loop runs
|
|
86
88
|
|
|
87
89
|
1. **Brief (step 3).** Read what the table is for and which judgements the person named. Run
|
|
88
|
-
`mr-data models --json`.
|
|
89
|
-
|
|
90
|
+
`mr-data models --json`. Design the table the goal needs, not only the one the request
|
|
91
|
+
names: sources to join, derived columns, labels, extracted fields, a prediction. Put it in
|
|
92
|
+
the brief form as one single-choice scope question. Recommend the full design. Its
|
|
93
|
+
description names each part and what it adds, in the person's words. Offer the request as
|
|
94
|
+
written as the other option. Ask in the
|
|
95
|
+
same form as the rest of the brief, so the offer costs no extra turn. A judgement the
|
|
90
96
|
brief already asks for ("which reports mention fog", "tag each filing by sector") is part of
|
|
91
97
|
the build, not an offer.
|
|
92
98
|
2. **Probe (step 4).** Read the sampled rows column by column with the ladder: each free-text,
|
|
@@ -317,7 +323,8 @@ A translated quotation is a translation, not the speaker's words. Label it so wh
|
|
|
317
323
|
|
|
318
324
|
Name the model by what it does, not by its binding: "a small classification model reads each
|
|
319
325
|
report and labels the weather regime", "a small extraction model pulls the issuer and the amount
|
|
320
|
-
out of each filing"
|
|
326
|
+
out of each filing", "a small standardization model cleans company names into a canonical name
|
|
327
|
+
and match key", "a small matching model verifies ambiguous pairs across both tables". Say how many rows it would read, that it costs the person nothing, and what
|
|
321
328
|
the new columns would be called. Never say a model was used when the table has no source that
|
|
322
329
|
called it, and never present a model's label as fact: it is a label with a probability. A predicted value is a
|
|
323
330
|
prediction with its range, never a measurement.
|
|
@@ -339,3 +346,46 @@ and the transform settles which label wins.
|
|
|
339
346
|
- Where the per-row interval is served too, state `pages.revisit` as a long interval, up to a
|
|
340
347
|
year: the model is pinned and the question fixed, so an answer does not change and should be
|
|
341
348
|
carried forward ([a freshness bound](making-a-table-incremental.md#a-freshness-bound-on-per-row-answers)).
|
|
349
|
+
|
|
350
|
+
### Writing a standardize source
|
|
351
|
+
|
|
352
|
+
A standardize source is a [per-row request](sources.md#authoring-a-per-row-request) over the
|
|
353
|
+
distinct values of a messy entity name column (organizations, people, places, products). Copy the
|
|
354
|
+
listing's `request_template` and `pages_template`, rename `name_column` to the upstream column in
|
|
355
|
+
`parameters`, `body_template`, and `carry_columns` (keep `"id"` in `carry_columns` and
|
|
356
|
+
`max_chars: 512`), and set `entity_type` to `org`, `person`, `place`, `product`, `generic`, or
|
|
357
|
+
`auto`. Deduplicate upstream distinct names before calling the endpoint so repeated rows pay once.
|
|
358
|
+
Read top-level `status`, `canonical_name`, `match_key`, `entity_type`, `components/legal_form`,
|
|
359
|
+
`components/qualifier`, and `components/dba` directly from the JSON response, keeping the original
|
|
360
|
+
name beside `canonical_name` and `match_key`.
|
|
361
|
+
|
|
362
|
+
> Note on `/v1/translate`: when `list_models` serves `translate` on `/v1/translate`, use the
|
|
363
|
+
> served `{model, text, source_language, target_language}` body (never send legacy Gemini
|
|
364
|
+
> `messages`/`response_format`) and read top-level `status`, `source_language`, `target_language`,
|
|
365
|
+
> and `translated_text` directly.
|
|
366
|
+
|
|
367
|
+
### Writing a match source
|
|
368
|
+
|
|
369
|
+
A match source is a [per-row request](sources.md#authoring-a-per-row-request) that verifies
|
|
370
|
+
whether two arbitrary JSON records (`left` and `right`) represent the same real-world entity
|
|
371
|
+
across any schema (`company`, `person`, `product`, `address`, `vessel`, `invoice`, or `auto`).
|
|
372
|
+
Follow the ladder so you never pay for O(N^2) pairs:
|
|
373
|
+
|
|
374
|
+
1. Standardize messy name columns first with [a standardize source](#writing-a-standardize-source)
|
|
375
|
+
(or a SQL key) and auto-link exact `match_key` hits in SQL for free.
|
|
376
|
+
2. Block possible near-matches in SQL (shared prefix, domain, postal code, or trigram similarity)
|
|
377
|
+
in a supporting table (`table.version@1.0.0`, declaring the needed `"columns"` in `parquet.tabular@1.0.0` `reader.decode_options`) so only ambiguous pairs reach the model — a
|
|
378
|
+
`source_rows` per-row source reads an upstream `source`, never the same recipe's `transform`.
|
|
379
|
+
3. Copy the listing's `request_template` and `pages_template`, extend `parameters`, `left`, and
|
|
380
|
+
`right` inside `body_template` with any disambiguating columns (`domain`, `city`, `postal_code`,
|
|
381
|
+
`sku`, `email`) — set `"required": false` on optional sparse parameters so pairs with nulls in
|
|
382
|
+
an attribute are not skipped — set `record_type` (and optional `criteria`, up to 500 chars),
|
|
383
|
+
and list the upstream pair's key column(s) (e.g. `pair_id`, or `left_id` and `right_id`) in
|
|
384
|
+
`carry_columns`.
|
|
385
|
+
4. Read the scalar fields `match` (`yes` / `no` / `uncertain`), `confidence`
|
|
386
|
+
(`high` / `medium` / `low`), `score` (`0..1`), and `reason` directly with `json.tabular`.
|
|
387
|
+
Because `matched_fields` and `conflicting_fields` are JSON arrays, either omit them or use
|
|
388
|
+
`json.tabular@1.4.0` with `"non_scalar": "json"` on `/matched_fields` and `/conflicting_fields`
|
|
389
|
+
so admission does not reject array values. Auto-link `match = 'yes'` with `confidence = 'high'`
|
|
390
|
+
and flag `uncertain` rows for review. Skip `match` when its `note` says this workspace has no
|
|
391
|
+
match allowance.
|
|
@@ -353,6 +353,9 @@ the dashboard's explain, or through `search explain`:
|
|
|
353
353
|
|
|
354
354
|
```sh
|
|
355
355
|
mr-data search explain TABLE_ID --version VERSION_ID --query "stocks under 10" --json
|
|
356
|
+
# Or explain a whole query battery concurrently in one command (newline-delimited or JSON array):
|
|
357
|
+
mr-data search explain TABLE_ID --version VERSION_ID --queries-file queries.txt --json
|
|
358
|
+
mr-data search explain TABLE_ID --version VERSION_ID --query "stocks under 10" --query "top gainers" --json
|
|
356
359
|
```
|
|
357
360
|
|
|
358
361
|
Read `filters` and `order_by` to check the deterministic interpretation. To test an
|
|
@@ -384,8 +387,10 @@ you judge ranking. `try` runs on published tables only, against their live versi
|
|
|
384
387
|
### Run a query battery before you deliver
|
|
385
388
|
|
|
386
389
|
A few spot checks miss most gaps. Before you deliver a table with search, write a battery of at
|
|
387
|
-
least 40 queries that the people who use the table would type
|
|
388
|
-
|
|
390
|
+
least 40 queries that the people who use the table would type into a file (one query per line or
|
|
391
|
+
a JSON array of strings) and run all of them in a single batched `mr-data search explain TABLE_ID
|
|
392
|
+
--version VERSION_ID --queries-file queries.txt --json` call (avoid 40 separate CLI invocations).
|
|
393
|
+
Take the queries from the brief and the product, not from the column names.
|
|
389
394
|
Cover each kind:
|
|
390
395
|
|
|
391
396
|
| Kind | Examples |
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""The hosted ``mr-data`` client package, and the closed public surface it actually provides.
|
|
2
|
+
|
|
3
|
+
⚠ AN EXPORT IS A PROMISE THE INSTALLED WHEEL HAS TO KEEP. This module used to resolve fifty-eight
|
|
4
|
+
names through a ``__getattr__`` over a table of module coordinates, and the table outlived the
|
|
5
|
+
modules: the execution engine moved to Studio and every coordinate naming ``pipeline``, ``offline``,
|
|
6
|
+
``recipe``, ``contracts``, ``local_contracts``, ``studio_boundary`` or ``review`` became an import
|
|
7
|
+
that raises inside the shipped wheel. A dynamic coordinate is also invisible to the ownership
|
|
8
|
+
scanner, so nothing held the table to the tree. Both problems have the same fix: the exports are
|
|
9
|
+
plain imports of modules this distribution ships, so a missing one is an ImportError at build and
|
|
10
|
+
test time rather than an AttributeError in somebody else's program.
|
|
11
|
+
|
|
12
|
+
What is left is the canonical-JSON leaf, which the wire contracts share, and the version. Every
|
|
13
|
+
command surface is reached through :mod:`mostlyright.data_harness.thin`.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import os as _os
|
|
17
|
+
import sys as _sys
|
|
18
|
+
|
|
19
|
+
from mostlyright.data_harness.agent_protocol import (
|
|
20
|
+
PROTOCOL_SCHEMA,
|
|
21
|
+
RECOVERY_CATEGORIES,
|
|
22
|
+
normalize_reader_options,
|
|
23
|
+
recovery_from,
|
|
24
|
+
recovery_next_step,
|
|
25
|
+
)
|
|
26
|
+
from mostlyright.data_harness.canonical import (
|
|
27
|
+
CanonicalJSONError,
|
|
28
|
+
canonical_json_bytes,
|
|
29
|
+
canonical_sha256,
|
|
30
|
+
parse_canonical_json,
|
|
31
|
+
parse_json,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
_CACHED_VERSION: str | None = None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _fast_dist_version() -> str | None:
|
|
38
|
+
"""Read ``Version:`` directly from ``mostlyright_data-*.dist-info/METADATA`` without importing
|
|
39
|
+
``importlib.metadata`` (which loads ``email`` and ``zipfile`` on every CLI start)."""
|
|
40
|
+
|
|
41
|
+
matches: list[str] = []
|
|
42
|
+
seen_dirs: set[str] = set()
|
|
43
|
+
for entry in _sys.path:
|
|
44
|
+
if not entry or entry in seen_dirs:
|
|
45
|
+
continue
|
|
46
|
+
seen_dirs.add(entry)
|
|
47
|
+
try:
|
|
48
|
+
with _os.scandir(entry) as it:
|
|
49
|
+
for item in it:
|
|
50
|
+
name = item.name
|
|
51
|
+
if name.startswith("mostlyright_data-") and name.endswith(".dist-info"):
|
|
52
|
+
meta = _os.path.join(item.path, "METADATA")
|
|
53
|
+
if _os.path.isfile(meta):
|
|
54
|
+
matches.append(meta)
|
|
55
|
+
except OSError:
|
|
56
|
+
continue
|
|
57
|
+
if matches:
|
|
58
|
+
break
|
|
59
|
+
if len(matches) != 1:
|
|
60
|
+
return None
|
|
61
|
+
try:
|
|
62
|
+
with open(matches[0], encoding="utf-8") as fh:
|
|
63
|
+
for line in fh:
|
|
64
|
+
if line in ("\n", "\r\n", ""):
|
|
65
|
+
break
|
|
66
|
+
if line.startswith("Version:"):
|
|
67
|
+
value = line.partition(":")[2].strip()
|
|
68
|
+
return value or None
|
|
69
|
+
except OSError:
|
|
70
|
+
return None
|
|
71
|
+
return None
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def package_version() -> str:
|
|
75
|
+
"""Return the installed distribution version or an honest source-tree fallback."""
|
|
76
|
+
|
|
77
|
+
global _CACHED_VERSION
|
|
78
|
+
if _CACHED_VERSION is not None:
|
|
79
|
+
return _CACHED_VERSION
|
|
80
|
+
fast = _fast_dist_version()
|
|
81
|
+
if fast is not None:
|
|
82
|
+
_CACHED_VERSION = fast
|
|
83
|
+
return fast
|
|
84
|
+
from importlib import metadata as _metadata
|
|
85
|
+
|
|
86
|
+
try:
|
|
87
|
+
_CACHED_VERSION = _metadata.version("mostlyright-data")
|
|
88
|
+
except _metadata.PackageNotFoundError:
|
|
89
|
+
return "uninstalled"
|
|
90
|
+
return _CACHED_VERSION
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def __getattr__(name: str) -> str:
|
|
94
|
+
if name == "__version__":
|
|
95
|
+
value = package_version()
|
|
96
|
+
globals()["__version__"] = value
|
|
97
|
+
return value
|
|
98
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
99
|
+
|
|
100
|
+
__all__ = [
|
|
101
|
+
"PROTOCOL_SCHEMA",
|
|
102
|
+
"RECOVERY_CATEGORIES",
|
|
103
|
+
"CanonicalJSONError",
|
|
104
|
+
"__version__",
|
|
105
|
+
"canonical_json_bytes",
|
|
106
|
+
"canonical_sha256",
|
|
107
|
+
"normalize_reader_options",
|
|
108
|
+
"package_version",
|
|
109
|
+
"parse_canonical_json",
|
|
110
|
+
"parse_json",
|
|
111
|
+
"recovery_from",
|
|
112
|
+
"recovery_next_step",
|
|
113
|
+
]
|
{mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/skill_assets.py
RENAMED
|
@@ -39,10 +39,7 @@ tests keep reading it there, and the wheel carries the same bytes at
|
|
|
39
39
|
|
|
40
40
|
from __future__ import annotations
|
|
41
41
|
|
|
42
|
-
import hashlib
|
|
43
42
|
import os
|
|
44
|
-
import shutil
|
|
45
|
-
import tempfile
|
|
46
43
|
from pathlib import Path
|
|
47
44
|
|
|
48
45
|
__all__ = [
|
|
@@ -66,13 +63,14 @@ _AMBIENT_SUFFIXES = frozenset({".pyc", ".pyo"})
|
|
|
66
63
|
|
|
67
64
|
_STAMP_NAME = ".mr-data-skill.json"
|
|
68
65
|
_OPT_OUT = "MOSTLYRIGHT_SKILL_AUTOINSTALL"
|
|
66
|
+
_SANDBOX_ENV = "MOSTLYRIGHT_SANDBOX"
|
|
69
67
|
|
|
70
68
|
|
|
71
69
|
def packaged_skill_tree() -> Path | None:
|
|
72
70
|
"""The skill tree carried inside this wheel, or ``None`` in a source checkout."""
|
|
73
71
|
|
|
74
|
-
candidate =
|
|
75
|
-
return candidate if
|
|
72
|
+
candidate = os.path.join(os.path.dirname(os.path.abspath(__file__)), "skill_tree", SKILL_NAME)
|
|
73
|
+
return Path(candidate) if os.path.isdir(candidate) else None
|
|
76
74
|
|
|
77
75
|
|
|
78
76
|
def _target_root(target: str) -> Path:
|
|
@@ -119,6 +117,8 @@ def tree_digest(root: Path) -> str:
|
|
|
119
117
|
|
|
120
118
|
if not root.is_dir() or root.is_symlink():
|
|
121
119
|
raise ValueError(f"skill tree is not a plain directory: {root}")
|
|
120
|
+
import hashlib
|
|
121
|
+
|
|
122
122
|
accumulator = hashlib.sha256()
|
|
123
123
|
pending = [root]
|
|
124
124
|
entries: list[tuple[str, bytes]] = []
|
|
@@ -165,6 +165,8 @@ def _write_stamp(destination: Path, *, version: str, digest: str) -> None:
|
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
def _copy_tree(source: Path, destination: Path) -> None:
|
|
168
|
+
import shutil
|
|
169
|
+
|
|
168
170
|
shutil.copytree(
|
|
169
171
|
source,
|
|
170
172
|
destination,
|
|
@@ -182,6 +184,9 @@ def install_tree(source: Path, destination: Path, *, version: str) -> None:
|
|
|
182
184
|
and removed only once the new one is in place.
|
|
183
185
|
"""
|
|
184
186
|
|
|
187
|
+
import shutil
|
|
188
|
+
import tempfile
|
|
189
|
+
|
|
185
190
|
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
186
191
|
staging = Path(tempfile.mkdtemp(prefix=f".{SKILL_NAME}.", dir=destination.parent))
|
|
187
192
|
staged = staging / SKILL_NAME
|
|
@@ -197,12 +202,10 @@ def install_tree(source: Path, destination: Path, *, version: str) -> None:
|
|
|
197
202
|
|
|
198
203
|
|
|
199
204
|
def _package_version() -> str:
|
|
200
|
-
from
|
|
205
|
+
from mostlyright.data_harness import package_version
|
|
201
206
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
except PackageNotFoundError:
|
|
205
|
-
return "0"
|
|
207
|
+
running = package_version()
|
|
208
|
+
return "0" if running == "uninstalled" else running
|
|
206
209
|
|
|
207
210
|
|
|
208
211
|
def ensure_installed(target: str = "claude") -> str:
|
|
@@ -214,7 +217,9 @@ def ensure_installed(target: str = "claude") -> str:
|
|
|
214
217
|
command's, and this runs before all of them.
|
|
215
218
|
"""
|
|
216
219
|
|
|
217
|
-
if os.environ.get(_OPT_OUT, "").strip() in {"0", "false", "no"}:
|
|
220
|
+
if os.environ.get(_OPT_OUT, "").strip().lower() in {"0", "false", "no"}:
|
|
221
|
+
return "opted-out"
|
|
222
|
+
if os.environ.get(_SANDBOX_ENV, "").strip().lower() not in {"", "0", "false", "no"}:
|
|
218
223
|
return "opted-out"
|
|
219
224
|
source = packaged_skill_tree()
|
|
220
225
|
if source is None:
|
{mostlyright_data-0.31.45 → mostlyright_data-0.31.47}/src/mostlyright/data_harness/thin/activity.py
RENAMED
|
@@ -53,9 +53,9 @@ from mostlyright.data_harness.thin import THIN_SCHEMA_PREFIX
|
|
|
53
53
|
from mostlyright.data_harness.thin.session import StudioSessionProvider, dataset_dashboard_url
|
|
54
54
|
from mostlyright.data_harness.thin.transport import (
|
|
55
55
|
REQUEST_TIMEOUT_SECONDS,
|
|
56
|
+
ReusableHttpsTransport,
|
|
56
57
|
ThinLaneError,
|
|
57
58
|
Transport,
|
|
58
|
-
UrlLibTransport,
|
|
59
59
|
)
|
|
60
60
|
from mostlyright.data_harness.thin.v4 import (
|
|
61
61
|
COMMAND_REQUEST_VERSION_FLOOR,
|
|
@@ -987,23 +987,60 @@ def open_client(*, timeout: float = REQUEST_TIMEOUT_SECONDS) -> StudioV4Activity
|
|
|
987
987
|
|
|
988
988
|
global _COMMAND_TRANSPORT
|
|
989
989
|
if _COMMAND_TRANSPORT is None:
|
|
990
|
-
_COMMAND_TRANSPORT =
|
|
990
|
+
_COMMAND_TRANSPORT = ReusableHttpsTransport(timeout=timeout)
|
|
991
991
|
return _client_on(_COMMAND_TRANSPORT)
|
|
992
992
|
|
|
993
993
|
|
|
994
994
|
def _reporting_client(budget: _Budget) -> StudioV4ActivityClient:
|
|
995
995
|
"""The AUTOMATIC half's client, bounded by one deadline across every request it makes."""
|
|
996
996
|
|
|
997
|
-
|
|
997
|
+
transport = ReusableHttpsTransport(timeout=budget.remaining)
|
|
998
|
+
from mostlyright.data_harness.thin.session import cached_fresh_session
|
|
999
|
+
from mostlyright.data_harness.ux.credentials import resolve_cloud_credentials
|
|
1000
|
+
|
|
1001
|
+
if _SESSION is not None:
|
|
1002
|
+
fresh = _SESSION.fresh_or_none()
|
|
1003
|
+
if fresh is not None:
|
|
1004
|
+
return StudioV4ActivityClient(StudioSessionProvider(fresh), transport=transport)
|
|
1005
|
+
else:
|
|
1006
|
+
creds = resolve_cloud_credentials()
|
|
1007
|
+
fresh = cached_fresh_session(creds)
|
|
1008
|
+
if fresh is not None:
|
|
1009
|
+
return StudioV4ActivityClient(StudioSessionProvider(fresh), transport=transport)
|
|
1010
|
+
return _client_on(transport, budgeted=True)
|
|
998
1011
|
|
|
999
1012
|
|
|
1000
|
-
def _client_on(transport: Transport) -> StudioV4ActivityClient:
|
|
1013
|
+
def _client_on(transport: Transport, *, budgeted: bool = False) -> StudioV4ActivityClient:
|
|
1001
1014
|
global _SESSION
|
|
1002
|
-
from mostlyright.data_harness.thin.session import
|
|
1015
|
+
from mostlyright.data_harness.thin.session import (
|
|
1016
|
+
cached_fresh_session,
|
|
1017
|
+
open_renewable_session,
|
|
1018
|
+
)
|
|
1003
1019
|
from mostlyright.data_harness.ux.credentials import resolve_cloud_credentials
|
|
1004
1020
|
|
|
1005
1021
|
if _SESSION is None:
|
|
1006
|
-
|
|
1022
|
+
creds = resolve_cloud_credentials()
|
|
1023
|
+
fresh = cached_fresh_session(creds) if budgeted else None
|
|
1024
|
+
if fresh is not None:
|
|
1025
|
+
return StudioV4ActivityClient(StudioSessionProvider(fresh), transport=transport)
|
|
1026
|
+
_SESSION = open_renewable_session(
|
|
1027
|
+
creds,
|
|
1028
|
+
transport=transport,
|
|
1029
|
+
renewal_transport=None,
|
|
1030
|
+
_cache_result=True,
|
|
1031
|
+
)
|
|
1032
|
+
if budgeted:
|
|
1033
|
+
fresh = _SESSION.fresh_or_none()
|
|
1034
|
+
if fresh is not None:
|
|
1035
|
+
return StudioV4ActivityClient(StudioSessionProvider(fresh), transport=transport)
|
|
1036
|
+
# Re-exchange under the short activity budget rather than blocking on a 30s renewal.
|
|
1037
|
+
creds = resolve_cloud_credentials()
|
|
1038
|
+
_SESSION = open_renewable_session(
|
|
1039
|
+
creds,
|
|
1040
|
+
transport=transport,
|
|
1041
|
+
renewal_transport=None,
|
|
1042
|
+
_cache_result=True,
|
|
1043
|
+
)
|
|
1007
1044
|
return StudioV4ActivityClient(_SESSION, transport=transport)
|
|
1008
1045
|
|
|
1009
1046
|
|
|
@@ -1011,9 +1048,17 @@ def forget_session() -> None:
|
|
|
1011
1048
|
"""Drop the cached session, transport and document. For tests, and for nothing else."""
|
|
1012
1049
|
|
|
1013
1050
|
global _SESSION, _COMMAND_TRANSPORT
|
|
1051
|
+
from mostlyright.data_harness.thin.session import forget_cached_sessions
|
|
1052
|
+
|
|
1014
1053
|
_SESSION = None
|
|
1015
|
-
_COMMAND_TRANSPORT = None
|
|
1054
|
+
transport, _COMMAND_TRANSPORT = _COMMAND_TRANSPORT, None
|
|
1055
|
+
if transport is not None and hasattr(transport, "close"):
|
|
1056
|
+
try:
|
|
1057
|
+
transport.close()
|
|
1058
|
+
except Exception:
|
|
1059
|
+
pass
|
|
1016
1060
|
_DOCUMENTS.clear()
|
|
1061
|
+
forget_cached_sessions()
|
|
1017
1062
|
|
|
1018
1063
|
|
|
1019
1064
|
__all__ = [
|