parsimony-boc 0.0.1__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.
- parsimony_boc-0.0.1/.gitignore +40 -0
- parsimony_boc-0.0.1/CHANGELOG.md +57 -0
- parsimony_boc-0.0.1/LICENSE +190 -0
- parsimony_boc-0.0.1/PKG-INFO +137 -0
- parsimony_boc-0.0.1/README.md +103 -0
- parsimony_boc-0.0.1/parsimony_boc/__init__.py +32 -0
- parsimony_boc-0.0.1/parsimony_boc/_http.py +91 -0
- parsimony_boc-0.0.1/parsimony_boc/catalog_build.py +24 -0
- parsimony_boc-0.0.1/parsimony_boc/connectors/__init__.py +25 -0
- parsimony_boc-0.0.1/parsimony_boc/connectors/enumerate.py +220 -0
- parsimony_boc-0.0.1/parsimony_boc/connectors/fetch.py +119 -0
- parsimony_boc-0.0.1/parsimony_boc/outputs.py +54 -0
- parsimony_boc-0.0.1/parsimony_boc/py.typed +0 -0
- parsimony_boc-0.0.1/parsimony_boc/search.py +35 -0
- parsimony_boc-0.0.1/pyproject.toml +79 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*$py.class
|
|
4
|
+
*.so
|
|
5
|
+
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
|
|
12
|
+
.venv/
|
|
13
|
+
.env
|
|
14
|
+
.env.*
|
|
15
|
+
!.env.example
|
|
16
|
+
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
.mypy_cache/
|
|
19
|
+
.ruff_cache/
|
|
20
|
+
.coverage
|
|
21
|
+
htmlcov/
|
|
22
|
+
coverage.xml
|
|
23
|
+
|
|
24
|
+
uv.lock
|
|
25
|
+
|
|
26
|
+
.vscode/
|
|
27
|
+
.council/
|
|
28
|
+
PLAN-*.md
|
|
29
|
+
.idea/
|
|
30
|
+
*.swp
|
|
31
|
+
.DS_Store
|
|
32
|
+
|
|
33
|
+
outputs/
|
|
34
|
+
logs/
|
|
35
|
+
# Recorded HTTP cassettes must never be committed — respx mocks are hand-authored
|
|
36
|
+
# from upstream API documentation. A pre-commit / CI regex scan is the belt; this
|
|
37
|
+
# ignore is the braces. Override per-file via `!` if you need a hand-authored
|
|
38
|
+
# fixture checked in.
|
|
39
|
+
packages/*/tests/fixtures/**
|
|
40
|
+
!packages/*/tests/fixtures/README.md
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog — parsimony-boc
|
|
2
|
+
|
|
3
|
+
All notable changes to `parsimony-boc` will be documented in this file. The
|
|
4
|
+
format is based on [Keep a Changelog](https://keepachangelog.com/) and
|
|
5
|
+
this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.8.0] — 2026-06-09
|
|
8
|
+
|
|
9
|
+
Re-run through the full connector guidebook process and **live-verified** against
|
|
10
|
+
the production Valet API and bulk list endpoints.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Observations URL-length guard.** Valet 302-redirects any `/observations`
|
|
15
|
+
request whose URL exceeds ~4096 bytes (a limit on URL length, not series
|
|
16
|
+
count). `boc_fetch` now rejects oversized requests pre-network with an
|
|
17
|
+
actionable `InvalidParameterError` (split the names, or fetch a whole panel
|
|
18
|
+
with `group:NAME`) instead of an opaque redirect surfacing as a `ParseError`.
|
|
19
|
+
- **Retired-group pruning.** The per-group membership fan-out doubles as a
|
|
20
|
+
liveness probe: ~29 dated one-off panels that 404 on both `/groups/{name}` and
|
|
21
|
+
`/observations/group/{name}` are pruned from the catalog so it never offers an
|
|
22
|
+
unfetchable panel. A *transient* (5xx/network) failure keeps the group
|
|
23
|
+
best-effort — only a definitive 404 prunes.
|
|
24
|
+
- A `failed/total` enumeration summary log (series + live groups + pruned +
|
|
25
|
+
transient failures), `catalog_tests/queries.yaml` (recall gate), and
|
|
26
|
+
`tests/test_public_surface.py`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- **Package restructured** into `_http` / `outputs` / `connectors/{fetch,
|
|
31
|
+
enumerate,__init__}` / `search` / `catalog_build`; the monolithic
|
|
32
|
+
`__init__.py` is now a thin facade. No change to the connector surface
|
|
33
|
+
(`boc_fetch`, `enumerate_boc`, `boc_search`) or the catalog schema.
|
|
34
|
+
- Completeness re-verified live: `/lists/series/json` (15,638 series) is the
|
|
35
|
+
authoritative universe — a full fan-out over all 2,441 groups surfaces **0**
|
|
36
|
+
members absent from it; ~99.7% of listed series are fetchable (stale entries
|
|
37
|
+
return a clean `EmptyDataError`); every live group panel is fetchable.
|
|
38
|
+
|
|
39
|
+
## [0.5.0] — 2026-05-06
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- Adapted to `parsimony-core==0.5`. Connector code no longer constructs `Provenance` directly; the framework authors all provenance fields in `Connector._wrap_result`. Source-specific extras (where present) move to `Result.with_properties(**kwargs)`. Drops the `provenance=` and `params=` kwargs from `OutputConfig.build_table_result` / `Result.from_dataframe` call sites.
|
|
44
|
+
- Bump `parsimony-core` pin from `>=0.4.0,<0.5` to `>=0.5.0,<0.6` (and `[standard-onnx]` extra accordingly on catalog-publishing packages).
|
|
45
|
+
## [0.4.0] — 2026-04-24
|
|
46
|
+
|
|
47
|
+
Part of the first coordinated release of the
|
|
48
|
+
[`parsimony-connectors`](https://github.com/ockham-sh/parsimony-connectors)
|
|
49
|
+
monorepo under `parsimony-core==0.4`.
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
|
|
53
|
+
- Connector rewritten against the kernel's `parsimony.discover` surface
|
|
54
|
+
(`iter_providers`, `load`, `load_all`) and the `@connector(env=...)`
|
|
55
|
+
decorator-level env-var declaration that replaced module-level
|
|
56
|
+
`ENV_VARS`.
|
|
57
|
+
- Pin bumped to `parsimony-core>=0.4,<0.5`.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Ockham.sh
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: parsimony-boc
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Bank of Canada connector for the parsimony framework
|
|
5
|
+
Project-URL: Homepage, https://www.bankofcanada.ca
|
|
6
|
+
Project-URL: Repository, https://github.com/ockham-sh/parsimony-connectors
|
|
7
|
+
Project-URL: Issues, https://github.com/ockham-sh/parsimony-connectors/issues
|
|
8
|
+
Author-email: "Ockham.sh" <team@ockham.sh>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: boc,connectors,data,finance,parsimony
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: pandas<3,>=2.3.0
|
|
25
|
+
Requires-Dist: parsimony-core[catalog]>=0.0.1
|
|
26
|
+
Requires-Dist: pydantic<3,>=2.11.1
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=9.0.3; extra == 'dev'
|
|
31
|
+
Requires-Dist: respx>=0.22.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.15.10; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# parsimony-boc
|
|
36
|
+
|
|
37
|
+
Bank of Canada connector — Canadian exchange rates, interest/bond yields, money
|
|
38
|
+
& credit aggregates, CPI, commodity price indices, and the data behind BoC
|
|
39
|
+
publications, as numeric time series via the **Valet** API.
|
|
40
|
+
|
|
41
|
+
Part of the [parsimony-connectors](https://github.com/ockham-sh/parsimony-connectors) monorepo. Distributed standalone on PyPI as `parsimony-boc`.
|
|
42
|
+
|
|
43
|
+
## Connectors
|
|
44
|
+
|
|
45
|
+
| Name | Kind | Description |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `boc_fetch` | connector | Fetch one or more series by name (e.g. `FXUSDCAD,FXEURCAD`) or a whole panel by group (e.g. `group:FX_RATES_DAILY`). Reaches the **entire** universe by name. |
|
|
48
|
+
| `enumerate_boc` | enumerator | Catalog feed: one row per series (~15.6k) and one per live group (~2.4k), from Valet's list endpoints plus a per-group membership fan-out. |
|
|
49
|
+
| `boc_search` | connector | Search the published BoC catalog (lexical title or `code:`/structured). Pass returned codes to `boc_fetch(series_name=...)`. |
|
|
50
|
+
|
|
51
|
+
## Discovery model
|
|
52
|
+
|
|
53
|
+
The Valet API has **no native keyword search**, so discovery is a built catalog
|
|
54
|
+
(archetype A — one live full-index call lists the whole universe):
|
|
55
|
+
|
|
56
|
+
- `GET /lists/series/json` is the **authoritative enumeration path** (15,638
|
|
57
|
+
series, live 2026-06-09). It self-tracks BoC additions, so the catalog stays
|
|
58
|
+
current on each rebuild.
|
|
59
|
+
- **Groups are first-class catalog entities.** Each named panel (e.g.
|
|
60
|
+
`FX_RATES_DAILY`) gets its own row keyed `group:NAME` — the exact string
|
|
61
|
+
`boc_fetch` accepts — because group descriptions carry retrieval signal no
|
|
62
|
+
individual series has ("Month-end, Millions of dollars"). A fetch on a
|
|
63
|
+
`group:` code returns the whole panel in one request.
|
|
64
|
+
- The per-group membership fan-out doubles as a **liveness probe**: ~29 retired
|
|
65
|
+
one-off panels that 404 on every fetch path are pruned, so the catalog never
|
|
66
|
+
offers a panel you cannot fetch.
|
|
67
|
+
|
|
68
|
+
Every series stays fetchable by name regardless of catalog coverage — the
|
|
69
|
+
boundary is discovery, not access.
|
|
70
|
+
|
|
71
|
+
## Install
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install parsimony-boc
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Pulls in a compatible `parsimony-core` automatically. Verify discovery:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -c "from parsimony import discover; print([p.name for p in discover.iter_providers()])"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
No configuration required — the Valet API is open and unauthenticated.
|
|
86
|
+
|
|
87
|
+
`boc_search` reads published catalog snapshots (default root
|
|
88
|
+
`hf://parsimony-dev/boc`). Override with `PARSIMONY_BOC_CATALOG_URL` or
|
|
89
|
+
`catalog_url=` at call time; a missing snapshot is built on demand from the live
|
|
90
|
+
list endpoints and cached in an LRU.
|
|
91
|
+
|
|
92
|
+
> **Observations request limit.** Valet caps the `/observations` request URL near
|
|
93
|
+
> **4096 bytes** (roughly 100–160 comma-joined series, depending on name length).
|
|
94
|
+
> `boc_fetch` guards this pre-call and asks you to split the request or fetch a
|
|
95
|
+
> whole panel with `group:NAME`. The limit is on URL length, not series count.
|
|
96
|
+
|
|
97
|
+
## Quick start
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from parsimony_boc import CONNECTORS
|
|
101
|
+
|
|
102
|
+
# find a series (or a whole panel) in the catalog
|
|
103
|
+
hits = CONNECTORS["boc_search"](query="US dollar Canadian dollar exchange rate")
|
|
104
|
+
code = hits.data.iloc[0]["code"] # e.g. "FXUSDCAD" or "group:FX_RATES_DAILY"
|
|
105
|
+
# fetch observations
|
|
106
|
+
result = CONNECTORS["boc_fetch"](series_name=code, start_date="2024-01-01")
|
|
107
|
+
print(result.data.head())
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
For multi-plugin composition (autoloads everything installed):
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from parsimony import discover
|
|
114
|
+
connectors = discover.load_all()
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Catalog building
|
|
118
|
+
|
|
119
|
+
`scripts/build_catalog.py` builds the single `boc` catalog from the live list
|
|
120
|
+
endpoints and saves/pushes a snapshot:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv run python packages/boc/scripts/build_catalog.py \
|
|
124
|
+
--save file:///tmp/parsimony-catalogs/boc --push hf://parsimony-dev/boc
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Provider
|
|
128
|
+
|
|
129
|
+
- Homepage: https://www.bankofcanada.ca
|
|
130
|
+
- Valet API docs: https://www.bankofcanada.ca/valet/docs
|
|
131
|
+
- Terms: https://www.bankofcanada.ca/terms/ — free reuse **with attribution to
|
|
132
|
+
the Bank of Canada**. Data is © Bank of Canada; this connector and its catalog
|
|
133
|
+
are a derived index of series identifiers and titles.
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# parsimony-boc
|
|
2
|
+
|
|
3
|
+
Bank of Canada connector — Canadian exchange rates, interest/bond yields, money
|
|
4
|
+
& credit aggregates, CPI, commodity price indices, and the data behind BoC
|
|
5
|
+
publications, as numeric time series via the **Valet** API.
|
|
6
|
+
|
|
7
|
+
Part of the [parsimony-connectors](https://github.com/ockham-sh/parsimony-connectors) monorepo. Distributed standalone on PyPI as `parsimony-boc`.
|
|
8
|
+
|
|
9
|
+
## Connectors
|
|
10
|
+
|
|
11
|
+
| Name | Kind | Description |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| `boc_fetch` | connector | Fetch one or more series by name (e.g. `FXUSDCAD,FXEURCAD`) or a whole panel by group (e.g. `group:FX_RATES_DAILY`). Reaches the **entire** universe by name. |
|
|
14
|
+
| `enumerate_boc` | enumerator | Catalog feed: one row per series (~15.6k) and one per live group (~2.4k), from Valet's list endpoints plus a per-group membership fan-out. |
|
|
15
|
+
| `boc_search` | connector | Search the published BoC catalog (lexical title or `code:`/structured). Pass returned codes to `boc_fetch(series_name=...)`. |
|
|
16
|
+
|
|
17
|
+
## Discovery model
|
|
18
|
+
|
|
19
|
+
The Valet API has **no native keyword search**, so discovery is a built catalog
|
|
20
|
+
(archetype A — one live full-index call lists the whole universe):
|
|
21
|
+
|
|
22
|
+
- `GET /lists/series/json` is the **authoritative enumeration path** (15,638
|
|
23
|
+
series, live 2026-06-09). It self-tracks BoC additions, so the catalog stays
|
|
24
|
+
current on each rebuild.
|
|
25
|
+
- **Groups are first-class catalog entities.** Each named panel (e.g.
|
|
26
|
+
`FX_RATES_DAILY`) gets its own row keyed `group:NAME` — the exact string
|
|
27
|
+
`boc_fetch` accepts — because group descriptions carry retrieval signal no
|
|
28
|
+
individual series has ("Month-end, Millions of dollars"). A fetch on a
|
|
29
|
+
`group:` code returns the whole panel in one request.
|
|
30
|
+
- The per-group membership fan-out doubles as a **liveness probe**: ~29 retired
|
|
31
|
+
one-off panels that 404 on every fetch path are pruned, so the catalog never
|
|
32
|
+
offers a panel you cannot fetch.
|
|
33
|
+
|
|
34
|
+
Every series stays fetchable by name regardless of catalog coverage — the
|
|
35
|
+
boundary is discovery, not access.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install parsimony-boc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Pulls in a compatible `parsimony-core` automatically. Verify discovery:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -c "from parsimony import discover; print([p.name for p in discover.iter_providers()])"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
No configuration required — the Valet API is open and unauthenticated.
|
|
52
|
+
|
|
53
|
+
`boc_search` reads published catalog snapshots (default root
|
|
54
|
+
`hf://parsimony-dev/boc`). Override with `PARSIMONY_BOC_CATALOG_URL` or
|
|
55
|
+
`catalog_url=` at call time; a missing snapshot is built on demand from the live
|
|
56
|
+
list endpoints and cached in an LRU.
|
|
57
|
+
|
|
58
|
+
> **Observations request limit.** Valet caps the `/observations` request URL near
|
|
59
|
+
> **4096 bytes** (roughly 100–160 comma-joined series, depending on name length).
|
|
60
|
+
> `boc_fetch` guards this pre-call and asks you to split the request or fetch a
|
|
61
|
+
> whole panel with `group:NAME`. The limit is on URL length, not series count.
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from parsimony_boc import CONNECTORS
|
|
67
|
+
|
|
68
|
+
# find a series (or a whole panel) in the catalog
|
|
69
|
+
hits = CONNECTORS["boc_search"](query="US dollar Canadian dollar exchange rate")
|
|
70
|
+
code = hits.data.iloc[0]["code"] # e.g. "FXUSDCAD" or "group:FX_RATES_DAILY"
|
|
71
|
+
# fetch observations
|
|
72
|
+
result = CONNECTORS["boc_fetch"](series_name=code, start_date="2024-01-01")
|
|
73
|
+
print(result.data.head())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
For multi-plugin composition (autoloads everything installed):
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from parsimony import discover
|
|
80
|
+
connectors = discover.load_all()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Catalog building
|
|
84
|
+
|
|
85
|
+
`scripts/build_catalog.py` builds the single `boc` catalog from the live list
|
|
86
|
+
endpoints and saves/pushes a snapshot:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run python packages/boc/scripts/build_catalog.py \
|
|
90
|
+
--save file:///tmp/parsimony-catalogs/boc --push hf://parsimony-dev/boc
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Provider
|
|
94
|
+
|
|
95
|
+
- Homepage: https://www.bankofcanada.ca
|
|
96
|
+
- Valet API docs: https://www.bankofcanada.ca/valet/docs
|
|
97
|
+
- Terms: https://www.bankofcanada.ca/terms/ — free reuse **with attribution to
|
|
98
|
+
the Bank of Canada**. Data is © Bank of Canada; this connector and its catalog
|
|
99
|
+
are a derived index of series identifiers and titles.
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Bank of Canada (BoC) connector: fetch + catalog enumeration + search.
|
|
2
|
+
|
|
3
|
+
Valet API (``https://www.bankofcanada.ca/valet``) — keyless public JSON. Three
|
|
4
|
+
connectors, discovered as the top-level ``CONNECTORS`` bundle:
|
|
5
|
+
|
|
6
|
+
* ``boc_fetch`` — observations by series name(s) or ``group:NAME`` panel.
|
|
7
|
+
* ``enumerate_boc`` — the catalog feed (archetype A: live ``/lists/series``).
|
|
8
|
+
* ``boc_search`` — search over the published catalog snapshot.
|
|
9
|
+
|
|
10
|
+
This module is a thin facade; the implementation lives in ``_http`` / ``outputs``
|
|
11
|
+
/ ``connectors/{fetch,enumerate}`` / ``search`` / ``catalog_build``.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from parsimony_boc.connectors import CONNECTORS, load
|
|
17
|
+
from parsimony_boc.connectors.enumerate import enumerate_boc
|
|
18
|
+
from parsimony_boc.connectors.fetch import boc_fetch
|
|
19
|
+
from parsimony_boc.outputs import BOC_ENUMERATE_OUTPUT, BOC_FETCH_OUTPUT
|
|
20
|
+
from parsimony_boc.search import BOC_SEARCH_OUTPUT, PARSIMONY_BOC_CATALOG_URL_ENV, boc_search
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"BOC_ENUMERATE_OUTPUT",
|
|
24
|
+
"BOC_FETCH_OUTPUT",
|
|
25
|
+
"BOC_SEARCH_OUTPUT",
|
|
26
|
+
"CONNECTORS",
|
|
27
|
+
"PARSIMONY_BOC_CATALOG_URL_ENV",
|
|
28
|
+
"boc_fetch",
|
|
29
|
+
"boc_search",
|
|
30
|
+
"enumerate_boc",
|
|
31
|
+
"load",
|
|
32
|
+
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Bank of Canada (BoC) Valet transport: constants + the canonical client.
|
|
2
|
+
|
|
3
|
+
The Valet API is keyless JSON — there is no auth to resolve, so this module is
|
|
4
|
+
thin: a base URL, timeouts, the group-fan-out concurrency cap, and the one
|
|
5
|
+
non-obvious transport fact, the **observations request-URI limit**.
|
|
6
|
+
|
|
7
|
+
``boc_fetch`` and the list endpoints all speak GET + JSON, so they go through
|
|
8
|
+
the kernel's canonical ``make_http_client`` + ``fetch_json`` pair (GET +
|
|
9
|
+
``raise_for_status`` + ``map_http_error`` / ``map_timeout_error`` + ``json()`` +
|
|
10
|
+
``None``-param dropping). There is no provider-specific status semantics to
|
|
11
|
+
intercept, so there is no per-package mapper chokepoint here.
|
|
12
|
+
|
|
13
|
+
Endpoints (base ``https://www.bankofcanada.ca/valet``):
|
|
14
|
+
|
|
15
|
+
* ``GET /lists/series/json`` (~15.6k) and ``GET /lists/groups/json`` (~2.4k) —
|
|
16
|
+
the catalog index.
|
|
17
|
+
* ``GET /groups/{name}/json`` — per-group series membership (the fan-out); a
|
|
18
|
+
retired group returns 404.
|
|
19
|
+
* ``GET /observations/{names}/json`` and
|
|
20
|
+
``GET /observations/group/{name}/json`` — time-series observations.
|
|
21
|
+
|
|
22
|
+
**Observations request-URI cap (~4096 bytes).** Valet redirects (HTTP 302, to an
|
|
23
|
+
error page) any ``/observations`` request whose URL exceeds ~4 KB. The boundary
|
|
24
|
+
is on the *URL length*, not the series count: a full URL of 4087 bytes returns
|
|
25
|
+
200 while 4127 bytes 302s (measured live 2026-06-09). So a count cap is wrong
|
|
26
|
+
(140 short names pass, 140 long names 302). We guard the assembled URL
|
|
27
|
+
pre-network and raise a clear :class:`InvalidParameterError` instead of letting
|
|
28
|
+
the agent hit an opaque redirect that ``fetch_json`` would surface as a
|
|
29
|
+
``ParseError``.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
from __future__ import annotations
|
|
33
|
+
|
|
34
|
+
from parsimony.errors import InvalidParameterError
|
|
35
|
+
from parsimony.transport import HttpClient
|
|
36
|
+
from parsimony.transport.helpers import make_http_client
|
|
37
|
+
|
|
38
|
+
PROVIDER = "boc"
|
|
39
|
+
|
|
40
|
+
BASE_URL = "https://www.bankofcanada.ca/valet"
|
|
41
|
+
|
|
42
|
+
#: Per-call timeout for both the fetch and the (large) list endpoints. The
|
|
43
|
+
#: series index is ~3.5 MB, so allow a long read.
|
|
44
|
+
FETCH_TIMEOUT = 60.0
|
|
45
|
+
|
|
46
|
+
#: Concurrency cap for the per-group fan-out that builds the series→group map.
|
|
47
|
+
#: Valet is unauthenticated and tolerates moderate concurrency; 16 keeps the
|
|
48
|
+
#: ~2,400-group sweep at ~70 s while staying well under any sensible limit.
|
|
49
|
+
GROUP_FETCH_CONCURRENCY = 16
|
|
50
|
+
|
|
51
|
+
#: Maximum assembled-URL length (host + path, query excluded) we will send to
|
|
52
|
+
#: ``/observations``. The server caps the request URI at ~4096 bytes; we sit
|
|
53
|
+
#: conservatively below that so the date query string still fits under the cap.
|
|
54
|
+
OBSERVATIONS_MAX_URL_BYTES = 4000
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def make_valet_client(timeout: float = FETCH_TIMEOUT) -> HttpClient:
|
|
58
|
+
"""Build the canonical keyless Valet client (GET + JSON via ``fetch_json``)."""
|
|
59
|
+
return make_http_client(BASE_URL, timeout=timeout)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def guard_observations_path(path: str, *, series_name: str) -> None:
|
|
63
|
+
"""Reject an ``/observations`` path whose URL would exceed the server cap.
|
|
64
|
+
|
|
65
|
+
Valet 302-redirects any observations request URL over ~4 KB. Caught
|
|
66
|
+
pre-network, this becomes an actionable :class:`InvalidParameterError`
|
|
67
|
+
(split the request or fetch a whole panel with ``group:NAME``) instead of an
|
|
68
|
+
opaque redirect that downstream parsing would report as a ``ParseError``.
|
|
69
|
+
"""
|
|
70
|
+
url_len = len(BASE_URL) + 1 + len(path)
|
|
71
|
+
if url_len > OBSERVATIONS_MAX_URL_BYTES:
|
|
72
|
+
raise InvalidParameterError(
|
|
73
|
+
PROVIDER,
|
|
74
|
+
(
|
|
75
|
+
f"too many/long series names: the request URL is {url_len} bytes but the "
|
|
76
|
+
f"Bank of Canada observations endpoint caps it near {OBSERVATIONS_MAX_URL_BYTES + 96}. "
|
|
77
|
+
"Split the names across multiple boc_fetch calls, or fetch a whole panel in one "
|
|
78
|
+
"call with series_name='group:GROUP_NAME'."
|
|
79
|
+
),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
__all__ = [
|
|
84
|
+
"BASE_URL",
|
|
85
|
+
"FETCH_TIMEOUT",
|
|
86
|
+
"GROUP_FETCH_CONCURRENCY",
|
|
87
|
+
"OBSERVATIONS_MAX_URL_BYTES",
|
|
88
|
+
"PROVIDER",
|
|
89
|
+
"guard_observations_path",
|
|
90
|
+
"make_valet_client",
|
|
91
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Build the Bank of Canada catalog snapshot."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from parsimony.catalog import Catalog
|
|
6
|
+
from parsimony.catalog.policy import discovery_indexes
|
|
7
|
+
from parsimony.catalog.source import entities_from_raw
|
|
8
|
+
|
|
9
|
+
from parsimony_boc.connectors.enumerate import enumerate_boc
|
|
10
|
+
from parsimony_boc.outputs import BOC_ENUMERATE_OUTPUT
|
|
11
|
+
|
|
12
|
+
CATALOG_NAMESPACE = "boc"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def build_boc_catalog() -> Catalog:
|
|
16
|
+
result = enumerate_boc()
|
|
17
|
+
entries = entities_from_raw(result, BOC_ENUMERATE_OUTPUT)
|
|
18
|
+
catalog = Catalog(CATALOG_NAMESPACE, indexes=discovery_indexes(entries), default_field="title")
|
|
19
|
+
catalog.set_entities(entries)
|
|
20
|
+
catalog.build()
|
|
21
|
+
return catalog
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
__all__ = ["CATALOG_NAMESPACE", "build_boc_catalog"]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""boc connector registry."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from parsimony.connector import Connectors
|
|
6
|
+
|
|
7
|
+
from parsimony_boc.connectors.enumerate import enumerate_boc
|
|
8
|
+
from parsimony_boc.connectors.fetch import boc_fetch
|
|
9
|
+
from parsimony_boc.search import boc_search
|
|
10
|
+
|
|
11
|
+
CONNECTORS = Connectors([boc_fetch, enumerate_boc, boc_search])
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def load(*, catalog_url: str | None = None) -> Connectors:
|
|
15
|
+
"""Return :data:`CONNECTORS` with the optional search catalog URL bound.
|
|
16
|
+
|
|
17
|
+
BoC is keyless — there is no API key to bind. ``catalog_url`` lets an
|
|
18
|
+
operator point ``boc_search`` at a specific catalog snapshot.
|
|
19
|
+
"""
|
|
20
|
+
if catalog_url is None:
|
|
21
|
+
return CONNECTORS
|
|
22
|
+
return CONNECTORS.bind(catalog_url=catalog_url)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
__all__ = ["CONNECTORS", "load"]
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"""BoC catalog enumerator (archetype A: the live ``/lists/series`` full index).
|
|
2
|
+
|
|
3
|
+
Emits one row per series **and** one row per *live* group. The series index
|
|
4
|
+
(``/lists/series/json``, ~15.6k) is the authoritative universe — verified
|
|
5
|
+
complete: a full fan-out over every group surfaces zero members absent from it.
|
|
6
|
+
|
|
7
|
+
The per-group fan-out (``/groups/{name}/json`` × ~2.4k) does double duty:
|
|
8
|
+
|
|
9
|
+
1. **Membership** — annotates each series with its group (97.7% of series carry
|
|
10
|
+
a group; the first encountered wins for the rare multi-group series).
|
|
11
|
+
2. **Liveness** — a group whose detail endpoint 404s is *retired* (BoC leaves
|
|
12
|
+
~29 dated one-off panels in ``/lists/groups`` that 404 on both
|
|
13
|
+
``/groups/{name}`` and ``/observations/group/{name}``). We use the 404 signal
|
|
14
|
+
to **prune** those group rows so the catalog never offers a panel that cannot
|
|
15
|
+
be fetched. A *transient* failure (5xx / network) is kept best-effort — only
|
|
16
|
+
a definitive 404 prunes.
|
|
17
|
+
|
|
18
|
+
A ``failed/total`` summary is logged at the end so a quietly-shrunk crawl is
|
|
19
|
+
visible (guidebook §7.2).
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import logging
|
|
25
|
+
from typing import Any
|
|
26
|
+
|
|
27
|
+
import httpx
|
|
28
|
+
import pandas as pd
|
|
29
|
+
from parsimony.connector import enumerator
|
|
30
|
+
from parsimony.errors import ParseError
|
|
31
|
+
from parsimony.transport import HttpClient, pooled_client
|
|
32
|
+
from parsimony.transport.helpers import fetch_json
|
|
33
|
+
|
|
34
|
+
from parsimony_boc._http import PROVIDER, make_valet_client
|
|
35
|
+
from parsimony_boc.outputs import BOC_ENUMERATE_OUTPUT, ENUMERATE_COLUMNS
|
|
36
|
+
|
|
37
|
+
logger = logging.getLogger(__name__)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _list_groups(client: HttpClient) -> dict[str, dict[str, Any]]:
|
|
41
|
+
"""Return BoC's group index (~2.4k entries) from ``/lists/groups/json``.
|
|
42
|
+
|
|
43
|
+
This is the **bounding seam** for live tests: monkeypatch this module global
|
|
44
|
+
to a 2–3 group slice so the per-group fan-out fires a handful of requests,
|
|
45
|
+
never the full ~2,400-request crawl. ``enumerate_boc`` reads it as a module
|
|
46
|
+
global at call time so the monkeypatch takes.
|
|
47
|
+
"""
|
|
48
|
+
payload = fetch_json(client, path="lists/groups/json", provider=PROVIDER, op_name="groups/list")
|
|
49
|
+
if not isinstance(payload, dict):
|
|
50
|
+
raise ParseError(PROVIDER, "unexpected /lists/groups/json shape (expected object)")
|
|
51
|
+
groups = payload.get("groups") or {}
|
|
52
|
+
return groups if isinstance(groups, dict) else {}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _fetch_group_membership(
|
|
56
|
+
client: HttpClient,
|
|
57
|
+
group_name: str,
|
|
58
|
+
) -> tuple[str, list[str], bool]:
|
|
59
|
+
"""Fetch one group's membership. Returns ``(name, members, alive)``.
|
|
60
|
+
|
|
61
|
+
``alive`` is ``False`` **only** on a definitive 404 (a retired group): the
|
|
62
|
+
caller prunes those from the catalog. A transient transport error or a
|
|
63
|
+
200-with-non-JSON body keeps ``alive=True`` (best-effort) — the group is
|
|
64
|
+
still catalogued, it just loses its membership annotation this run, so a
|
|
65
|
+
network blip never silently shrinks the catalog.
|
|
66
|
+
"""
|
|
67
|
+
try:
|
|
68
|
+
resp = client.request("GET", f"/groups/{group_name}/json")
|
|
69
|
+
resp.raise_for_status()
|
|
70
|
+
body = resp.json()
|
|
71
|
+
except httpx.HTTPStatusError as exc:
|
|
72
|
+
if exc.response.status_code == 404:
|
|
73
|
+
# Retired-but-indexed group: prune it.
|
|
74
|
+
return group_name, [], False
|
|
75
|
+
logger.warning("BoC group fetch failed for %r: HTTP %s", group_name, exc.response.status_code)
|
|
76
|
+
return group_name, [], True
|
|
77
|
+
except (httpx.HTTPError, ValueError) as exc:
|
|
78
|
+
# Transport failure OR a 200-with-non-JSON body (BoC sometimes serves
|
|
79
|
+
# an HTML stub) — keep the group, drop only its membership this run.
|
|
80
|
+
logger.warning("BoC group fetch failed for %r: %s", group_name, exc)
|
|
81
|
+
return group_name, [], True
|
|
82
|
+
|
|
83
|
+
if not isinstance(body, dict):
|
|
84
|
+
return group_name, [], True
|
|
85
|
+
details = body.get("groupDetails") or {}
|
|
86
|
+
members = details.get("groupSeries") or {}
|
|
87
|
+
if not isinstance(members, dict):
|
|
88
|
+
return group_name, [], True
|
|
89
|
+
return group_name, [s for s in members if s], True
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _build_series_to_group_map(
|
|
93
|
+
client: HttpClient,
|
|
94
|
+
groups_index: dict[str, dict[str, Any]],
|
|
95
|
+
) -> tuple[dict[str, tuple[str, str]], set[str], int]:
|
|
96
|
+
"""Fan out over groups → ``(series_to_group, dead_groups, transient_failures)``.
|
|
97
|
+
|
|
98
|
+
``series_to_group`` maps each series to its first ``(group_id, group_label)``.
|
|
99
|
+
``dead_groups`` are the names that 404'd (retired) — the caller skips their
|
|
100
|
+
rows. ``transient_failures`` counts non-404 failures (kept, for the summary
|
|
101
|
+
log). Connections are pooled across the walk via :func:`pooled_client`.
|
|
102
|
+
"""
|
|
103
|
+
with pooled_client(client) as shared:
|
|
104
|
+
results = [_fetch_group_membership(shared, name) for name in groups_index]
|
|
105
|
+
|
|
106
|
+
series_to_group: dict[str, tuple[str, str]] = {}
|
|
107
|
+
dead_groups: set[str] = set()
|
|
108
|
+
transient_failures = 0
|
|
109
|
+
for group_name, members, alive in results:
|
|
110
|
+
if not alive:
|
|
111
|
+
dead_groups.add(group_name)
|
|
112
|
+
continue
|
|
113
|
+
if not members:
|
|
114
|
+
# alive but no members → either an empty/transient result. We can't
|
|
115
|
+
# distinguish a live-but-empty group from a transient miss here, but
|
|
116
|
+
# live groups always carry members in practice, so a non-404 empty is
|
|
117
|
+
# a transient failure for summary purposes.
|
|
118
|
+
transient_failures += 1
|
|
119
|
+
info = groups_index.get(group_name) or {}
|
|
120
|
+
label = (info.get("label") if isinstance(info, dict) else "") or ""
|
|
121
|
+
for series_name in members:
|
|
122
|
+
if series_name not in series_to_group:
|
|
123
|
+
series_to_group[series_name] = (group_name, label)
|
|
124
|
+
return series_to_group, dead_groups, transient_failures
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@enumerator(output=BOC_ENUMERATE_OUTPUT, tags=["macro", "ca"])
|
|
128
|
+
def enumerate_boc() -> pd.DataFrame:
|
|
129
|
+
"""Enumerate every Bank of Canada series and live group via Valet.
|
|
130
|
+
|
|
131
|
+
Granularity is one row per series — Valet addresses observations per series,
|
|
132
|
+
so series-level keys are the right unit (~15.6k rows) — plus one row per live
|
|
133
|
+
group (keyed ``group:NAME``) so whole panels are discoverable.
|
|
134
|
+
|
|
135
|
+
Pipeline: ``/lists/series/json`` and ``/lists/groups/json``, then a
|
|
136
|
+
serial ``/groups/{name}/json`` fan-out for series→group membership and
|
|
137
|
+
group liveness (retired groups that 404 are pruned).
|
|
138
|
+
"""
|
|
139
|
+
client = make_valet_client()
|
|
140
|
+
|
|
141
|
+
series_payload = fetch_json(client, path="lists/series/json", provider=PROVIDER, op_name="series/list")
|
|
142
|
+
if not isinstance(series_payload, dict):
|
|
143
|
+
raise ParseError(PROVIDER, "unexpected /lists/series/json shape (expected object)")
|
|
144
|
+
|
|
145
|
+
groups_index = _list_groups(client)
|
|
146
|
+
series_to_group, dead_groups, transient_failures = _build_series_to_group_map(client, groups_index)
|
|
147
|
+
|
|
148
|
+
series = series_payload.get("series") or {}
|
|
149
|
+
if not isinstance(series, dict):
|
|
150
|
+
series = {}
|
|
151
|
+
|
|
152
|
+
rows: list[dict[str, str]] = []
|
|
153
|
+
for series_name, info in series.items():
|
|
154
|
+
if not series_name:
|
|
155
|
+
continue
|
|
156
|
+
if isinstance(info, dict):
|
|
157
|
+
label = info.get("label") or series_name
|
|
158
|
+
desc = info.get("description") or ""
|
|
159
|
+
else:
|
|
160
|
+
label = str(info)
|
|
161
|
+
desc = ""
|
|
162
|
+
|
|
163
|
+
group_id, group_label = series_to_group.get(series_name, ("", ""))
|
|
164
|
+
rows.append(
|
|
165
|
+
{
|
|
166
|
+
"series_name": series_name,
|
|
167
|
+
"title": label,
|
|
168
|
+
"description": desc,
|
|
169
|
+
"source": "valet",
|
|
170
|
+
"entity_type": "series",
|
|
171
|
+
"group": group_id,
|
|
172
|
+
"group_label": group_label,
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
n_series = len(rows)
|
|
177
|
+
|
|
178
|
+
# One row per *live* group as a discoverable catalog entity. Groups are
|
|
179
|
+
# addressable via ``boc_fetch(series_name="group:NAME")``; cataloguing them
|
|
180
|
+
# lets agents search by the group-level description ("Month-end, Millions of
|
|
181
|
+
# dollars") and fetch a whole panel in one shot. Retired groups (404 on
|
|
182
|
+
# detail) are pruned so the catalog never offers an unfetchable panel.
|
|
183
|
+
n_groups = 0
|
|
184
|
+
for group_name, group_info in groups_index.items():
|
|
185
|
+
if not group_name or group_name in dead_groups:
|
|
186
|
+
continue
|
|
187
|
+
if isinstance(group_info, dict):
|
|
188
|
+
g_label = group_info.get("label") or group_name
|
|
189
|
+
g_desc = group_info.get("description") or ""
|
|
190
|
+
else:
|
|
191
|
+
g_label = str(group_info)
|
|
192
|
+
g_desc = ""
|
|
193
|
+
rows.append(
|
|
194
|
+
{
|
|
195
|
+
"series_name": f"group:{group_name}",
|
|
196
|
+
"title": g_label,
|
|
197
|
+
"description": g_desc,
|
|
198
|
+
"source": "valet",
|
|
199
|
+
"entity_type": "group",
|
|
200
|
+
"group": group_name,
|
|
201
|
+
"group_label": g_label,
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
n_groups += 1
|
|
205
|
+
|
|
206
|
+
logger.info(
|
|
207
|
+
"boc enumerate: %d series + %d live groups "
|
|
208
|
+
"(%d retired groups pruned, %d transient membership failures of %d groups)",
|
|
209
|
+
n_series,
|
|
210
|
+
n_groups,
|
|
211
|
+
len(dead_groups),
|
|
212
|
+
transient_failures,
|
|
213
|
+
len(groups_index),
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
columns = list(ENUMERATE_COLUMNS)
|
|
217
|
+
return pd.DataFrame(rows, columns=columns) if rows else pd.DataFrame(columns=columns)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
__all__ = ["enumerate_boc"]
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""BoC observations fetch connector (Valet ``/observations`` endpoint).
|
|
2
|
+
|
|
3
|
+
Fetches one or more series by name, or a whole named panel via ``group:NAME``.
|
|
4
|
+
The observations payload is a wide, date-keyed array — ``{"d": ..., "FXUSDCAD":
|
|
5
|
+
{"v": "1.38"}, ...}`` — which we melt into long ``(series_name, title, date,
|
|
6
|
+
value)`` rows. Suppressed/missing observations (``""`` / ``"NaN"`` / absent) come
|
|
7
|
+
back as a null ``value``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Annotated, Any
|
|
13
|
+
|
|
14
|
+
import pandas as pd
|
|
15
|
+
from parsimony import Namespace
|
|
16
|
+
from parsimony.connector import connector
|
|
17
|
+
from parsimony.errors import EmptyDataError, InvalidParameterError, ParseError
|
|
18
|
+
from parsimony.transport.helpers import fetch_json
|
|
19
|
+
|
|
20
|
+
from parsimony_boc._http import PROVIDER, guard_observations_path, make_valet_client
|
|
21
|
+
from parsimony_boc.outputs import BOC_FETCH_OUTPUT
|
|
22
|
+
|
|
23
|
+
_FETCH_COLUMNS = ["series_name", "title", "date", "value"]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _parse_observations(
|
|
27
|
+
json_data: dict[str, Any],
|
|
28
|
+
series_details: dict[str, Any] | None = None,
|
|
29
|
+
) -> pd.DataFrame:
|
|
30
|
+
"""Melt the Valet observations array into long-format rows.
|
|
31
|
+
|
|
32
|
+
Each observation entry looks like
|
|
33
|
+
``{"d": "2024-01-15", "FXUSDCAD": {"v": "1.3456"}, ...}`` — one date key
|
|
34
|
+
plus one nested ``{"v": ...}`` per series. Titles are resolved from the
|
|
35
|
+
payload's ``seriesDetail`` block when present, else fall back to the name.
|
|
36
|
+
"""
|
|
37
|
+
observations = json_data.get("observations", [])
|
|
38
|
+
if not observations:
|
|
39
|
+
return pd.DataFrame(columns=_FETCH_COLUMNS)
|
|
40
|
+
|
|
41
|
+
sample = observations[0]
|
|
42
|
+
series_cols = [k for k in sample if k != "d"]
|
|
43
|
+
|
|
44
|
+
rows: list[dict[str, Any]] = []
|
|
45
|
+
for obs in observations:
|
|
46
|
+
date = obs.get("d", "")
|
|
47
|
+
for col in series_cols:
|
|
48
|
+
raw = obs.get(col)
|
|
49
|
+
if raw is None:
|
|
50
|
+
continue
|
|
51
|
+
raw_value = raw.get("v") if isinstance(raw, dict) else raw
|
|
52
|
+
try:
|
|
53
|
+
value = float(raw_value) if raw_value is not None and raw_value not in ("", "NaN") else None
|
|
54
|
+
except (ValueError, TypeError):
|
|
55
|
+
value = None
|
|
56
|
+
|
|
57
|
+
title = col
|
|
58
|
+
if series_details and col in series_details:
|
|
59
|
+
detail = series_details[col]
|
|
60
|
+
title = detail.get("label", detail.get("description", col))
|
|
61
|
+
|
|
62
|
+
rows.append({"series_name": col, "title": title, "date": date, "value": value})
|
|
63
|
+
|
|
64
|
+
return pd.DataFrame(rows, columns=_FETCH_COLUMNS) if rows else pd.DataFrame(columns=_FETCH_COLUMNS)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@connector(output=BOC_FETCH_OUTPUT, tags=["macro", "ca"])
|
|
68
|
+
def boc_fetch(
|
|
69
|
+
series_name: Annotated[str, Namespace("boc")],
|
|
70
|
+
start_date: str | None = None,
|
|
71
|
+
end_date: str | None = None,
|
|
72
|
+
) -> pd.DataFrame:
|
|
73
|
+
"""Fetch Bank of Canada time series by series name(s) or group name.
|
|
74
|
+
|
|
75
|
+
Use 'group:GROUP_NAME' syntax for a whole panel (e.g. group:FX_RATES_DAILY).
|
|
76
|
+
Otherwise pass one or more comma-separated series names (e.g.
|
|
77
|
+
FXUSDCAD,FXEURCAD). Discover names with boc_search or enumerate_boc.
|
|
78
|
+
Observations come back as long-format (series_name, title, date, value)
|
|
79
|
+
rows; optional start_date/end_date (YYYY-MM-DD) bound the window.
|
|
80
|
+
"""
|
|
81
|
+
series_name = series_name.strip()
|
|
82
|
+
if not series_name:
|
|
83
|
+
raise InvalidParameterError(PROVIDER, "series_name must be non-empty")
|
|
84
|
+
|
|
85
|
+
if series_name.startswith("group:"):
|
|
86
|
+
group_name = series_name[6:].strip()
|
|
87
|
+
if not group_name:
|
|
88
|
+
raise InvalidParameterError(PROVIDER, "group name must be non-empty after 'group:'")
|
|
89
|
+
path = f"observations/group/{group_name}/json"
|
|
90
|
+
else:
|
|
91
|
+
path = f"observations/{series_name}/json"
|
|
92
|
+
|
|
93
|
+
# Valet 302-redirects observations requests whose URL exceeds ~4 KB; reject
|
|
94
|
+
# those pre-network with actionable guidance rather than a downstream parse
|
|
95
|
+
# failure. Only the multi-series path realistically trips this.
|
|
96
|
+
guard_observations_path(path, series_name=series_name)
|
|
97
|
+
|
|
98
|
+
json_data = fetch_json(
|
|
99
|
+
make_valet_client(),
|
|
100
|
+
path=path,
|
|
101
|
+
params={"start_date": start_date, "end_date": end_date},
|
|
102
|
+
provider=PROVIDER,
|
|
103
|
+
op_name="observations",
|
|
104
|
+
)
|
|
105
|
+
if not isinstance(json_data, dict):
|
|
106
|
+
raise ParseError(PROVIDER, f"unexpected observations response shape for: {series_name}")
|
|
107
|
+
|
|
108
|
+
df = _parse_observations(json_data, json_data.get("seriesDetail"))
|
|
109
|
+
if df.empty:
|
|
110
|
+
raise EmptyDataError(
|
|
111
|
+
PROVIDER,
|
|
112
|
+
message=f"No observations returned for: {series_name}",
|
|
113
|
+
query_params={"series_name": series_name, "start_date": start_date, "end_date": end_date},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
return df
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
__all__ = ["boc_fetch"]
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Output schemas for the Bank of Canada (BoC) connectors."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from parsimony.result import Column, ColumnRole, OutputConfig
|
|
6
|
+
|
|
7
|
+
BOC_FETCH_OUTPUT = OutputConfig(
|
|
8
|
+
columns=[
|
|
9
|
+
Column(name="series_name", role=ColumnRole.KEY, namespace="boc"),
|
|
10
|
+
Column(name="title", role=ColumnRole.TITLE),
|
|
11
|
+
Column(name="date", dtype="datetime", role=ColumnRole.DATA),
|
|
12
|
+
Column(name="value", dtype="numeric", role=ColumnRole.DATA),
|
|
13
|
+
]
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
BOC_ENUMERATE_OUTPUT = OutputConfig(
|
|
17
|
+
columns=[
|
|
18
|
+
# The KEY is either a series name (e.g. ``FXUSDCAD``) or a group entry
|
|
19
|
+
# prefixed with ``group:`` (e.g. ``group:FX_RATES_DAILY``). Groups are
|
|
20
|
+
# first-class addressable entities — ``boc_fetch`` accepts
|
|
21
|
+
# ``series_name="group:NAME"`` and Valet's
|
|
22
|
+
# ``/observations/group/{name}/json`` returns the full panel — so they
|
|
23
|
+
# get their own catalog rows for discovery alongside the per-series rows.
|
|
24
|
+
# The ``group:`` prefix is the exact string ``boc_fetch`` already
|
|
25
|
+
# expects, so a search hit routes straight to a fetch.
|
|
26
|
+
Column(name="series_name", role=ColumnRole.KEY, namespace="boc"),
|
|
27
|
+
Column(name="title", role=ColumnRole.TITLE),
|
|
28
|
+
# The upstream Valet ``description`` text. For group rows this carries
|
|
29
|
+
# the group's description (often the only place units/frequency live,
|
|
30
|
+
# e.g. "Month-end, Millions of dollars").
|
|
31
|
+
Column(name="description", role=ColumnRole.METADATA),
|
|
32
|
+
# ``source`` tells the agent which fetch connector to call. BoC has a
|
|
33
|
+
# single Valet source today; the column is future-proofing for a
|
|
34
|
+
# parallel source so dispatch is already wired (matches Treasury's
|
|
35
|
+
# ``fiscal_data``/``treasury_rates`` split).
|
|
36
|
+
Column(name="source", role=ColumnRole.METADATA),
|
|
37
|
+
# ``entity_type`` is ``"series"`` for individual series rows and
|
|
38
|
+
# ``"group"`` for group rows — lets agents filter or weight by
|
|
39
|
+
# entity granularity.
|
|
40
|
+
Column(name="entity_type", role=ColumnRole.METADATA),
|
|
41
|
+
# ``group`` carries the upstream group ID the series belongs to. A
|
|
42
|
+
# series can belong to several groups (rare); the first encountered
|
|
43
|
+
# group wins. Empty string when a series is in no catalogued group.
|
|
44
|
+
# For group rows this is the group's own ID.
|
|
45
|
+
Column(name="group", role=ColumnRole.METADATA),
|
|
46
|
+
Column(name="group_label", role=ColumnRole.METADATA),
|
|
47
|
+
]
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
#: The exact column order the ``@enumerator`` must return (enumerators drop
|
|
51
|
+
#: unmapped columns then require an exact match against the declared schema).
|
|
52
|
+
ENUMERATE_COLUMNS: tuple[str, ...] = tuple(c.name for c in BOC_ENUMERATE_OUTPUT.columns)
|
|
53
|
+
|
|
54
|
+
__all__ = ["BOC_ENUMERATE_OUTPUT", "BOC_FETCH_OUTPUT", "ENUMERATE_COLUMNS"]
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Semantic search over the published Bank of Canada (BoC) catalog."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from parsimony.catalog.search import CatalogSearchParams, make_local_search_connector
|
|
6
|
+
from parsimony.result import Column, ColumnRole, OutputConfig
|
|
7
|
+
|
|
8
|
+
from parsimony_boc.catalog_build import build_boc_catalog
|
|
9
|
+
|
|
10
|
+
PARSIMONY_BOC_CATALOG_URL_ENV = "PARSIMONY_BOC_CATALOG_URL"
|
|
11
|
+
|
|
12
|
+
BocSearchParams = CatalogSearchParams
|
|
13
|
+
|
|
14
|
+
BOC_SEARCH_OUTPUT = OutputConfig(
|
|
15
|
+
columns=[
|
|
16
|
+
Column(name="code", role=ColumnRole.KEY, namespace="boc"),
|
|
17
|
+
Column(name="title", role=ColumnRole.TITLE),
|
|
18
|
+
Column(name="score", role=ColumnRole.DATA),
|
|
19
|
+
]
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
boc_search = make_local_search_connector(
|
|
24
|
+
provider="boc",
|
|
25
|
+
default_url="hf://parsimony-dev/boc",
|
|
26
|
+
catalog_url_env_var=PARSIMONY_BOC_CATALOG_URL_ENV,
|
|
27
|
+
build_catalog=build_boc_catalog,
|
|
28
|
+
tags=["macro", "ca", "tool"],
|
|
29
|
+
description=(
|
|
30
|
+
"Search the Bank of Canada (BoC) Valet catalog. "
|
|
31
|
+
"Preferred: structured queries such as 'code: FXUSDCAD'. "
|
|
32
|
+
"Pass returned codes to boc_fetch(series_name=...)."
|
|
33
|
+
),
|
|
34
|
+
output_columns=BOC_SEARCH_OUTPUT.columns,
|
|
35
|
+
)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "parsimony-boc"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "Bank of Canada connector for the parsimony framework"
|
|
5
|
+
authors = [{ name = "Ockham.sh", email = "team@ockham.sh" }]
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
keywords = ["finance", "data", "connectors", "parsimony", "boc"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 4 - Beta",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Intended Audience :: Financial and Insurance Industry",
|
|
14
|
+
"License :: OSI Approved :: Apache Software License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Topic :: Office/Business :: Financial",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
21
|
+
"Typing :: Typed",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"parsimony-core[catalog]>=0.0.1",
|
|
25
|
+
"pydantic>=2.11.1,<3",
|
|
26
|
+
"pandas>=2.3.0,<3",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest>=9.0.3",
|
|
32
|
+
"pytest-cov>=5.0",
|
|
33
|
+
"respx>=0.22.0",
|
|
34
|
+
"ruff>=0.15.10",
|
|
35
|
+
"mypy>=1.10",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://www.bankofcanada.ca"
|
|
40
|
+
Repository = "https://github.com/ockham-sh/parsimony-connectors"
|
|
41
|
+
Issues = "https://github.com/ockham-sh/parsimony-connectors/issues"
|
|
42
|
+
|
|
43
|
+
[project.entry-points."parsimony.providers"]
|
|
44
|
+
boc = "parsimony_boc"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["hatchling"]
|
|
49
|
+
build-backend = "hatchling.build"
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.wheel]
|
|
52
|
+
packages = ["parsimony_boc"]
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build.targets.sdist]
|
|
55
|
+
include = ["parsimony_boc", "README.md", "LICENSE", "CHANGELOG.md"]
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
target-version = "py311"
|
|
59
|
+
line-length = 120
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint.per-file-ignores]
|
|
65
|
+
# Publish scripts call logging.basicConfig() before importing parsimony so
|
|
66
|
+
# the kernel's INFO logs surface during the long-running publish pipeline.
|
|
67
|
+
"scripts/*" = ["E402"]
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
python_version = "3.11"
|
|
71
|
+
warn_return_any = true
|
|
72
|
+
warn_unused_ignores = true
|
|
73
|
+
ignore_missing_imports = true
|
|
74
|
+
|
|
75
|
+
[tool.pytest.ini_options]
|
|
76
|
+
addopts = "--import-mode=importlib -m 'not integration'"
|
|
77
|
+
markers = [
|
|
78
|
+
"integration: hits live APIs (may be slow, requires env vars)",
|
|
79
|
+
]
|