Skip to content

Commit eda617f

Browse files
author
MongoDB DevRel
committed
feat: MongoDBMemoryCapability for Pydantic AI (reference impl for harness#255)
0 parents  commit eda617f

18 files changed

Lines changed: 1610 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install package + dev deps
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[dev]"
28+
29+
- name: Run acceptance suite (offline; Atlas vector test auto-skips)
30+
env:
31+
# ATLAS_URI / VOYAGE_API_KEY are intentionally unset in CI →
32+
# test_vector_recall skips. Set them as repo secrets to run it.
33+
ATLAS_URI: ${{ secrets.ATLAS_URI }}
34+
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
35+
run: pytest tests/ -v
36+
37+
build:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-python@v5
42+
with:
43+
python-version: "3.12"
44+
- name: Build sdist + wheel
45+
run: |
46+
python -m pip install --upgrade pip build twine
47+
python -m build
48+
python -m twine check dist/*

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
3+
# Publishes to PyPI via Trusted Publishing (OIDC) — no API tokens stored.
4+
# Trigger: push a version tag (e.g. v0.1.0) OR run manually for a TestPyPI dry-run.
5+
#
6+
# One-time setup on PyPI (and TestPyPI) → Project → Publishing → "Add a pending publisher":
7+
# Owner: mongodb-developer
8+
# Repository: pydantic-ai-mongodb-memory
9+
# Workflow: release.yml
10+
# Environment: pypi (and testpypi for the test index)
11+
12+
on:
13+
push:
14+
tags: ["v*"]
15+
workflow_dispatch:
16+
inputs:
17+
target:
18+
description: "Where to publish"
19+
type: choice
20+
default: testpypi
21+
options: [testpypi, pypi]
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
build:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-python@v5
32+
with:
33+
python-version: "3.12"
34+
- name: Build distributions
35+
run: |
36+
python -m pip install --upgrade pip build twine
37+
python -m build
38+
python -m twine check dist/*
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
name: dist
42+
path: dist/
43+
44+
publish-testpypi:
45+
# Tag pushes and explicit testpypi dispatch both go to TestPyPI first.
46+
if: github.event_name == 'push' || github.event.inputs.target == 'testpypi'
47+
needs: build
48+
runs-on: ubuntu-latest
49+
environment: testpypi
50+
permissions:
51+
id-token: write # required for Trusted Publishing (OIDC)
52+
steps:
53+
- uses: actions/download-artifact@v4
54+
with:
55+
name: dist
56+
path: dist/
57+
- name: Publish to TestPyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
with:
60+
repository-url: https://test.pypi.org/legacy/
61+
62+
publish-pypi:
63+
# Real PyPI only on a version tag (or explicit pypi dispatch).
64+
if: startsWith(github.ref, 'refs/tags/v') || github.event.inputs.target == 'pypi'
65+
needs: build
66+
runs-on: ubuntu-latest
67+
environment: pypi
68+
permissions:
69+
id-token: write # required for Trusted Publishing (OIDC)
70+
steps:
71+
- uses: actions/download-artifact@v4
72+
with:
73+
name: dist
74+
path: dist/
75+
- name: Publish to PyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Internal build plan & helper artifacts — not shipped with the package/repo
2+
PLAN.md
3+
PUBLISHING.md
4+
5+
# Internal outreach drafts — not part of the public package/repo
6+
outreach/
7+
8+
9+
10+
# Secrets / local env
11+
.env
12+
demo/.env
13+
14+
# Virtual environments
15+
.venv/
16+
venv/
17+
env/
18+
19+
# Python build / packaging artifacts
20+
build/
21+
dist/
22+
*.egg-info/
23+
*.egg
24+
pip-wheel-metadata/
25+
26+
# Caches & bytecode
27+
__pycache__/
28+
*.py[cod]
29+
.pytest_cache/
30+
.mypy_cache/
31+
.ruff_cache/
32+
.coverage
33+
htmlcov/
34+
35+
# OS / editor cruft
36+
.DS_Store

LICENSE

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 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 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 Derivative
95+
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 those notices that do not
110+
pertain to any part of the Derivative Works.
111+
112+
You may add Your own copyright statement to Your modifications and
113+
may provide additional or different license terms and conditions
114+
for use, reproduction, or distribution of Your modifications, or
115+
for any such Derivative Works as a whole, provided Your use,
116+
reproduction, and distribution of the Work otherwise complies with
117+
the conditions stated in this License.
118+
119+
5. Submission of Contributions. Unless You explicitly state otherwise,
120+
any Contribution intentionally submitted for inclusion in the Work
121+
by You to the Licensor shall be under the terms and conditions of
122+
this License, without any additional terms or conditions.
123+
Notwithstanding the above, nothing herein shall supersede or modify
124+
the terms of any separate license agreement you may have executed
125+
with Licensor regarding such Contributions.
126+
127+
6. Trademarks. This License does not grant permission to use the trade
128+
names, trademarks, service marks, or product names of the Licensor,
129+
except as required for reasonable and customary use in describing the
130+
origin of the Work and reproducing the content of the NOTICE file.
131+
132+
7. Disclaimer of Warranty. Unless required by applicable law or
133+
agreed to in writing, Licensor provides the Work (and each
134+
Contributor provides its Contributions) on an "AS IS" BASIS,
135+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
136+
implied, including, without limitation, any warranties or conditions
137+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
138+
PARTICULAR PURPOSE. You are solely responsible for determining the
139+
appropriateness of using or redistributing the Work and assume any
140+
risks associated with Your exercise of permissions under this License.
141+
142+
8. Limitation of Liability. In no event and under no legal theory,
143+
whether in tort (including negligence), contract, or otherwise,
144+
unless required by applicable law (such as deliberate and grossly
145+
negligent acts) or agreed to in writing, shall any Contributor be
146+
liable to You for damages, including any direct, indirect, special,
147+
incidental, or consequential damages of any character arising as a
148+
result of this License or out of the use or inability to use the
149+
Work (including but not limited to damages for loss of goodwill,
150+
work stoppage, computer failure or malfunction, or any and all
151+
other commercial damages or losses), even if such Contributor
152+
has been advised of the possibility of such damages.
153+
154+
9. Accepting Warranty or Additional Liability. While redistributing
155+
the Work or Derivative Works thereof, You may choose to offer,
156+
and charge a fee for, acceptance of support, warranty, indemnity,
157+
or other liability obligations and/or rights consistent with this
158+
License. However, in accepting such obligations, You may act only
159+
on Your own behalf and on Your sole responsibility, not on behalf
160+
of any other Contributor, and only if You agree to indemnify,
161+
defend, and hold each Contributor harmless for any liability
162+
incurred by, or claims asserted against, such Contributor by reason
163+
of your accepting any such warranty or additional liability.
164+
165+
END OF TERMS AND CONDITIONS
166+
167+
APPENDIX: How to apply the Apache License to your work.
168+
169+
To apply the Apache License to your work, attach the following
170+
boilerplate notice, with the fields enclosed by brackets "[]"
171+
replaced with your own identifying information. (Don't include
172+
the brackets!) The text should be enclosed in the appropriate
173+
comment syntax for the file format. We also recommend that a
174+
file or class name and description of purpose be included on the
175+
same "printed page" as the copyright notice for easier
176+
identification within third-party archives.
177+
178+
Copyright 2026 MongoDB, Inc.
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 commit comments

Comments
 (0)