Skip to content

Commit 16ec3d5

Browse files
authored
PYTHON-5389: Add Tags to each buildvariant and augment test skipping/tracking policy. (#82)
1 parent 0dc8e97 commit 16ec3d5

File tree

5 files changed

+156
-11
lines changed

5 files changed

+156
-11
lines changed

.evergreen/config.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ tasks:
292292
buildvariants:
293293
- name: test-semantic-kernel-python-rhel
294294
display_name: Semantic-Kernel RHEL Python
295+
tags: [python]
295296
expansions:
296297
DIR: semantic-kernel-python
297298
run_on:
@@ -304,6 +305,7 @@ buildvariants:
304305

305306
- name: test-semantic-kernel-csharp-rhel
306307
display_name: Semantic-Kernel RHEL CSharp
308+
tags: [csharp]
307309
expansions:
308310
DIR: semantic-kernel-csharp
309311
run_on:
@@ -314,6 +316,7 @@ buildvariants:
314316

315317
- name: test-langchain-python-rhel
316318
display_name: Langchain RHEL Python
319+
tags: [python]
317320
expansions:
318321
DIR: langchain-python
319322
run_on:
@@ -325,6 +328,7 @@ buildvariants:
325328

326329
- name: test-langgraph-python-rhel
327330
display_name: Langgraph RHEL Python
331+
tags: [python]
328332
expansions:
329333
DIR: langgraph-python
330334
run_on:
@@ -335,8 +339,9 @@ buildvariants:
335339
batchtime: 10080 # 1 week
336340

337341
# TODO: INTPYTHON-668
338-
# - name: test-chatgpt-retrieval-plugin-rhel
342+
# - name: test-chatgpt-retrieval-plugin-python-rhel
339343
# display_name: ChatGPT Retrieval Plugin
344+
# tags: [python]
340345
# expansions:
341346
# DIR: chatgpt-retrieval-plugin
342347
# run_on:
@@ -347,8 +352,9 @@ buildvariants:
347352
# batchtime: 10080 # 1 week
348353

349354
# TODO: INTPYTHON-669
350-
# - name: test-llama-index-vectorstore-rhel
355+
# - name: test-llama-index-vectorstore-python-rhel
351356
# display_name: LlamaIndex RHEL Vector Store
357+
# tags: [python]
352358
# expansions:
353359
# DIR: llama-index-python-vectorstore
354360
# run_on:
@@ -359,8 +365,9 @@ buildvariants:
359365
# # - name: test-llama-index-remote
360366
# # batchtime: 10080 # 1 week
361367

362-
- name: test-docarray-rhel
368+
- name: test-docarray-python-rhel
363369
display_name: DocArray RHEL
370+
tags: [python]
364371
expansions:
365372
DIR: docarray
366373
run_on:
@@ -369,8 +376,9 @@ buildvariants:
369376
- name: test-docarray-local
370377
- name: test-docarray-remote
371378

372-
- name: test-pymongo-voyageai-rhel
379+
- name: test-pymongo-voyageai-python-rhel
373380
display_name: PyMongo-VoyageAI RHEL
381+
tags: [python]
374382
expansions:
375383
DIR: pymongo-voyageai
376384
run_on:
@@ -379,8 +387,9 @@ buildvariants:
379387
- name: test-pymongo-voyageai-local
380388
- name: test-pymongo-voyageai-remote
381389

382-
- name: test-crewai-tools-rhel
390+
- name: test-crewai-tools-python-rhel
383391
display_name: CrewAI-Tools Ubuntu
392+
tags: [python]
384393
expansions:
385394
DIR: crewai-tools
386395
run_on:
@@ -389,8 +398,9 @@ buildvariants:
389398
- name: test-crewai-tools-local
390399
- name: test-crewai-tools-remote
391400

392-
- name: test-haystack-embeddings-rhel
401+
- name: test-haystack-embeddings-python-rhel
393402
display_name: Haystack Embeddings RHEL
403+
tags: [python]
394404
expansions:
395405
DIR: haystack-embeddings
396406
run_on:
@@ -400,8 +410,9 @@ buildvariants:
400410
# TODO: INTPYTHON-465
401411
# - name: test-haystack-embeddings-remote
402412

403-
- name: test-haystack-fulltext-rhel
413+
- name: test-haystack-fulltext-python-rhel
404414
display_name: Haystack FullText RHEL
415+
tags: [python]
405416
expansions:
406417
DIR: haystack-fulltext
407418
run_on:
@@ -411,8 +422,9 @@ buildvariants:
411422
# TODO: INTPYTHON-465
412423
# - name: test-haystack-fulltext-remote
413424

414-
- name: test-langchaingo-ubuntu
425+
- name: test-langchaingo-golang-ubuntu
415426
display_name: LangchainGo Ubuntu2204
427+
tags: [golang]
416428
expansions:
417429
DIR: langchaingo-golang
418430
run_on:
@@ -423,6 +435,7 @@ buildvariants:
423435
# TODO: INTPYTHON-667
424436
# - name: test-langchain-js-ubuntu
425437
# display_name: LangchainJS Ubuntu2204
438+
# tags: [javascript]
426439
# expansions:
427440
# DIR: langchain-js
428441
# run_on:
@@ -433,6 +446,7 @@ buildvariants:
433446

434447
- name: test-mem0-python-rhel
435448
display_name: mem0 RHEL Python
449+
tags: [python]
436450
expansions:
437451
DIR: mem0-python
438452
run_on:

.evergreen/lint_config.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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_buildvariants(data: Dict[Any, Any]) -> List[str]:
29+
"""
30+
Check if buildvariant tasks contain at least one required language tag
31+
as well as the language within the buildvariant name.
32+
33+
Example Buildvariant structure in YAML:
34+
buildvariants:
35+
- name: test-semantic-kernel-python-rhel
36+
display_name: Semantic-Kernel RHEL Python
37+
tags: [python]
38+
expansions:
39+
DIR: semantic-kernel-python
40+
run_on:
41+
- rhel87-small
42+
tasks:
43+
- name: test-semantic-kernel-python-local
44+
- name: test-semantic-kernel-python-remote
45+
batchtime: 10080 # 1 week
46+
47+
Args:
48+
data: Parsed YAML data
49+
50+
Returns:
51+
List of error messages for tasks missing required tags
52+
"""
53+
errors = []
54+
55+
buildvariants = data.get("buildvariants", [])
56+
if not isinstance(buildvariants, list):
57+
return ["'buildvariants' should be a list"]
58+
59+
for i, buildvariant in enumerate(buildvariants):
60+
if not isinstance(buildvariant, dict):
61+
errors.append(f"buildvariants[{i}] should contain sub-fields")
62+
continue
63+
64+
buildvariant_name = buildvariant.get("name", "")
65+
if not buildvariant_name:
66+
errors.append(f"buildvariants[{i}] is missing 'name'")
67+
continue
68+
else:
69+
if all([f"-{lang}-" not in buildvariant_name for lang in VALID_LANGUAGES]):
70+
errors.append(
71+
f"buildvariant '{buildvariant_name}' should contain one"
72+
f" '-[{', '.join(VALID_LANGUAGES)}]-' in its name"
73+
f"got: {buildvariant_name}",
74+
)
75+
76+
buildvariant_display_name = buildvariant.get("display_name", buildvariant_name)
77+
78+
tags = buildvariant.get("tags", [])
79+
80+
if not isinstance(tags, list) or len(tags) != 1:
81+
errors.append(
82+
f"'tags' in buildvariant '{buildvariant_display_name}' should be a list of size 1"
83+
)
84+
continue
85+
86+
if tags[0] not in VALID_LANGUAGES:
87+
errors.append(
88+
f"buildvariant '{buildvariant_display_name}' has invalid tag '{tags[0]}'. "
89+
f"Valid tags are: {', '.join(VALID_LANGUAGES)}"
90+
)
91+
return errors
92+
93+
94+
def main():
95+
"""Main function for the pre-commit hook."""
96+
total_errors = 0
97+
98+
data = load_yaml_file(CONFIG_YML)
99+
if not data:
100+
raise FileNotFoundError(f"Failed to load or parse {CONFIG_YML}")
101+
102+
errors = check_buildvariants(data)
103+
104+
if errors:
105+
logger.error("❌ Errors found in %s:", CONFIG_YML)
106+
for error in errors:
107+
logger.error(" - %s", error)
108+
total_errors += len(errors)
109+
110+
if total_errors > 0:
111+
logger.error("❌ Total errors found: %s", total_errors)
112+
return 1
113+
else:
114+
logger.info("✅ %s passed AI/ML testing pipeline validation", CONFIG_YML)
115+
116+
117+
if __name__ == "__main__":
118+
sys.exit(main())

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
python-version: '3.10'
2424
- name: Install Python dependencies
2525
run: |
26-
python -m pip install -U pip pre-commit
26+
python -m pip install -U pip pre-commit pyyaml
2727
- name: Run linters
2828
run: |
2929
pre-commit run --hook-stage=manual --all-files

.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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ Test execution flow is defined in `.evergreen/config.yml`. The test pipeline's c
110110
- `run_on` -- Specified platform to run on. `rhel87-small` or `ubuntu2204-small` should be used by default. Any other distro may fail Atlas CLI setup.
111111
- `tasks` -- Tasks to run. See below for more details
112112
- `cron` -- The tests are run via a cron job on a nightly cadence. This can be modified by setting a different cadence. Cron jobs can be scheduled using [cron syntax](https://crontab.guru/#0_0_*_*_*)
113+
- `tags` -- This should include the language where the AI/ML is run. i.e. `[python, csharp, golang, javascript]` Any tagged language will populate the
114+
appropriate language-specific slack channel.
113115

114116
**[Tasks](https://docs.devprod.prod.corp.mongodb.com/evergreen/Project-Configuration/Project-Configuration-Files#tasks)** -- These are the "building blocks" of our runs. Here is where we consolidate the specific set of functions. The basic parameters to add are shown below
115117

@@ -185,8 +187,10 @@ evergreen patch -p ai-ml-pipeline-testing --param REPO_ORG=caseyclements --param
185187

186188
### Handling Failing Tests
187189

188-
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
190+
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`).
191+
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
189193
in the `config.yml` file, with a comment about the JIRA ticket that will address it.
190194

191-
This policy will help ensure that a single failing integration does not cause noise in the `dbx-ai-ml-testing-pipeline-notifications` that would mask other
195+
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
192196
failures.

0 commit comments

Comments
 (0)