myopenfund-open-data-store 0.1.0__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.
Files changed (50) hide show
  1. myopenfund_open_data_store-0.1.0/.github/dependabot.yml +6 -0
  2. myopenfund_open_data_store-0.1.0/.github/workflows/ci.yml +106 -0
  3. myopenfund_open_data_store-0.1.0/.github/workflows/release.yml +175 -0
  4. myopenfund_open_data_store-0.1.0/.gitignore +10 -0
  5. myopenfund_open_data_store-0.1.0/.mcp.json +11 -0
  6. myopenfund_open_data_store-0.1.0/LICENSE +21 -0
  7. myopenfund_open_data_store-0.1.0/PKG-INFO +177 -0
  8. myopenfund_open_data_store-0.1.0/README.md +135 -0
  9. myopenfund_open_data_store-0.1.0/deploy/nas/.env.example +21 -0
  10. myopenfund_open_data_store-0.1.0/deploy/nas/README.md +61 -0
  11. myopenfund_open_data_store-0.1.0/deploy/nas/compose.yaml +151 -0
  12. myopenfund_open_data_store-0.1.0/deploy/nas/push_landing.py +118 -0
  13. myopenfund_open_data_store-0.1.0/deploy/nas/roles.sql +24 -0
  14. myopenfund_open_data_store-0.1.0/docs/ARCHITECTURE.md +200 -0
  15. myopenfund_open_data_store-0.1.0/docs/MIGRATION.md +81 -0
  16. myopenfund_open_data_store-0.1.0/pyproject.toml +59 -0
  17. myopenfund_open_data_store-0.1.0/src/open_data_store/__init__.py +3 -0
  18. myopenfund_open_data_store-0.1.0/src/open_data_store/cli.py +63 -0
  19. myopenfund_open_data_store-0.1.0/src/open_data_store/config.py +90 -0
  20. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/__init__.py +4 -0
  21. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/base.py +89 -0
  22. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/registry.py +35 -0
  23. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/rules.py +225 -0
  24. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/__init__.py +10 -0
  25. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/_common.py +26 -0
  26. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/entity_observations.py +36 -0
  27. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/filing_statements.py +57 -0
  28. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/filings.py +58 -0
  29. myopenfund_open_data_store-0.1.0/src/open_data_store/contracts/standard/fundamentals.py +85 -0
  30. myopenfund_open_data_store-0.1.0/src/open_data_store/lake.py +104 -0
  31. myopenfund_open_data_store-0.1.0/src/open_data_store/publisher/__init__.py +8 -0
  32. myopenfund_open_data_store-0.1.0/src/open_data_store/publisher/entities.py +152 -0
  33. myopenfund_open_data_store-0.1.0/src/open_data_store/publisher/publish.py +604 -0
  34. myopenfund_open_data_store-0.1.0/src/open_data_store/reader/__init__.py +3 -0
  35. myopenfund_open_data_store-0.1.0/src/open_data_store/reader/api.py +393 -0
  36. myopenfund_open_data_store-0.1.0/src/open_data_store/writer/__init__.py +3 -0
  37. myopenfund_open_data_store-0.1.0/src/open_data_store/writer/batch.py +122 -0
  38. myopenfund_open_data_store-0.1.0/tests/conftest.py +135 -0
  39. myopenfund_open_data_store-0.1.0/tests/test_cli.py +50 -0
  40. myopenfund_open_data_store-0.1.0/tests/test_contracts.py +299 -0
  41. myopenfund_open_data_store-0.1.0/tests/test_deploy_roles.py +104 -0
  42. myopenfund_open_data_store-0.1.0/tests/test_identifiers.py +340 -0
  43. myopenfund_open_data_store-0.1.0/tests/test_no_old_name.py +44 -0
  44. myopenfund_open_data_store-0.1.0/tests/test_packaging.py +305 -0
  45. myopenfund_open_data_store-0.1.0/tests/test_postgres.py +33 -0
  46. myopenfund_open_data_store-0.1.0/tests/test_publisher.py +1400 -0
  47. myopenfund_open_data_store-0.1.0/tests/test_push_landing.py +141 -0
  48. myopenfund_open_data_store-0.1.0/tests/test_reader.py +505 -0
  49. myopenfund_open_data_store-0.1.0/tests/test_reader_pushdown.py +138 -0
  50. myopenfund_open_data_store-0.1.0/tests/test_writer.py +265 -0
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
@@ -0,0 +1,106 @@
1
+ name: ci
2
+ on:
3
+ push:
4
+ pull_request:
5
+ branches: [main]
6
+ jobs:
7
+ test:
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ matrix:
11
+ python: ["3.11", "3.12", "3.13"]
12
+ services:
13
+ postgres:
14
+ image: postgres:16
15
+ env:
16
+ POSTGRES_HOST_AUTH_METHOD: trust # throwaway CI container, no password needed
17
+ ports: ["5432:5432"]
18
+ options: >-
19
+ --health-cmd "pg_isready -U postgres" --health-interval 5s --health-timeout 5s --health-retries 10
20
+ env:
21
+ OPEN_DATA_STORE_TEST_PG: "host=localhost port=5432 user=postgres dbname=postgres"
22
+ steps:
23
+ - uses: actions/checkout@v5
24
+ - uses: actions/setup-python@v6
25
+ with:
26
+ python-version: ${{ matrix.python }}
27
+ - run: pip install -e ".[dev]"
28
+ - run: ruff check src tests deploy && ruff format --check src tests deploy
29
+ - run: docker compose -f deploy/nas/compose.yaml --env-file deploy/nas/.env.example config -q
30
+ - run: pytest -q -W error
31
+
32
+ stack:
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v5
36
+ - name: the stack starts from nothing, creates its roles and dumps its catalogue
37
+ run: |
38
+ mkdir -p "$RUNNER_TEMP/stack/data"
39
+ cat > "$RUNNER_TEMP/stack/.env" <<EOF
40
+ # this job never runs install or publish: the value only has to be set
41
+ OPEN_DATA_STORE_REF=${GITHUB_SHA}
42
+ OPEN_DATA_STORE_HOST_DIR=$RUNNER_TEMP/stack/data
43
+ OPEN_DATA_STORE_UID_GID=$(id -u):$(id -g)
44
+ OPEN_DATA_STORE_PG_BIND=127.0.0.1:5433
45
+ OPEN_DATA_STORE_CATALOG_DB=lake_catalog
46
+ OPEN_DATA_STORE_ADMIN_PASSWORD=ci-admin
47
+ OPEN_DATA_STORE_PUBLISHER_PASSWORD=ci-publisher
48
+ OPEN_DATA_STORE_READER_PASSWORD=ci-reader
49
+ OPEN_DATA_STORE_APPROVE=
50
+ OPEN_DATA_STORE_APPROVED_BY=
51
+ EOF
52
+ dc="docker compose -f deploy/nas/compose.yaml --env-file $RUNNER_TEMP/stack/.env"
53
+ $dc up -d --wait catalog
54
+ $dc run --rm backup
55
+ $dc run --rm init
56
+ test -s "$(ls "$RUNNER_TEMP"/stack/data/backups/lake_catalog-*.dump | head -n 1)"
57
+ docker run --rm --network host -e PGPASSWORD=ci-reader postgres:16 \
58
+ psql -h 127.0.0.1 -p 5433 -U lake_reader -d lake_catalog -Atc "SELECT 1"
59
+ $dc down -v
60
+ - name: a dump restores into a fresh stack, readable by lake_reader (stack migration path)
61
+ run: |
62
+ # Probes the operator path (dump, fresh stack, init, pg_restore as lake_publisher, read as
63
+ # lake_reader) on a plain table; a real DuckLake catalogue is restored the same way.
64
+ mkdir -p "$RUNNER_TEMP/rst/data"
65
+ sed "s#$RUNNER_TEMP/stack/data#$RUNNER_TEMP/rst/data#" "$RUNNER_TEMP/stack/.env" > "$RUNNER_TEMP/rst/.env"
66
+ dc="docker compose -f deploy/nas/compose.yaml --env-file $RUNNER_TEMP/rst/.env"
67
+ pub() { docker run --rm --network host -e PGPASSWORD=ci-publisher postgres:16 \
68
+ psql -h 127.0.0.1 -p 5433 -U lake_publisher -d lake_catalog -v ON_ERROR_STOP=1 -Atc "$1"; }
69
+ $dc up -d --wait catalog
70
+ $dc run --rm init
71
+ pub "CREATE TABLE ducklake_probe (n int); INSERT INTO ducklake_probe VALUES (1), (2), (3)"
72
+ $dc run --rm backup
73
+ dump="$(basename "$(ls "$RUNNER_TEMP"/rst/data/backups/lake_catalog-*.dump | tail -n 1)")"
74
+ $dc down -v
75
+ $dc up -d --wait catalog
76
+ $dc run --rm init
77
+ $dc run --rm backup sh -c "pg_restore --exit-on-error -d \"\$PGDATABASE\" /data/backups/$dump"
78
+ test "$(docker run --rm --network host -e PGPASSWORD=ci-reader postgres:16 \
79
+ psql -h 127.0.0.1 -p 5433 -U lake_reader -d lake_catalog -Atc \
80
+ "SELECT count(*) FROM ducklake_probe")" = 3
81
+ $dc down -v
82
+
83
+ # Publication check on every PR and push: build, `twine check --strict`, and install the
84
+ # wheel (with its reader extra) in a fresh venv away from the checkout. release.yml repeats
85
+ # this and adds the tag check and the upload.
86
+ package:
87
+ runs-on: ubuntu-latest
88
+ steps:
89
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
90
+ with:
91
+ persist-credentials: false
92
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
93
+ with:
94
+ python-version: "3.12"
95
+ - name: Build and check the distribution
96
+ run: |
97
+ pip install build==1.6.1 twine==7.0.0
98
+ python -m build . --outdir dist
99
+ twine check --strict dist/*
100
+ - name: Smoke install in a fresh venv
101
+ run: |
102
+ python -m venv "$RUNNER_TEMP/smoke"
103
+ "$RUNNER_TEMP/smoke/bin/pip" install "$(ls "$PWD"/dist/*.whl)[reader]"
104
+ cd "$RUNNER_TEMP"
105
+ "$RUNNER_TEMP/smoke/bin/python" -c "import open_data_store; print(open_data_store.__file__)"
106
+ "$RUNNER_TEMP/smoke/bin/open-data-store" --help
@@ -0,0 +1,175 @@
1
+ name: release
2
+
3
+ # Actions -> release -> Run workflow (target `pypi`) builds the default branch,
4
+ # publishes once the `pypi` environment's required reviewer approves, then
5
+ # creates the tag `vX.Y.Z` and the GitHub Release itself. Target `testpypi` is a
6
+ # rehearsal: it publishes to TestPyPI and creates no tag. Pushing a tag `vX.Y.Z`
7
+ # by hand still publishes. PyPI trusts this workflow + environment (no token).
8
+ on:
9
+ push:
10
+ tags: ["v*"]
11
+ workflow_dispatch:
12
+ inputs:
13
+ target:
14
+ # The publish environment comes from this input, so a new option needs a workflow change.
15
+ description: Index to publish to (testpypi is a rehearsal, no tag, no release)
16
+ type: choice
17
+ options: [pypi, testpypi]
18
+ default: pypi
19
+ required: true
20
+
21
+ permissions: {}
22
+
23
+ concurrency:
24
+ group: release-${{ github.ref }}
25
+ cancel-in-progress: false
26
+
27
+ jobs:
28
+ build:
29
+ runs-on: ubuntu-latest
30
+ permissions:
31
+ contents: read
32
+ outputs:
33
+ tag: ${{ steps.tag.outputs.tag || github.ref_name }}
34
+ sha: ${{ github.sha }}
35
+ steps:
36
+ - name: Branch guard (a dispatch must run on main)
37
+ if: github.event_name == 'workflow_dispatch'
38
+ env:
39
+ REF: ${{ github.ref }}
40
+ run: |
41
+ if [ "$REF" != "refs/heads/main" ]; then
42
+ echo "run this workflow on main (got $REF): pick the main branch in Run workflow"
43
+ exit 1
44
+ fi
45
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
46
+ with:
47
+ persist-credentials: false
48
+ fetch-depth: 0
49
+ - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
50
+ with:
51
+ python-version: "3.12"
52
+ - name: Build
53
+ run: |
54
+ pip install build==1.6.1 twine==7.0.0
55
+ python -m build . --outdir dist
56
+ twine check --strict dist/*
57
+ - name: Smoke install in a fresh venv
58
+ run: |
59
+ python -m venv "$RUNNER_TEMP/smoke"
60
+ "$RUNNER_TEMP/smoke/bin/pip" install "$(ls "$PWD"/dist/*.whl)[reader]"
61
+ cd "$RUNNER_TEMP"
62
+ "$RUNNER_TEMP/smoke/bin/python" -c "import open_data_store; print(open_data_store.__file__)"
63
+ "$RUNNER_TEMP/smoke/bin/open-data-store" --help
64
+ - name: Tag check (the wheel version must equal the tag version)
65
+ if: github.event_name == 'push'
66
+ run: |
67
+ wheel_version="$("$RUNNER_TEMP/smoke/bin/python" -c "import importlib.metadata as m; print(m.version('myopenfund-open-data-store'))")"
68
+ tag_version="${GITHUB_REF_NAME#v}"
69
+ if [ "$wheel_version" != "$tag_version" ]; then
70
+ echo "tag $GITHUB_REF_NAME says $tag_version but the built myopenfund-open-data-store wheel is $wheel_version"
71
+ exit 1
72
+ fi
73
+ echo "tag and wheel agree: $wheel_version"
74
+ - name: Branch check (the tagged commit must be on main)
75
+ if: github.event_name == 'push'
76
+ run: |
77
+ git merge-base --is-ancestor "$GITHUB_SHA" origin/main || { echo "tag $GITHUB_REF_NAME is not on main"; exit 1; }
78
+ - name: Compute the tag from the wheel version (dispatch; must be new for pypi)
79
+ id: tag
80
+ if: github.event_name == 'workflow_dispatch'
81
+ env:
82
+ INPUT_TARGET: ${{ inputs.target }}
83
+ run: |
84
+ version="$("$RUNNER_TEMP/smoke/bin/python" -c "import importlib.metadata as m; print(m.version('myopenfund-open-data-store'))")"
85
+ tag="v$version"
86
+ if [ "$INPUT_TARGET" = "pypi" ]; then
87
+ existing="$(git ls-remote --tags origin "refs/tags/$tag")"
88
+ if [ -n "$existing" ]; then
89
+ echo "tag $tag already exists on the remote: bump the version in a PR first"
90
+ exit 1
91
+ fi
92
+ fi
93
+ echo "tag=$tag" >> "$GITHUB_OUTPUT"
94
+ echo "will release $tag from $GITHUB_SHA (target $INPUT_TARGET)"
95
+ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
96
+ with:
97
+ name: dist
98
+ path: dist/
99
+ if-no-files-found: error
100
+
101
+ publish:
102
+ needs: build
103
+ runs-on: ubuntu-latest
104
+ environment: ${{ (github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi') && 'testpypi' || 'pypi' }}
105
+ permissions:
106
+ id-token: write
107
+ steps:
108
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
109
+ with:
110
+ name: dist
111
+ path: dist/
112
+ - name: Publish to PyPI
113
+ if: ${{ !(github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi') }}
114
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
115
+ - name: Publish to TestPyPI
116
+ if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
117
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
118
+ with:
119
+ repository-url: https://test.pypi.org/legacy/
120
+ skip-existing: true
121
+
122
+ github-release:
123
+ # Never for a TestPyPI rehearsal. On dispatch this job creates the tag with the
124
+ # job's token; GitHub does not start workflows for events caused by GITHUB_TOKEN,
125
+ # so that tag push does not re-trigger this workflow (which is what we want).
126
+ if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.target == 'pypi')
127
+ needs: [build, publish]
128
+ runs-on: ubuntu-latest
129
+ permissions:
130
+ contents: write
131
+ steps:
132
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
133
+ if: github.event_name == 'workflow_dispatch'
134
+ with:
135
+ ref: ${{ needs.build.outputs.sha }}
136
+ persist-credentials: true
137
+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
138
+ with:
139
+ name: dist
140
+ path: dist/
141
+ - name: Create the tag (dispatch; safe to re-run)
142
+ if: github.event_name == 'workflow_dispatch'
143
+ env:
144
+ TAG: ${{ needs.build.outputs.tag }}
145
+ SHA: ${{ needs.build.outputs.sha }}
146
+ run: |
147
+ # A re-run after a partial failure finds the tag already there. At the built
148
+ # commit: nothing to do. Anywhere else: stop, never move or reuse it.
149
+ remote_sha="$(git ls-remote origin "refs/tags/$TAG" "refs/tags/$TAG^{}" | awk '{ if ($2 ~ /\^\{\}$/) p = $1; else t = $1 } END { print (p != "" ? p : t) }')"
150
+ if [ -z "$remote_sha" ]; then
151
+ git -c user.name="Marc Jeulin" -c user.email="${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" tag -a "$TAG" -m "$TAG" "$SHA"
152
+ git push origin "refs/tags/$TAG"
153
+ elif [ "$remote_sha" = "$SHA" ]; then
154
+ echo "tag $TAG already exists at $SHA: nothing to push"
155
+ else
156
+ echo "tag $TAG already exists at $remote_sha, not at the built commit $SHA: refusing to reuse it"
157
+ exit 1
158
+ fi
159
+ - name: Create the GitHub release (or complete it)
160
+ env:
161
+ GH_TOKEN: ${{ github.token }}
162
+ TAG: ${{ needs.build.outputs.tag }}
163
+ SHA: ${{ needs.build.outputs.sha }}
164
+ run: |
165
+ # A release already exists when it was drafted in the GitHub web UI or when this
166
+ # job is re-run: attach the distributions and keep the title and notes there.
167
+ if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
168
+ gh release upload "$TAG" dist/* --repo "$GITHUB_REPOSITORY" --clobber
169
+ elif [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
170
+ gh release create "$TAG" dist/* \
171
+ --repo "$GITHUB_REPOSITORY" --target "$SHA" --title "$TAG" --generate-notes
172
+ else
173
+ gh release create "$TAG" dist/* \
174
+ --repo "$GITHUB_REPOSITORY" --verify-tag --title "$TAG" --generate-notes
175
+ fi
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ build/
9
+ /store/
10
+ deploy/nas/.env
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "myopenfund": {
4
+ "type": "http",
5
+ "url": "${MOF_MCP_URL}",
6
+ "headers": {
7
+ "Authorization": "Bearer ${MOF_MCP_TOKEN}"
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Marc Jeulin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.5
2
+ Name: myopenfund-open-data-store
3
+ Version: 0.1.0
4
+ Summary: Bitemporal open-data store for MyOpenFund: contracts, writer, publisher, reader.
5
+ Project-URL: Homepage, https://github.com/MyOpenFund/open-data-store
6
+ Project-URL: Source, https://github.com/MyOpenFund/open-data-store
7
+ Project-URL: Issues, https://github.com/MyOpenFund/open-data-store/issues
8
+ Project-URL: Organization, https://github.com/MyOpenFund
9
+ Author: Marc Jeulin
10
+ Maintainer: Marc Jeulin
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: bitemporal,duckdb,ducklake,finance,myopenfund,open-data,parquet
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Database
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: pyarrow>=17
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.2; extra == 'dev'
26
+ Requires-Dist: duckdb<3,>=2.0; extra == 'dev'
27
+ Requires-Dist: openpyxl>=3.1; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: pytz>=2024.1; extra == 'dev'
30
+ Requires-Dist: pyyaml>=6; extra == 'dev'
31
+ Requires-Dist: ruff==0.17.3; extra == 'dev'
32
+ Requires-Dist: twine>=5; extra == 'dev'
33
+ Provides-Extra: publisher
34
+ Requires-Dist: duckdb<3,>=2.0; extra == 'publisher'
35
+ Requires-Dist: pytz>=2024.1; extra == 'publisher'
36
+ Provides-Extra: reader
37
+ Requires-Dist: duckdb<3,>=2.0; extra == 'reader'
38
+ Requires-Dist: openpyxl>=3.1; extra == 'reader'
39
+ Requires-Dist: pytz>=2024.1; extra == 'reader'
40
+ Provides-Extra: writer
41
+ Description-Content-Type: text/markdown
42
+
43
+ # open-data-store
44
+
45
+ Created and maintained by [Marc Jeulin](https://github.com/jeulinmarc), part of [MyOpenFund](https://github.com/MyOpenFund).
46
+
47
+ Bitemporal open-data store for MyOpenFund: dataset **contracts**, a light **writer** for producers,
48
+ a **publisher** (the only writer to the lake) and a **reader** for analyses, the MCP and strategies.
49
+ Facts are DuckLake tables (Parquet + a Postgres catalogue), read through DuckDB. Every fact carries
50
+ `valid_date` (what it is about) and `known_at` (when it became knowable): reads are look-ahead-free.
51
+
52
+ > This library is a tool. It manages nobody's money and gives no investment advice.
53
+
54
+ Renamed on 2026-11-22 (package, import, command and environment variables): see
55
+ [docs/MIGRATION.md](https://github.com/MyOpenFund/open-data-store/blob/main/docs/MIGRATION.md).
56
+
57
+ ## Install
58
+
59
+ ```
60
+ pip install "myopenfund-open-data-store[writer]" # producers: pyarrow only
61
+ pip install "myopenfund-open-data-store[publisher]" # store operator: DuckDB + DuckLake
62
+ pip install "myopenfund-open-data-store[reader]" # analyses, MCP, strategies
63
+ ```
64
+
65
+ If this environment installed the old distribution (`open-data-store`, from a git URL), run
66
+ `pip uninstall -y open-data-store` before installing `myopenfund-open-data-store`: both own the same import package.
67
+
68
+ To try the latest `main` before a release (dependencies still come from PyPI):
69
+
70
+ ```
71
+ pip install "myopenfund-open-data-store[reader] @ git+https://github.com/MyOpenFund/open-data-store"
72
+ ```
73
+
74
+ **Working across repos**
75
+
76
+ Clone the repos side by side and install this package editable over the PyPI version in the
77
+ consumer's environment: `pip install -e ../open-data-store`. A consumer change that needs an
78
+ unreleased version waits for this package's release before the consumer's PR merges.
79
+
80
+ **How to release**
81
+
82
+ Bump `__version__` and `version` in a PR. After it merges, go to Actions, then release, then Run workflow: pick the `main` branch and target `pypi`. Approve the `pypi` deployment. The workflow builds the package, checks it, publishes it, then creates the tag `v<version>` and the GitHub Release itself.
83
+ It fails before publishing if it is not run on the default branch or if that tag already exists. Target `testpypi` is a rehearsal: it publishes to TestPyPI and creates no tag and no release.
84
+ Pushing a tag `v<version>` by hand still works: the workflow checks that the tag equals the package version and is on the default branch, then publishes and attaches the files to the Release.
85
+ If PyPI got the package but the tag or the Release is missing, re-run the failed `github-release` job from Actions; do not push the tag by hand (the re-run would fail at the PyPI upload).
86
+
87
+ ## Configuration
88
+
89
+ | Variable | Meaning |
90
+ |---|---|
91
+ | `OPEN_DATA_STORE_DATA_ROOT` | Holds `landing/` (batches), `lake/` (Parquet), `reports/` |
92
+ | `OPEN_DATA_STORE_CATALOG` | DuckLake catalogue: `postgres:dbname=... host=... user=...`, or a file path (tests, single user) |
93
+ | `OPEN_DATA_STORE_DATA_INLINING_ROW_LIMIT` | Default `0`: every batch becomes a Parquet file |
94
+ | `OPEN_DATA_STORE_KNOWN_AT_FUTURE_TOLERANCE_S` | Clock-skew tolerance, default `300` |
95
+ | `OPEN_DATA_STORE_RESOLVING_SCHEMES` | Identifier schemes that may merge entities, default `cik,lei,isin,figi,cb_code,national_id` |
96
+ | `OPEN_DATA_STORE_SINGLE_VALUED_SCHEMES` | Schemes an entity holds one value of, default `cik,lei,cb_code` |
97
+
98
+ ## Reader interface (stable for v0.x)
99
+
100
+ ```python
101
+ from datetime import datetime, timezone
102
+ from open_data_store.reader import Recipe, Store, export
103
+
104
+ store = Store.open() # config from env (or `with Store.open() as store:`)
105
+ store.datasets() # name, major, version, kind, licence, table
106
+ t = store.read_asof("fundamentals", datetime(2025, 12, 1, tzinfo=timezone.utc),
107
+ where="original_tag = 'us-gaap:Revenues'") # pyarrow.Table, latest known per key
108
+ t1 = store.read_asof("fundamentals", filters={"source_code": ["sec"]},
109
+ columns=["entity_id", "original_tag", "value"], limit=100) # bound, safe for servers
110
+ store.read_asof("fundamentals", filters={"entity_value": ["0000320193"]}, vintages=True) # every vintage
111
+ store.freshness() # last published_at, batch count
112
+ store.describe("fundamentals") # columns, docs, natural key, licence
113
+ t0 = store.read_asof("fundamentals", snapshot=42) # what the store held at DuckLake version 42
114
+ r = Recipe("debt_by_source", "1.0.0", {"f": "fundamentals"},
115
+ "SELECT source_code, sum(value) AS debt FROM f GROUP BY 1")
116
+ out = store.assemble(r, as_of=datetime.now(timezone.utc)) # save=True arrives with metrics
117
+ # {"f": "fundamentals:vintages"} gives every row knowable at the date, not the latest per key
118
+ export(out, "debt.xlsx") # .csv | .xlsx | .parquet
119
+ ```
120
+
121
+ **Time zone.** The reader's sessions are pinned to UTC: timestamps come back as UTC, and `where`
122
+ and recipe SQL evaluate in UTC whatever the process `TZ`. Under a non-UTC `TZ`, earlier versions
123
+ evaluated them in local time, so a naive literal (`known_at < '2025-07-31'`) or a date cast can
124
+ select other rows now; write explicit offsets (`TIMESTAMPTZ '2025-07-31 00:00:00+02'`).
125
+
126
+ **Performance.** Filters on natural-key columns (e.g. `entity_value`) are always pushed explicitly
127
+ before the as-of window, so DuckLake reads only the matching files: on a 20-issuer test store a
128
+ filter on `entity_value` read 1 fundamentals data file (5 kB) instead of 60 files (139 kB). DuckDB
129
+ already pushes a filter on the as-of window's partition key (the natural key) through the window by
130
+ itself (filtering `entity_value` outside the window also read 1 file / 5 kB); the explicit push in
131
+ `read_asof` guarantees that pruning whatever the optimizer version. Filters on other columns read
132
+ the whole table. Keep one batch per issuer, and do not merge data files
133
+ (`ducklake_merge_adjacent_files`) without measuring: merging issuers into one file defeats the
134
+ pruning.
135
+
136
+ ## Producers
137
+
138
+ ```python
139
+ from open_data_store.writer import write_batch
140
+ ref = write_batch(contract, table, landing_root=data_root / "landing",
141
+ run_id=run_id, producer="company-corpus", source_inputs=[...])
142
+ ```
143
+
144
+ The writer validates the table against its contract and drops an atomic, idempotent batch in
145
+ `landing/`. It never touches Postgres. A producer declares its own contracts through the
146
+ `open_data_store.contracts` entry-point group; standard contracts (`fundamentals`, `entity_observations`,
147
+ `filing_statements`, `filings`) ship with this library.
148
+
149
+ ## Operator
150
+
151
+ ```
152
+ open-data-store contracts list
153
+ open-data-store contracts approve fundamentals 3 --by <name> # reviewed step; refuses conflicting definitions
154
+ open-data-store contracts approve filing_statements 1 --by <name> # likewise, for a store that publishes it
155
+ open-data-store contracts approve filings 1 --by <name> # likewise
156
+ open-data-store publish # exit 0 ok · 1 fatal · 3 degraded
157
+ ```
158
+
159
+ `publish` audits every landed batch again (file checksum, contract, recomputed batch id),
160
+ quarantines failures in `landing/_quarantine/` with a `reason.json`, publishes the rest atomically
161
+ (one DuckLake snapshot per batch, commit message = batch id) and writes a run report under
162
+ `reports/publisher/`. A batch that hits an infrastructure error (listed under `errors`, exit 1)
163
+ stays in `landing/` for the next run, and so do the fact batches behind a failed identity batch,
164
+ instead of being quarantined as `unknown_entity`. Those deferrals are `errors` entries too (no
165
+ separate field): their `error` text starts with `deferred:`. Design, security model and gotchas: [docs/ARCHITECTURE.md](https://github.com/MyOpenFund/open-data-store/blob/main/docs/ARCHITECTURE.md).
166
+
167
+ Producers may re-emit full history: rows already published with the same values (compared
168
+ exactly, so re-emit bit-identical floats) are skipped and counted (`skipped_rows` in the report,
169
+ `rows_skipped` in `ref.batches`, where `rows` counts only the inserted rows); the same key and
170
+ `known_at` with another value quarantines the batch (`conflicting_republish`). Columns of the
171
+ major's first approved definition are compared strictly; columns added by a later minor are compared
172
+ only where the published row holds a value (changing it is a conflict), and filling a NULL in one
173
+ needs a later `known_at` to be recorded.
174
+
175
+ ## Licence
176
+
177
+ MIT (code). Each dataset carries its own data licence in its contract.
@@ -0,0 +1,135 @@
1
+ # open-data-store
2
+
3
+ Created and maintained by [Marc Jeulin](https://github.com/jeulinmarc), part of [MyOpenFund](https://github.com/MyOpenFund).
4
+
5
+ Bitemporal open-data store for MyOpenFund: dataset **contracts**, a light **writer** for producers,
6
+ a **publisher** (the only writer to the lake) and a **reader** for analyses, the MCP and strategies.
7
+ Facts are DuckLake tables (Parquet + a Postgres catalogue), read through DuckDB. Every fact carries
8
+ `valid_date` (what it is about) and `known_at` (when it became knowable): reads are look-ahead-free.
9
+
10
+ > This library is a tool. It manages nobody's money and gives no investment advice.
11
+
12
+ Renamed on 2026-11-22 (package, import, command and environment variables): see
13
+ [docs/MIGRATION.md](https://github.com/MyOpenFund/open-data-store/blob/main/docs/MIGRATION.md).
14
+
15
+ ## Install
16
+
17
+ ```
18
+ pip install "myopenfund-open-data-store[writer]" # producers: pyarrow only
19
+ pip install "myopenfund-open-data-store[publisher]" # store operator: DuckDB + DuckLake
20
+ pip install "myopenfund-open-data-store[reader]" # analyses, MCP, strategies
21
+ ```
22
+
23
+ If this environment installed the old distribution (`open-data-store`, from a git URL), run
24
+ `pip uninstall -y open-data-store` before installing `myopenfund-open-data-store`: both own the same import package.
25
+
26
+ To try the latest `main` before a release (dependencies still come from PyPI):
27
+
28
+ ```
29
+ pip install "myopenfund-open-data-store[reader] @ git+https://github.com/MyOpenFund/open-data-store"
30
+ ```
31
+
32
+ **Working across repos**
33
+
34
+ Clone the repos side by side and install this package editable over the PyPI version in the
35
+ consumer's environment: `pip install -e ../open-data-store`. A consumer change that needs an
36
+ unreleased version waits for this package's release before the consumer's PR merges.
37
+
38
+ **How to release**
39
+
40
+ Bump `__version__` and `version` in a PR. After it merges, go to Actions, then release, then Run workflow: pick the `main` branch and target `pypi`. Approve the `pypi` deployment. The workflow builds the package, checks it, publishes it, then creates the tag `v<version>` and the GitHub Release itself.
41
+ It fails before publishing if it is not run on the default branch or if that tag already exists. Target `testpypi` is a rehearsal: it publishes to TestPyPI and creates no tag and no release.
42
+ Pushing a tag `v<version>` by hand still works: the workflow checks that the tag equals the package version and is on the default branch, then publishes and attaches the files to the Release.
43
+ If PyPI got the package but the tag or the Release is missing, re-run the failed `github-release` job from Actions; do not push the tag by hand (the re-run would fail at the PyPI upload).
44
+
45
+ ## Configuration
46
+
47
+ | Variable | Meaning |
48
+ |---|---|
49
+ | `OPEN_DATA_STORE_DATA_ROOT` | Holds `landing/` (batches), `lake/` (Parquet), `reports/` |
50
+ | `OPEN_DATA_STORE_CATALOG` | DuckLake catalogue: `postgres:dbname=... host=... user=...`, or a file path (tests, single user) |
51
+ | `OPEN_DATA_STORE_DATA_INLINING_ROW_LIMIT` | Default `0`: every batch becomes a Parquet file |
52
+ | `OPEN_DATA_STORE_KNOWN_AT_FUTURE_TOLERANCE_S` | Clock-skew tolerance, default `300` |
53
+ | `OPEN_DATA_STORE_RESOLVING_SCHEMES` | Identifier schemes that may merge entities, default `cik,lei,isin,figi,cb_code,national_id` |
54
+ | `OPEN_DATA_STORE_SINGLE_VALUED_SCHEMES` | Schemes an entity holds one value of, default `cik,lei,cb_code` |
55
+
56
+ ## Reader interface (stable for v0.x)
57
+
58
+ ```python
59
+ from datetime import datetime, timezone
60
+ from open_data_store.reader import Recipe, Store, export
61
+
62
+ store = Store.open() # config from env (or `with Store.open() as store:`)
63
+ store.datasets() # name, major, version, kind, licence, table
64
+ t = store.read_asof("fundamentals", datetime(2025, 12, 1, tzinfo=timezone.utc),
65
+ where="original_tag = 'us-gaap:Revenues'") # pyarrow.Table, latest known per key
66
+ t1 = store.read_asof("fundamentals", filters={"source_code": ["sec"]},
67
+ columns=["entity_id", "original_tag", "value"], limit=100) # bound, safe for servers
68
+ store.read_asof("fundamentals", filters={"entity_value": ["0000320193"]}, vintages=True) # every vintage
69
+ store.freshness() # last published_at, batch count
70
+ store.describe("fundamentals") # columns, docs, natural key, licence
71
+ t0 = store.read_asof("fundamentals", snapshot=42) # what the store held at DuckLake version 42
72
+ r = Recipe("debt_by_source", "1.0.0", {"f": "fundamentals"},
73
+ "SELECT source_code, sum(value) AS debt FROM f GROUP BY 1")
74
+ out = store.assemble(r, as_of=datetime.now(timezone.utc)) # save=True arrives with metrics
75
+ # {"f": "fundamentals:vintages"} gives every row knowable at the date, not the latest per key
76
+ export(out, "debt.xlsx") # .csv | .xlsx | .parquet
77
+ ```
78
+
79
+ **Time zone.** The reader's sessions are pinned to UTC: timestamps come back as UTC, and `where`
80
+ and recipe SQL evaluate in UTC whatever the process `TZ`. Under a non-UTC `TZ`, earlier versions
81
+ evaluated them in local time, so a naive literal (`known_at < '2025-07-31'`) or a date cast can
82
+ select other rows now; write explicit offsets (`TIMESTAMPTZ '2025-07-31 00:00:00+02'`).
83
+
84
+ **Performance.** Filters on natural-key columns (e.g. `entity_value`) are always pushed explicitly
85
+ before the as-of window, so DuckLake reads only the matching files: on a 20-issuer test store a
86
+ filter on `entity_value` read 1 fundamentals data file (5 kB) instead of 60 files (139 kB). DuckDB
87
+ already pushes a filter on the as-of window's partition key (the natural key) through the window by
88
+ itself (filtering `entity_value` outside the window also read 1 file / 5 kB); the explicit push in
89
+ `read_asof` guarantees that pruning whatever the optimizer version. Filters on other columns read
90
+ the whole table. Keep one batch per issuer, and do not merge data files
91
+ (`ducklake_merge_adjacent_files`) without measuring: merging issuers into one file defeats the
92
+ pruning.
93
+
94
+ ## Producers
95
+
96
+ ```python
97
+ from open_data_store.writer import write_batch
98
+ ref = write_batch(contract, table, landing_root=data_root / "landing",
99
+ run_id=run_id, producer="company-corpus", source_inputs=[...])
100
+ ```
101
+
102
+ The writer validates the table against its contract and drops an atomic, idempotent batch in
103
+ `landing/`. It never touches Postgres. A producer declares its own contracts through the
104
+ `open_data_store.contracts` entry-point group; standard contracts (`fundamentals`, `entity_observations`,
105
+ `filing_statements`, `filings`) ship with this library.
106
+
107
+ ## Operator
108
+
109
+ ```
110
+ open-data-store contracts list
111
+ open-data-store contracts approve fundamentals 3 --by <name> # reviewed step; refuses conflicting definitions
112
+ open-data-store contracts approve filing_statements 1 --by <name> # likewise, for a store that publishes it
113
+ open-data-store contracts approve filings 1 --by <name> # likewise
114
+ open-data-store publish # exit 0 ok · 1 fatal · 3 degraded
115
+ ```
116
+
117
+ `publish` audits every landed batch again (file checksum, contract, recomputed batch id),
118
+ quarantines failures in `landing/_quarantine/` with a `reason.json`, publishes the rest atomically
119
+ (one DuckLake snapshot per batch, commit message = batch id) and writes a run report under
120
+ `reports/publisher/`. A batch that hits an infrastructure error (listed under `errors`, exit 1)
121
+ stays in `landing/` for the next run, and so do the fact batches behind a failed identity batch,
122
+ instead of being quarantined as `unknown_entity`. Those deferrals are `errors` entries too (no
123
+ separate field): their `error` text starts with `deferred:`. Design, security model and gotchas: [docs/ARCHITECTURE.md](https://github.com/MyOpenFund/open-data-store/blob/main/docs/ARCHITECTURE.md).
124
+
125
+ Producers may re-emit full history: rows already published with the same values (compared
126
+ exactly, so re-emit bit-identical floats) are skipped and counted (`skipped_rows` in the report,
127
+ `rows_skipped` in `ref.batches`, where `rows` counts only the inserted rows); the same key and
128
+ `known_at` with another value quarantines the batch (`conflicting_republish`). Columns of the
129
+ major's first approved definition are compared strictly; columns added by a later minor are compared
130
+ only where the published row holds a value (changing it is a conflict), and filling a NULL in one
131
+ needs a later `known_at` to be recorded.
132
+
133
+ ## Licence
134
+
135
+ MIT (code). Each dataset carries its own data licence in its contract.