Skip to content

Commit df7a55c

Browse files
committed
include pre-commit to lint the config.yml file
2 parents 3d467f3 + 69b644a commit df7a55c

File tree

12 files changed

+451
-52
lines changed

12 files changed

+451
-52
lines changed

.evergreen/config.yml

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -310,30 +310,32 @@ buildvariants:
310310
- name: test-langgraph-python-remote
311311
batchtime: 10080 # 1 week
312312

313-
- name: test-chatgpt-retrieval-plugin-rhel
314-
display_name: ChatGPT Retrieval Plugin
315-
tags: [python]
316-
expansions:
317-
DIR: chatgpt-retrieval-plugin
318-
run_on:
319-
- rhel87-small
320-
tasks:
321-
- name: test-chatgpt-retrieval-plugin-local
322-
- name: test-chatgpt-retrieval-plugin-remote
323-
batchtime: 10080 # 1 week
324-
325-
- name: test-llama-index-vectorstore-rhel
326-
display_name: LlamaIndex RHEL Vector Store
327-
tags: [python]
328-
expansions:
329-
DIR: llama-index-python-vectorstore
330-
run_on:
331-
- rhel87-small
332-
tasks:
333-
- name: test-llama-index-local
334-
# TODO: INTPYTHON-440
335-
# - name: test-llama-index-remote
336-
# batchtime: 10080 # 1 week
313+
# TODO: INTPYTHON-668
314+
# - name: test-chatgpt-retrieval-plugin-rhel
315+
# display_name: ChatGPT Retrieval Plugin
316+
# tags: [python]
317+
# expansions:
318+
# DIR: chatgpt-retrieval-plugin
319+
# run_on:
320+
# - rhel87-small
321+
# tasks:
322+
# - name: test-chatgpt-retrieval-plugin-local
323+
# - name: test-chatgpt-retrieval-plugin-remote
324+
# batchtime: 10080 # 1 week
325+
326+
# TODO: INTPYTHON-669
327+
# - name: test-llama-index-vectorstore-rhel
328+
# display_name: LlamaIndex RHEL Vector Store
329+
# tags: [python]
330+
# expansions:
331+
# DIR: llama-index-python-vectorstore
332+
# run_on:
333+
# - rhel87-small
334+
# tasks:
335+
# - name: test-llama-index-local
336+
# # TODO: INTPYTHON-440
337+
# # - name: test-llama-index-remote
338+
# # batchtime: 10080 # 1 week
337339

338340
- name: test-docarray-rhel
339341
display_name: DocArray RHEL
@@ -391,13 +393,14 @@ buildvariants:
391393
tasks:
392394
- name: test-langchaingo-local
393395

394-
- name: test-langchain-js-ubuntu
395-
display_name: LangchainJS Ubuntu2204
396-
tags: [javascript]
397-
expansions:
398-
DIR: langchain-js
399-
run_on:
400-
- ubuntu2204-small
401-
tasks:
402-
- name: test-langchain-js-local
403-
- name: test-langchain-js-remote
396+
# TODO: INTPYTHON-667
397+
# - name: test-langchain-js-ubuntu
398+
# display_name: LangchainJS Ubuntu2204
399+
# tags: [javascript]
400+
# expansions:
401+
# DIR: langchain-js
402+
# run_on:
403+
# - ubuntu2204-small
404+
# tasks:
405+
# - name: test-langchain-js-local
406+
# - name: test-langchain-js-remote

.evergreen/execute-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ set -eu
55
SCRIPT_DIR=$(realpath "$(dirname ${BASH_SOURCE[0]})")
66
ROOT_DIR=$(dirname $SCRIPT_DIR)
77

8-
98
# Source the configuration.
109
cd ${ROOT_DIR}/${DIR}
1110
set -a
1211
source config.env
1312
set +a
1413

1514
cd ${REPO_NAME}
15+
1616
bash ${ROOT_DIR}/${DIR}/run.sh

.evergreen/lint_config.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Pre-commit hook to check if buildvariant tasks contain required language tags.
4+
"""
5+
6+
import logging
7+
import sys
8+
import yaml
9+
from pathlib import Path
10+
from typing import List, Dict, Any
11+
12+
logging.basicConfig()
13+
logger = logging.getLogger(__file__)
14+
logger.setLevel(logging.DEBUG)
15+
16+
17+
CURRENT_DIR = Path(__file__).parent.resolve()
18+
CONFIG_YML = CURRENT_DIR / "config.yml"
19+
VALID_LANGUAGES = {"python", "golang", "javascript", "csharp"}
20+
21+
22+
def load_yaml_file(file_path: str) -> Dict[Any, Any]:
23+
"""Load and parse a YAML file."""
24+
with open(file_path, "r", encoding="utf-8") as file:
25+
return yaml.safe_load(file) or {}
26+
27+
28+
def check_buildvariant_tags(data: Dict[Any, Any]) -> List[str]:
29+
"""
30+
Check if buildvariant tasks contain at least one required language tag.
31+
32+
Example Buildvariant structure in YAML:
33+
buildvariants:
34+
- name: test-semantic-kernel-python-rhel
35+
display_name: Semantic-Kernel RHEL Python
36+
tags: [python]
37+
expansions:
38+
DIR: semantic-kernel-python
39+
run_on:
40+
- rhel87-small
41+
tasks:
42+
- name: test-semantic-kernel-python-local
43+
- name: test-semantic-kernel-python-remote
44+
batchtime: 10080 # 1 week
45+
46+
Args:
47+
data: Parsed YAML data
48+
49+
Returns:
50+
List of error messages for tasks missing required tags
51+
"""
52+
errors = []
53+
54+
buildvariants = data.get("buildvariants", [])
55+
if not isinstance(buildvariants, list):
56+
return ["'buildvariants' should be a list"]
57+
58+
for i, buildvariant in enumerate(buildvariants):
59+
if not isinstance(buildvariant, dict):
60+
errors.append(f"buildvariants[{i}] should be a dictionary")
61+
continue
62+
63+
buildvariant_name = buildvariant.get("display_name", f"buildvariant_{i}")
64+
tags = buildvariant.get("tags", [])
65+
66+
if not isinstance(tags, list) or len(tags) != 1:
67+
errors.append(
68+
f"'tags' in buildvariant '{buildvariant_name}' should be a list of size 1"
69+
)
70+
continue
71+
72+
if tags[0] not in VALID_LANGUAGES:
73+
errors.append(
74+
f"buildvariant '{buildvariant_name}' has invalid tag '{tags[0]}'. "
75+
f"Valid tags are: {', '.join(VALID_LANGUAGES)}"
76+
)
77+
return errors
78+
79+
80+
def main():
81+
"""Main function for the pre-commit hook."""
82+
total_errors = 0
83+
84+
data = load_yaml_file(CONFIG_YML)
85+
if not data:
86+
raise FileNotFoundError(f"Failed to load or parse {CONFIG_YML}")
87+
88+
errors = check_buildvariant_tags(data)
89+
90+
if errors:
91+
logger.error("❌ Errors found in %s:", CONFIG_YML)
92+
for error in errors:
93+
logger.error(" - %s", error)
94+
total_errors += len(errors)
95+
96+
if total_errors > 0:
97+
logger.error("❌ Total errors found: %s", total_errors)
98+
return 1
99+
else:
100+
logger.info("✅ %s passed AI/ML testing pipeline validation", CONFIG_YML)
101+
102+
103+
if __name__ == "__main__":
104+
sys.exit(main())

.evergreen/provision-atlas.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ source secrets-export.sh
1818

1919
# Create the env file
2020
echo "export VOYAGEAI_S3_BUCKET=$VOYAGEAI_S3_BUCKET" >> env.sh
21-
echo "export OPENAI_API_KEY=$OPENAI_API_KEY" >> env.sh
21+
echo "export AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" >> env.sh
22+
echo "export AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" >> env.sh
23+
echo "export OPENAI_API_VERSION=$OPENAI_API_VERSION" >> env.sh
2224
echo "export MONGODB_URI=$CONN_STRING" >> env.sh
2325
echo "export VOYAGEAI_API_KEY=$VOYAGEAI_API_KEY" >> env.sh

.evergreen/setup-remote.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ export MONGODB_URI
5353

5454
# Create the env file
5555
echo "export VOYAGEAI_S3_BUCKET=$VOYAGEAI_S3_BUCKET" >> env.sh
56-
echo "export VOYAGEAI_API_KEY=$VOYAGEAI_API_KEY" >> env.sh
57-
echo "export OPENAI_API_KEY=$OPENAI_API_KEY" >> env.sh
56+
echo "export AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" >> env.sh
57+
echo "export AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" >> env.sh
58+
echo "export OPENAI_API_VERSION=$OPENAI_API_VERSION" >> env.sh
5859
echo "export MONGODB_URI=$MONGODB_URI" >> env.sh
60+
echo "export VOYAGEAI_API_KEY=$VOYAGEAI_API_KEY" >> env.sh
5961

6062
# Ensure the remote database is populated.
6163
. .evergreen/utils.sh

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ repos:
5353
rev: "v2.2.6"
5454
hooks:
5555
- id: codespell
56+
57+
- repo: local
58+
hooks:
59+
- id: check-buildvariant-tags
60+
name: Check buildvariant language tags
61+
entry: python3 .evergreen/lint_config.py
62+
language: system
63+
files: .evergreen/config.yml
64+
args: ['--languages=python,golang,javascript,csharp']

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ evergreen patch -p ai-ml-pipeline-testing --param REPO_ORG=caseyclements --param
189189

190190
Tests are run periodically (nightly) and any failures will propagate into both the `dbx-ai-ml-testing-pipline-notifications` and `dbx-ai-ml-testing-pipeline-notifications-{language}` channel. Repo owners of this `ai-ml-testing-pipeline` library are required to join the `dbx-ai-ml-testing-pipeline-notifications`. Pipeline specific implementers must **at least** join `dbx-ai-ml-testing-pipline-notifications-{language}` (e.g. whomever implemented `langchain-js` must at least be a member of `dbx-ai-ml-testing-pipeline-notifications-js`).
191191

192-
If tests are found to be failing, and cannot be addressed quickly, the responsible team MUST create a JIRA ticket, and disable the relevant tests
192+
If tests are found to be failing, and cannot be addressed quickly, the responsible team MUST create a JIRA ticket within their team's project (e.g. a python failure should generate an `INTPYTHON` ticket), and disable the relevant tests
193193
in the `config.yml` file, with a comment about the JIRA ticket that will address it.
194194

195195
This policy will help ensure that a single failing integration does not cause noise in the `dbx-ai-ml-testing-pipeline-notifications` or `dbx-ai-ml-testing-pipeline-notifications-{language}` that would mask other

langchain-python/run.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pip install uv rust-just
2222

2323
just install
2424

25-
export MONGODB_URI=$MONGODB_URI
26-
export OPENAI_API_KEY=$OPENAI_API_KEY
27-
28-
just tests
25+
just unit_tests
2926

3027
just integration_tests

langchaingo-golang/run.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ cd vectorstores/mongovector
99
export PATH="$PATH:/opt/golang/$GO_VERSION/bin"
1010
export GOROOT="/opt/golang/$GO_VERSION"
1111

12-
go test -v -failfast -race -shuffle=on
12+
# TODO(GODRIVER-3606): Update expected error in LangChainGo test for
13+
# non-tokenized filter.
14+
go test -v -failfast -race -shuffle=on \
15+
-skip "TestStore_SimilaritySearch_NonExactQuery/with_non-tokenized_filter"

langgraph-python/run.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pip install uv rust-just
2222

2323
just install
2424

25-
export MONGODB_URI=$MONGODB_URI
26-
export OPENAI_API_KEY=$OPENAI_API_KEY
27-
28-
just tests
25+
just unit_tests
2926

3027
just integration_tests

0 commit comments

Comments
 (0)