Skip to content

Commit 8d776d8

Browse files
authored
Merge pull request #1 from NoahStapp/main
INTPYTHON-598 - Create an AI/ML helper library
2 parents 22be6a3 + 853a5f4 commit 8d776d8

File tree

12 files changed

+1232
-1
lines changed

12 files changed

+1232
-1
lines changed

.github/dependabot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"
12+
# Python
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"

.github/workflows/dist.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Python Dist
2+
3+
on:
4+
push:
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
- "[0-9]+.[0-9]+.[0-9]+.post[0-9]+"
8+
- "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+"
9+
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
10+
workflow_dispatch:
11+
pull_request:
12+
workflow_call:
13+
inputs:
14+
ref:
15+
required: true
16+
type: string
17+
18+
permissions:
19+
contents: read
20+
actions: read
21+
22+
concurrency:
23+
group: dist-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
defaults:
27+
run:
28+
shell: bash -eux {0}
29+
30+
jobs:
31+
make_dist:
32+
name: Make Dist
33+
runs-on: macos-latest
34+
steps:
35+
- uses: actions/checkout@v5
36+
with:
37+
persist-credentials: false
38+
39+
- uses: actions/setup-python@v6
40+
with:
41+
# Build sdist on lowest supported Python
42+
python-version: '3.10'
43+
44+
- name: Install python requirements
45+
run: |
46+
python -m pip install uv rust-just build
47+
48+
- name: Build Dist
49+
run: |
50+
python -m build .
51+
52+
- name: Test SDist
53+
run: |
54+
python -m pip install dist/*.gz
55+
cd ..
56+
python -c "from pymongo_vectorsearch_utils import create_vector_search_index"
57+
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: "dist"
61+
path: ./dist/*.*
62+
63+
collect_dist:
64+
runs-on: ubuntu-latest
65+
needs: [make_dist]
66+
name: Download Dist
67+
steps:
68+
- name: Download all workflow run artifacts
69+
uses: actions/download-artifact@v5
70+
- name: Flatten directory
71+
working-directory: .
72+
run: |
73+
find . -mindepth 2 -type f -exec mv {} . \;
74+
find . -type d -empty -delete
75+
- uses: actions/upload-artifact@v4
76+
with:
77+
name: all-dist-${{ github.run_id }}
78+
path: "./*"
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
following_version:
7+
description: "The post (dev) version to set"
8+
dry_run:
9+
description: "Dry Run?"
10+
default: false
11+
type: boolean
12+
schedule:
13+
- cron: '30 5 * * *'
14+
15+
env:
16+
# Changes per repo
17+
PRODUCT_NAME: pymongo-vectorsearch-utils
18+
# Constant
19+
# inputs will be empty on a scheduled run. so, we only set dry_run
20+
# to 'false' when the input is set to 'false'.
21+
DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }}
22+
FOLLOWING_VERSION: ${{ inputs.following_version || '' }}
23+
24+
concurrency:
25+
group: wheels-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
defaults:
29+
run:
30+
shell: bash -eux {0}
31+
32+
jobs:
33+
pre-publish:
34+
environment: release
35+
runs-on: ubuntu-latest
36+
if: github.repository_owner == 'mongodb-labs' || github.event_name == 'workflow_dispatch'
37+
permissions:
38+
id-token: write
39+
contents: write
40+
outputs:
41+
version: ${{ steps.pre-publish.outputs.version }}
42+
steps:
43+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
44+
with:
45+
app_id: ${{ vars.APP_ID }}
46+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
47+
- uses: mongodb-labs/drivers-github-tools/setup@v2
48+
with:
49+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
50+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
51+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
52+
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
53+
- uses: mongodb-labs/drivers-github-tools/python-labs/pre-publish@v2
54+
id: pre-publish
55+
with:
56+
dry_run: ${{ env.DRY_RUN }}
57+
58+
build-dist:
59+
needs: [pre-publish]
60+
uses: ./.github/workflows/dist.yml
61+
permissions:
62+
contents: read
63+
actions: read
64+
with:
65+
ref: ${{ needs.pre-publish.outputs.version }}
66+
67+
static-scan:
68+
needs: [pre-publish]
69+
uses: ./.github/workflows/codeql.yml
70+
permissions:
71+
security-events: write
72+
packages: read
73+
actions: read
74+
contents: read
75+
with:
76+
ref: ${{ needs.pre-publish.outputs.version }}
77+
78+
publish:
79+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi
80+
needs: [build-dist, static-scan]
81+
if: (github.repository_owner == 'mongodb-labs' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch'
82+
runs-on: ubuntu-latest
83+
environment: release
84+
permissions:
85+
id-token: write
86+
steps:
87+
- name: Download all the dists
88+
uses: actions/download-artifact@v5
89+
with:
90+
name: all-dist-${{ github.run_id }}
91+
path: dist/
92+
- name: Publish package distributions to TestPyPI
93+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
94+
with:
95+
repository-url: https://test.pypi.org/legacy/
96+
skip-existing: true
97+
attestations: ${{ env.DRY_RUN }}
98+
- name: Publish distribution 📦 to PyPI
99+
if: startsWith(env.DRY_RUN, 'false')
100+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
101+
102+
post-publish:
103+
needs: [publish]
104+
runs-on: ubuntu-latest
105+
environment: release
106+
permissions:
107+
id-token: write
108+
contents: write
109+
attestations: write
110+
security-events: write
111+
steps:
112+
- uses: mongodb-labs/drivers-github-tools/secure-checkout@v2
113+
with:
114+
app_id: ${{ vars.APP_ID }}
115+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
116+
- uses: mongodb-labs/drivers-github-tools/setup@v2
117+
with:
118+
aws_role_arn: ${{ secrets.AWS_ROLE_ARN }}
119+
aws_region_name: ${{ vars.AWS_REGION_NAME }}
120+
aws_secret_id: ${{ secrets.AWS_SECRET_ID }}
121+
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
122+
- uses: mongodb-labs/drivers-github-tools/python-labs/post-publish@v2
123+
with:
124+
following_version: ${{ env.FOLLOWING_VERSION }}
125+
product_name: ${{ env.PRODUCT_NAME }}
126+
token: ${{ github.token }}
127+
dry_run: ${{ env.DRY_RUN }}

.github/workflows/test-python.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Python Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
8+
concurrency:
9+
group: tests-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: bash -eux {0}
15+
16+
env:
17+
MIN_PYTHON: "3.10"
18+
19+
jobs:
20+
static:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
steps:
25+
- uses: actions/checkout@v5
26+
with:
27+
persist-credentials: false
28+
fetch-depth: 0
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5
31+
with:
32+
enable-cache: true
33+
python-version: ${{ matrix.python-version }}
34+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
35+
- run: just install
36+
- run: just lint
37+
- run: just docs
38+
- run: just doctest
39+
build:
40+
runs-on: ubuntu-latest
41+
permissions:
42+
contents: read
43+
strategy:
44+
matrix:
45+
python-version: ["3.10", "3.11", "3.12", "3.13"]
46+
fail-fast: false
47+
name: CPython ${{ matrix.python-version }}
48+
steps:
49+
- uses: actions/checkout@v5
50+
with:
51+
persist-credentials: false
52+
fetch-depth: 0
53+
- name: Install uv
54+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5
55+
with:
56+
enable-cache: true
57+
python-version: ${{ matrix.python-version }}
58+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
59+
- uses: mongodb-labs/drivers-evergreen-tools@master
60+
with:
61+
local-atlas: '1'
62+
- run: just install
63+
- run: just test
64+
65+
build-min:
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: read
69+
steps:
70+
- uses: actions/checkout@v5
71+
with:
72+
persist-credentials: false
73+
fetch-depth: 0
74+
- name: Install uv
75+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5
76+
with:
77+
enable-cache: true
78+
python-version: ${{ env.MIN_PYTHON }}
79+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
80+
- name: Install uv
81+
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v5
82+
with:
83+
enable-cache: true
84+
python-version: ${{ env.MIN_PYTHON }}
85+
- uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
86+
- uses: mongodb-labs/drivers-evergreen-tools@master
87+
with:
88+
local-atlas: '1'
89+
- name: Run unit tests with minimum dependency versions
90+
run: |
91+
uv sync --python=${MIN_PYTHON} --resolution=lowest-direct
92+
just test

.github/workflows/zizmor.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: GitHub Actions Security Analysis with zizmor
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor latest via Cargo
12+
runs-on: ubuntu-latest
13+
permissions:
14+
security-events: write
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
with:
19+
persist-credentials: false
20+
- name: Run zizmor
21+
uses: zizmorcore/zizmor-action@a016d81e77496751b5c04eb1e8f00214bd396553

.github/zizmor.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
rules:
2+
unpinned-uses:
3+
config:
4+
policies:
5+
actions/*: ref-pin
6+
mongodb-labs/drivers-github-tools/*: ref-pin
7+
mongodb-labs/drivers-evergreen-tools: ref-pin
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
from ._version import __version__
2-
2+
from .index import (
3+
create_fulltext_search_index,
4+
create_vector_search_index,
5+
drop_vector_search_index,
6+
update_vector_search_index,
7+
)
8+
from .pipeline import (
9+
combine_pipelines,
10+
final_hybrid_stage,
11+
reciprocal_rank_stage,
12+
text_search_stage,
13+
vector_search_stage,
14+
)
315

416
__all__ = [
517
"__version__",
18+
"create_vector_search_index",
19+
"drop_vector_search_index",
20+
"update_vector_search_index",
21+
"create_fulltext_search_index",
22+
"text_search_stage",
23+
"vector_search_stage",
24+
"combine_pipelines",
25+
"reciprocal_rank_stage",
26+
"final_hybrid_stage",
627
]

0 commit comments

Comments
 (0)