Skip to content

Commit 8ec4617

Browse files
committed
Merge branch 'ko3n1g/ci/fixes-to-jet' into 'main'
tests: Minor improvements to JET See merge request ADLR/megatron-lm!2133
2 parents 08e80b0 + 643e60a commit 8ec4617

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

.gitlab/stages/02.functional-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ jet-generate:
4141
"--run-name"
4242
$FUNCTIONAL_TEST_NAME
4343
"--wandb-experiment"
44-
"test"
44+
$(echo $FUNCTIONAL_TEST_NAME | tr '/' '-')
4545
)
4646
else
4747
RELEASE_ARGS=()
4848
fi
4949
5050
- |
51+
export PYTHONPATH=$(pwd)
5152
python tests/functional_tests/python_test_utils/jet/generate_jet_trigger_job.py \
5253
--scope $FUNCTIONAL_TEST_SCOPE \
5354
--a100-cluster $A100_CLUSTER \

tests/functional_tests/python_test_utils/jet/common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,26 @@ def filter_by_scope(
8686
return workload_manifests
8787

8888

89+
def filter_by_model(
90+
workload_manifests: List[jetclient.JETWorkloadManifest], model: str
91+
) -> List[jetclient.JETWorkloadManifest]:
92+
"""Returns all workload with matching model."""
93+
workload_manifests = list(
94+
workload_manifest
95+
for workload_manifest in workload_manifests
96+
if workload_manifest.spec.model == model
97+
)
98+
99+
if len(workload_manifests) == 0:
100+
raise ValueError("No test_case found!")
101+
102+
return workload_manifests
103+
104+
89105
def load_workloads(
90106
container_tag: str,
91107
scope: Optional[str] = None,
108+
model: Optional[str] = None,
92109
test_case: Optional[str] = None,
93110
container_image: Optional[str] = None,
94111
) -> List[jetclient.JETWorkloadManifest]:
@@ -106,6 +123,9 @@ def load_workloads(
106123
if scope:
107124
workloads = filter_by_scope(workload_manifests=workloads, scope=scope)
108125

126+
if model:
127+
workloads = filter_by_model(workload_manifests=workloads, model=model)
128+
109129
if test_case:
110130
workloads = [filter_by_test_case(workload_manifests=workloads, test_case=test_case)]
111131

tests/functional_tests/python_test_utils/jet/generate_jet_trigger_job.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def main(
4747
raise ValueError(f"Platform {test_case.spec.platforms} unknown")
4848

4949
script = [
50+
"export PYTHONPATH=$(pwd); "
5051
"python tests/functional_tests/python_test_utils/jet/launch_jet_workload.py",
5152
f"--model {test_case.spec.model}",
5253
f"--test-case {test_case.spec.test_case}",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import pathlib
2+
from typing import Optional
3+
4+
import click
5+
import jetclient
6+
import yaml
7+
8+
from tests.functional_tests.python_test_utils.jet import common
9+
10+
11+
def load_script(config_path: str) -> str:
12+
with open(config_path) as stream:
13+
try:
14+
jetclient.JETWorkloadManifest(**yaml.safe_load(stream)).spec.script
15+
except yaml.YAMLError as exc:
16+
raise exc
17+
18+
19+
@click.command()
20+
@click.option("--model", required=False, type=str, help="Filters all tests by matching model")
21+
@click.option("--scope", required=False, type=str, help="Filters all tests by matching scope")
22+
@click.option(
23+
"--test-case", required=False, type=str, help="Returns a single test-case with matching name."
24+
)
25+
@click.option("--output-path", required=True, type=str, help="Path to write jobs to")
26+
def main(model: Optional[str], scope: Optional[str], test_case: Optional[str], output_path: str):
27+
workloads = common.load_workloads(
28+
container_image='none', scope=scope, model=model, test_case=test_case, container_tag='none'
29+
)
30+
31+
for workload in workloads:
32+
if workload.type == "build":
33+
continue
34+
magic_values = dict(workload.spec)
35+
magic_values["assets_dir"] = "."
36+
37+
file_path = (
38+
pathlib.Path(output_path)
39+
/ "test_cases"
40+
/ workload.spec.model
41+
/ f"{workload.spec.test_case}.sh"
42+
)
43+
file_path.parent.mkdir(parents=True, exist_ok=True)
44+
with open(file_path, "w", encoding="utf-8") as fh:
45+
fh.write(workload.spec.script.format(**magic_values))
46+
47+
48+
if __name__ == "__main__":
49+
main()

0 commit comments

Comments
 (0)