Skip to content

Commit a774d5b

Browse files
Add support for AsimovBot PR parser (#5172)
* Add support for AsimovBot PR parser * change pr template * Update PULL_REQUEST_TEMPLATE.md * Update PULL_REQUEST_TEMPLATE.md --------- Co-authored-by: Sirut Buasai <[email protected]>
1 parent 362173a commit a774d5b

File tree

5 files changed

+79
-67
lines changed

5 files changed

+79
-67
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
### Description
99

10-
### Tests run
11-
12-
**NOTE: By default, docker builds are disabled. In order to build your container, please update dlc_developer_config.toml and specify the framework to build in "build_frameworks"**
13-
- [ ] I have run builds/tests on commit <INSERT COMMIT ID> for my changes.
10+
### Tests Run
11+
By default, docker image builds and tests are disabled. Two ways to run builds and tests:
12+
1. Using dlc_developer_config.toml
13+
2. Using this PR description (currently only supported for PyTorch, TensorFlow, vllm, and base images)
1414

1515
<details>
16-
<summary>Confused on how to run tests? Try using the helper utility...</summary>
16+
<summary>How to use the helper utility for updating dlc_developer_config.toml</summary>
1717

1818
Assuming your remote is called `origin` (you can find out more with `git remote -v`)...
1919

@@ -28,50 +28,34 @@ Assuming your remote is called `origin` (you can find out more with `git remote
2828
- Restore TOML file when ready to merge
2929

3030
`python src/prepare_dlc_dev_environment.py -rcp origin`
31-
</details>
32-
33-
**NOTE: If you are creating a PR for a new framework version, please ensure success of the standard, rc, and efa sagemaker remote tests by updating the dlc_developer_config.toml file:**
34-
<details>
35-
<summary>Expand</summary>
3631

32+
**NOTE: If you are creating a PR for a new framework version, please ensure success of the local, standard, rc, and efa sagemaker tests by updating the dlc_developer_config.toml file:**
3733
- [ ] `sagemaker_remote_tests = true`
3834
- [ ] `sagemaker_efa_tests = true`
3935
- [ ] `sagemaker_rc_tests = true`
40-
41-
**Additionally, please run the sagemaker local tests in at least one revision:**
4236
- [ ] `sagemaker_local_tests = true`
43-
4437
</details>
4538

46-
### Formatting
47-
- [ ] I have run `black -l 100` on my code (formatting tool: https://black.readthedocs.io/en/stable/getting_started.html)
48-
49-
### DLC image/dockerfile
50-
51-
#### Builds to Execute
5239
<details>
53-
<summary>Expand</summary>
54-
55-
Fill out the template and click the checkbox of the builds you'd like to execute
56-
57-
*Note: Replace with <X.Y> with the major.minor framework version (i.e. 2.2) you would like to start.*
58-
59-
- [ ] build_pytorch_training_<X.Y>_sm
60-
- [ ] build_pytorch_training_<X.Y>_ec2
61-
62-
- [ ] build_pytorch_inference_<X.Y>_sm
63-
- [ ] build_pytorch_inference_<X.Y>_ec2
64-
- [ ] build_pytorch_inference_<X.Y>_graviton
40+
<summary>How to use PR description</summary>
41+
Use the code block below to uncomment commands and run the PR CodeBuild jobs. There are two commands available:
6542

66-
- [ ] build_tensorflow_training_<X.Y>_sm
67-
- [ ] build_tensorflow_training_<X.Y>_ec2
43+
- `# /buildspec <buildspec_path>`
44+
- e.g.: `# /buildspec pytorch/training/buildspec.yml`
45+
- If this line is commented out, dlc_developer_config.toml will be used.
46+
- `# /tests <test_list>`
47+
- e.g.: `# /tests sanity security ec2`
48+
- If this line is commented out, it will run the default set of tests (same as the defaults in dlc_developer_config.toml): `sanity, security, ec2, ecs, eks, sagemaker, sagemaker-local`.
6849

69-
- [ ] build_tensorflow_inference_<X.Y>_sm
70-
- [ ] build_tensorflow_inference_<X.Y>_ec2
71-
- [ ] build_tensorflow_inference_<X.Y>_graviton
7250
</details>
7351

74-
### Additional context
52+
```
53+
# /buildspec <buildspec_path>
54+
# /tests <test_list>
55+
```
56+
57+
### Formatting
58+
- [ ] I have run `black -l 100` on my code (formatting tool: https://black.readthedocs.io/en/stable/getting_started.html)
7559

7660
### PR Checklist
7761
<details>
@@ -84,14 +68,6 @@ Fill out the template and click the checkbox of the builds you'd like to execute
8468
- [ ] (If applicable) I've documented below the tests I've run on the DLC image
8569
- [ ] (If applicable) I've reviewed the licenses of updated and new binaries and their dependencies to make sure all licenses are on the Apache Software Foundation Third Party License Policy Category A or Category B license list. See [https://www.apache.org/legal/resolved.html](https://www.apache.org/legal/resolved.html).
8670
- [ ] (If applicable) I've scanned the updated and new binaries to make sure they do not have vulnerabilities associated with them.
87-
88-
#### NEURON/GRAVITON Testing Checklist
89-
* When creating a PR:
90-
- [ ] I've modified `dlc_developer_config.toml` in my PR branch by setting `neuron_mode = true` or `graviton_mode = true`
91-
92-
#### Benchmark Testing Checklist
93-
* When creating a PR:
94-
- [ ] I've modified `dlc_developer_config.toml` in my PR branch by setting `ec2_benchmark_tests = true` or `sagemaker_benchmark_tests = true`
9571
</details>
9672

9773
### Pytest Marker Checklist

src/main.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ def main():
4040
# this build.
4141
utils.write_to_json_file(constants.TEST_TYPE_IMAGES_PATH, {})
4242

43-
# Skip tensorflow-1 PR jobs, as there are no longer patch releases being added for TF1
44-
# Purposefully not including this in developer config to make this difficult to enable
45-
# TODO: Remove when we remove these jobs completely
46-
build_name = get_codebuild_project_name()
47-
if build_context == "PR" and build_name == "dlc-pr-tensorflow-1":
43+
# Only bypass TOML checks if buildspec comes from PR description
44+
if os.getenv("FRAMEWORK_BUILDSPEC_FILE") and os.getenv("FROM_PR_DESCRIPTION") == "true":
45+
utils.build_setup(
46+
args.framework,
47+
device_types=device_types,
48+
image_types=image_types,
49+
py_versions=py_versions,
50+
)
51+
image_builder(args.buildspec, image_types, device_types)
4852
return
4953

5054
# A general build will work if build job and build mode are in non-EI, non-NEURON

src/start_testbuilds.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def run_test_job(commit, codebuild_project, images_str=""):
5757
if config.is_deep_canary_mode_enabled():
5858
env_overrides.append({"name": "DEEP_CANARY_MODE", "value": "true", "type": "PLAINTEXT"})
5959

60+
# Get specified tests from PR description if any
61+
specified_tests = os.getenv("SPECIFIED_TESTS")
62+
if specified_tests:
63+
env_overrides.append(
64+
{"name": "SPECIFIED_TESTS", "value": specified_tests, "type": "PLAINTEXT"}
65+
)
66+
6067
pr_num = os.getenv("PR_NUMBER")
6168
LOGGER.debug(f"pr_num {pr_num}")
6269
env_overrides.extend(
@@ -248,17 +255,29 @@ def main():
248255
# Deep Canaries, as detailed in the docstring for run_deep_canary_pr_testbuilds().
249256
return
250257

251-
# load the images for all test_types to pass on to code build jobs
258+
# Load the test types to images mapping
252259
with open(constants.TEST_TYPE_IMAGES_PATH) as json_file:
253260
test_images = json.load(json_file)
254261

255262
# Run necessary PR test jobs
256263
commit = os.getenv("CODEBUILD_RESOLVED_SOURCE_VERSION")
257264

265+
specified_tests_env = os.getenv("SPECIFIED_TESTS")
266+
if specified_tests_env:
267+
specified_tests = specified_tests_env.split()
268+
LOGGER.info(f"Running only specified tests from PR description: {specified_tests}")
269+
else:
270+
specified_tests = None
271+
258272
for test_type, images in test_images.items():
259-
# only run the code build test jobs when the images are present
273+
# Skip any test_type not explicitly requested
274+
if specified_tests and test_type not in specified_tests:
275+
LOGGER.info(f"Skipping {test_type} test because it wasn’t in SPECIFIED_TESTS")
276+
continue
277+
260278
LOGGER.debug(f"test_type : {test_type}")
261279
LOGGER.debug(f"images: {images}")
280+
# Only run the CodeBuild test jobs when images are present
262281
if images:
263282
pr_test_job = f"dlc-pr-{test_type}-test"
264283
images_str = " ".join(images)
@@ -275,11 +294,12 @@ def main():
275294
):
276295
run_test_job(commit, pr_test_job, images_str)
277296

278-
if test_type == "autopr" and config.is_autopatch_build_enabled(
279-
buildspec_path=config.get_buildspec_override()
280-
or os.getenv("FRAMEWORK_BUILDSPEC_FILE"),
281-
):
282-
run_test_job(commit, f"dlc-pr-{test_type}", images_str)
297+
# autopr is disabled
298+
# if test_type == "autopr" and config.is_autopatch_build_enabled(
299+
# buildspec_path=config.get_buildspec_override()
300+
# or os.getenv("FRAMEWORK_BUILDSPEC_FILE"),
301+
# ):
302+
# run_test_job(commit, f"dlc-pr-{test_type}", images_str)
283303

284304
# Trigger sagemaker local test jobs when there are changes in sagemaker_tests
285305
if test_type == "sagemaker" and config.is_sm_local_test_enabled():

src/utils.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -462,16 +462,20 @@ def upload_data_to_pr_creation_s3_bucket(upload_data: str, s3_filepath: str, tag
462462
:param tag_set: List[Dict], as described above
463463
:return: str, s3 file path
464464
"""
465-
s3_resource = boto3.resource("s3")
466-
s3object = s3_resource.Object(constants.PR_CREATION_DATA_HELPER_BUCKET, s3_filepath)
467-
s3_client = s3_resource.meta.client
468-
s3object.put(Body=(bytes(upload_data.encode("UTF-8"))))
469-
if tag_set:
470-
s3_client.put_object_tagging(
471-
Bucket=constants.PR_CREATION_DATA_HELPER_BUCKET,
472-
Key=s3_filepath,
473-
Tagging={"TagSet": tag_set},
474-
)
465+
s3 = boto3.resource("s3")
466+
bucket = constants.PR_CREATION_DATA_HELPER_BUCKET
467+
obj = s3.Object(bucket, s3_filepath)
468+
client = s3.meta.client
469+
try:
470+
obj.put(Body=upload_data.encode("utf-8"))
471+
if tag_set:
472+
client.put_object_tagging(
473+
Bucket=bucket,
474+
Key=s3_filepath,
475+
Tagging={"TagSet": tag_set},
476+
)
477+
except ClientError as e:
478+
LOGGER.info(f"Could not write to s3://{bucket}/{s3_filepath}: {e}")
475479

476480

477481
def get_unique_s3_path_for_uploading_data_to_pr_creation_bucket(image_uri: str, file_name: str):

test/testrunner.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ def main():
441441
else:
442442
raise Exception(f"EKS cluster {eks_cluster_name} is not in active state")
443443

444+
# Get specified tests if any
445+
specified_tests = os.getenv("SPECIFIED_TESTS")
446+
if specified_tests:
447+
specified_tests = specified_tests.split()
448+
444449
# Execute dlc_tests pytest command
445450
pytest_cmd = [
446451
"-s",
@@ -449,6 +454,9 @@ def main():
449454
f"--junitxml={report}",
450455
"-n=auto",
451456
]
457+
if specified_tests:
458+
test_expr = " or ".join(f"test_{t}" for t in specified_tests)
459+
pytest_cmd.extend(["-k", f"({test_expr})"])
452460

453461
is_habana_image = any("habana" in image_uri for image_uri in all_image_list)
454462
if specific_test_type == "ec2":

0 commit comments

Comments
 (0)