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
16 changes: 13 additions & 3 deletions python/client-contract/CHANGELOG.md

Large diffs are not rendered by default.

55 changes: 32 additions & 23 deletions python/client-contract/README.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions python/client-contract/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source-include = [
"src/dfo_client_contract/served/*.json",
"src/dfo_client_contract/scenarios/*",
"src/dfo_client_contract/refs/*.json",
"src/dfo_client_contract/saved-files/*.json",
"src/dfo_client_contract/rules/*",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from and replay: the served OpenAPI document, the strict fields, the caller
action for each refusal code, the code of each error and warning a client
raises or issues itself, the website proxy's refusal codes,
the scenario and DatasetRef formats with their records, and the client rules
the scenario, DatasetRef and saved-file formats with their records, and the client rules
with their vectors. Every accessor reads the installed files through
`importlib.resources`.
"""
Expand All @@ -23,6 +23,8 @@
ref_examples,
rule,
rules_schema,
saved_file_examples,
saved_file_schema,
scenario_schema,
scenarios,
served_source,
Expand All @@ -46,6 +48,8 @@
"ref_examples",
"rule",
"rules_schema",
"saved_file_examples",
"saved_file_schema",
"scenario_schema",
"scenarios",
"served_source",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
"retryable": true,
"condition": "The call's deadline passed before it finished."
},
{
"code": "definition_spec_id_mismatch",
"class": "FormatError",
"retryable": false,
"condition": "A stored DatasetRef member's definition names a spec_id other than the member's spec."
},
{
"code": "digest_mismatch",
"class": "ServerError",
Expand All @@ -61,6 +67,18 @@
"retryable": true,
"condition": "The signed URL a files route names refused, or its fetch failed, after the route was asked once more."
},
{
"code": "format_invalid",
"class": "FormatError",
"retryable": false,
"condition": "Stored JSON for a DatasetRef, a saved dataset or a bundle breaks its format, or a bundle's descriptor lists a file outside the bundle."
},
{
"code": "hash_mismatch",
"class": "BundleError",
"retryable": false,
"condition": "A bundle's file hashes to another value than its descriptor gives."
},
{
"code": "header_invalid",
"class": "InvalidRequestError",
Expand All @@ -77,7 +95,7 @@
"code": "invalid_argument",
"class": "InvalidRequestError",
"retryable": false,
"condition": "A call's arguments break a rule the client checks before any request."
"condition": "A call's or client's arguments, or a setting's environment variable, break a rule the client checks before any request."
},
{
"code": "key_empty",
Expand All @@ -91,12 +109,42 @@
"retryable": false,
"condition": "The api_key holds a character outside visible ASCII."
},
{
"code": "match_unresolved",
"class": "InvalidRequestError",
"retryable": false,
"condition": "A lookup match whose status is not resolved is passed as an entity."
},
{
"code": "missing_file",
"class": "BundleError",
"retryable": false,
"condition": "A bundle lacks a file its descriptor lists."
},
{
"code": "network_error",
"class": "NetworkError",
"retryable": true,
"condition": "The connection failed before a response arrived."
},
{
"code": "no_data_resource",
"class": "BundleError",
"retryable": false,
"condition": "A bundle's descriptor names no data table."
},
{
"code": "no_descriptor",
"class": "BundleError",
"retryable": false,
"condition": "A bundle holds data with no datapackage.json."
},
{
"code": "not_a_bundle",
"class": "BundleError",
"retryable": false,
"condition": "A path holds neither a saved dataset nor part of a bundle, or a Parquet file or ZIP too damaged to read."
},
{
"code": "offline",
"class": "NetworkError",
Expand All @@ -115,12 +163,36 @@
"retryable": false,
"condition": "The chosen profile in the credentials file has no key."
},
{
"code": "proxy_invalid",
"class": "InvalidRequestError",
"retryable": false,
"condition": "A proxy URL read from the environment has a scheme other than http, https, socks5 or socks5h."
},
{
"code": "ref_unavailable",
"class": "InvalidRequestError",
"retryable": false,
"condition": "A dataset read from a bundle folder, which names no version, is asked for its ref."
},
{
"code": "refusal_without_code",
"class": "by_status",
"retryable": "by_status",
"condition": "A refusal whose body carries no code: no problem document, or one without a code."
},
{
"code": "repeated_spec_id",
"class": "FormatError",
"retryable": false,
"condition": "A stored DatasetRef holds one spec_id in two members."
},
{
"code": "resource_limit",
"class": "BundleError",
"retryable": false,
"condition": "A bundle passes a bound its reader sets on its descriptor, entries, resources, bytes or workbooks."
},
{
"code": "response_too_large",
"class": "ServerError",
Expand Down
15 changes: 15 additions & 0 deletions python/client-contract/src/dfo_client_contract/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"credentials-file",
"key-lookup",
"base-url",
"timeout-and-retries",
"cache-dir",
"cache-layout",
"reading-order",
Expand Down Expand Up @@ -121,6 +122,11 @@ def dataset_ref_schema() -> dict[str, Any]:
return _load("dataset-ref.schema.json")


def saved_file_schema() -> dict[str, Any]:
"""`saved-file.schema.json`: the `dfo.*` metadata of a saved Parquet file."""
return _load("saved-file.schema.json")


def rules_schema() -> dict[str, Any]:
"""`rules/rules.schema.json`: the shape of every rule file."""
return _load("rules/rules.schema.json")
Expand All @@ -144,6 +150,15 @@ def ref_examples() -> list[dict[str, Any]]:
return _records("refs")


def saved_file_examples() -> list[dict[str, Any]]:
"""Every saved-file metadata example, sorted by file name.

Raises:
RuntimeError: No example is installed.
"""
return _records("saved-files")


def rule(name: str) -> dict[str, Any]:
"""The vector file for rule `name`, one of `RULES`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,12 @@
"const": "frame"
},
"without_party_totals": {
"description": "Selects the artifact rendered with party totals left out. The key is absent for a plain rendering, so `false` is not a valid value.",
"description": "Selects the artifact rendered with party totals left out, the spelling every server rendering carries. The key is absent for a plain rendering, so `false` is not a valid value.",
"const": true
},
"party_totals": {
"description": "Selects the artifact rendered with party totals left out, the request spelling of the cut. A ref may carry it beside or in place of `without_party_totals`, in the same format version, and both say the same cut. The key is absent for a plain rendering, so `true` is not a valid value, and a pair that disagrees is not a ref.",
"const": false
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"format_version": 1,
"name": "ref-party-totals-both",
"description": "A ref whose rendering marks the cut with both spellings, party_totals false and without_party_totals true, which agree.",
"scenario": "fetch-spec-known-sentence",
"ref": {
"format_version": 1,
"members": [
{
"parts": [],
"sentence": "Germany's gross ODA disbursements to Nigeria for basic health care, 2020 to 2023. Current US dollars · OECD Creditor Reporting System (CRS).",
"spec": {
"spec_id": "spec_cb5baa4161de718f18583060674dbca6",
"definition": {
"schema_version": 1,
"spec_id": "spec_cb5baa4161de718f18583060674dbca6",
"identity": {
"identity_version": "spec1",
"shape": {
"kind": "statvar_schema",
"population_type": "FinancialFlow",
"measured_property": "amount",
"stat_type": "measuredValue",
"measurement_qualifier": "Nominal"
},
"slots": [
{
"property": "crsCooperationModality",
"binding": {
"state": "unbound"
}
},
{
"property": "crsPurpose",
"binding": {
"state": "value",
"ref": "CRSPurposeCode12220"
}
},
{
"property": "crsTypeOfFinance",
"binding": {
"state": "unbound"
}
},
{
"property": "crsTypeOfFlow",
"binding": {
"state": "value",
"ref": "CRSTypeOfFlow10"
}
},
{
"property": "financialFlowType",
"binding": {
"state": "value",
"ref": "Disbursement"
}
},
{
"property": "nettingBasis",
"binding": {
"state": "value",
"ref": "Gross"
}
}
],
"entities": {
"destination": [
"country/NGA"
],
"origin": [
"country/DEU"
]
},
"requested_window": {
"kind": "range",
"start_year": 2020,
"end_year": 2023
}
}
}
},
"content_version": "cv_bf242138f8d0a892c97da9373d1626f4",
"artifact": {
"digest": "sha256:c44200969f19d73104d1bc24ebca905e59f749c2939234cdde10ba6f5a131170",
"rendering": {
"format": "parquet",
"bundle": false,
"without_party_totals": true,
"party_totals": false
}
}
}
]
},
"expect": "accept"
}
Loading
Loading