Skip to content

Commit 32b1af8

Browse files
authored
[fix] Fix warnings in tests. (#1)
* Fix warnings. * Skip perf test for CI Signed-off-by: Rashid Kaleem <230885705+arekay-nv@users.noreply.github.com>
1 parent 0e906c6 commit 32b1af8

9 files changed

Lines changed: 227 additions & 220 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These owners will be the default owners for everything in the repo.
22
# Unless a later match takes precedence,they will be requested for review when someone opens a pull request.
3-
* @mlcommons/endpoints-developers
3+
* @mlcommons/endpoints-developers
44

55
/.github/CODEOWNERS @mlcommons/systems
66

.github/workflows/cla.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
21
name: "cla-bot"
32
on:
43
issue_comment:
54
types: [created]
65
pull_request_target:
7-
types: [opened,closed,synchronize]
6+
types: [opened, closed, synchronize]
87

98
jobs:
109
cla-check:
@@ -17,16 +16,16 @@ jobs:
1716
env:
1817
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1918
# the below token should have repo scope and must be manually added by you in the repository's secret
20-
PERSONAL_ACCESS_TOKEN : ${{ secrets.MLCOMMONS_BOT_CLA_TOKEN }}
19+
PERSONAL_ACCESS_TOKEN: ${{ secrets.MLCOMMONS_BOT_CLA_TOKEN }}
2120
with:
22-
path-to-signatures: 'cla-bot/v1/cla.json'
21+
path-to-signatures: "cla-bot/v1/cla.json"
2322
# branch should not be protected
24-
branch: 'main'
23+
branch: "main"
2524
allowlist: user1,bot*
2625
remote-organization-name: mlcommons
2726
remote-repository-name: systems
28-
29-
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
27+
28+
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
3029
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
3130
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
3231
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25+
pip install -e .
2526
pip install pre-commit
2627
2728
- name: Run pre-commit

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
3030
- name: Run tests
3131
run: |
32-
pytest -xv -m "not slow" --cov=src --cov-report=xml --cov-report=html
32+
pytest -xv -m "not slow and not performance" --cov=src --cov-report=xml --cov-report=html
3333
3434
- name: Upload coverage to Codecov
3535
uses: codecov/codecov-action@v3

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Contributing
22

3-
The best way to contribute to the MLCommons is to get involved with one of our many project communities. You can find more information about getting involved with MLCommons [here](https://mlcommons.org/community/).
3+
The best way to contribute to the MLCommons is to get involved with one of our many project communities. You can find more information about getting involved with MLCommons [here](https://mlcommons.org/community/).
44

55
Generally we encourage people to become MLCommons members if they wish to contribute to MLCommons projects, but outside pull requests are very welcome too.
66

LICENSE.md

Lines changed: 172 additions & 173 deletions
Large diffs are not rendered by default.

src/inference_endpoint/load_generator/session.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,39 @@ def _run_test(
6767
tokenizer_override: AutoTokenizer | None = None,
6868
):
6969
with self.event_recorder:
70-
EventRecorder.record_event(SessionEvent.TEST_STARTED, time.monotonic_ns())
71-
for issued_sample in load_generator:
72-
# In the future, we'll want to push this to some thread or process that
73-
# performs output verification / accuracy checks.
74-
self.sample_uuid_map[issued_sample.sample.uuid] = issued_sample
75-
76-
self.event_recorder.should_check_idle = True
77-
EventRecorder.record_event(SessionEvent.LOADGEN_STOP, time.monotonic_ns())
78-
start_time = time.monotonic()
79-
while self.event_recorder.n_inflight_samples != 0:
80-
if (
81-
max_shutdown_timeout_s is not None
82-
and time.monotonic() - start_time > max_shutdown_timeout_s
83-
):
84-
raise TimeoutError(
85-
f"Max shutdown timeout of {max_shutdown_timeout_s}s reached"
86-
)
87-
self.end_event.wait(timeout=10.0)
88-
self.logger.info(
89-
f"Waiting for the test to end... {self.event_recorder.n_inflight_samples} samples remaining"
70+
try:
71+
EventRecorder.record_event(
72+
SessionEvent.TEST_STARTED, time.monotonic_ns()
9073
)
91-
92-
if stop_sample_issuer_on_test_end:
93-
load_generator.sample_issuer.shutdown()
94-
EventRecorder.record_event(SessionEvent.TEST_ENDED, time.monotonic_ns())
74+
for issued_sample in load_generator:
75+
# In the future, we'll want to push this to some thread or process that
76+
# performs output verification / accuracy checks.
77+
self.sample_uuid_map[issued_sample.sample.uuid] = issued_sample
78+
79+
self.event_recorder.should_check_idle = True
80+
EventRecorder.record_event(
81+
SessionEvent.LOADGEN_STOP, time.monotonic_ns()
82+
)
83+
start_time = time.monotonic()
84+
while self.event_recorder.n_inflight_samples != 0:
85+
if (
86+
max_shutdown_timeout_s is not None
87+
and time.monotonic() - start_time > max_shutdown_timeout_s
88+
):
89+
raise TimeoutError(
90+
f"Max shutdown timeout of {max_shutdown_timeout_s}s reached"
91+
)
92+
self.end_event.wait(timeout=10.0)
93+
self.logger.info(
94+
f"Waiting for the test to end... {self.event_recorder.n_inflight_samples} samples remaining"
95+
)
96+
except Exception as e:
97+
logger.error(f"Error running benchmark session: {e}")
98+
raise e
99+
finally:
100+
if stop_sample_issuer_on_test_end:
101+
load_generator.sample_issuer.shutdown()
102+
EventRecorder.record_event(SessionEvent.TEST_ENDED, time.monotonic_ns())
95103

96104
self.event_recorder.wait_for_writes()
97105

tests/unit/config/test_schema.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
OSLDistribution,
2525
OSLDistributionType,
2626
SubmissionReference,
27-
TestType,
2827
)
28+
from inference_endpoint.config.schema import TestType as BenchmarkTestType
2929

3030

3131
class TestOSLDistribution:
@@ -105,19 +105,19 @@ def test_minimal_config(self):
105105
"""Test minimal valid configuration."""
106106
config = BenchmarkConfig(
107107
name="test",
108-
type=TestType.OFFLINE,
108+
type=BenchmarkTestType.OFFLINE,
109109
datasets=[{"name": "test", "type": "performance", "path": "test.pkl"}],
110110
)
111111
assert config.name == "test"
112-
assert config.type == TestType.OFFLINE
112+
assert config.type == BenchmarkTestType.OFFLINE
113113
assert len(config.datasets) == 1
114114

115115
def test_submission_config(self):
116116
"""Test official submission configuration."""
117117
config = BenchmarkConfig(
118118
name="submission",
119119
version="1.0",
120-
type=TestType.SUBMISSION,
120+
type=BenchmarkTestType.SUBMISSION,
121121
submission_ref=SubmissionReference(
122122
model="llama-2-70b", ruleset="mlperf-inference-v6.0"
123123
),
@@ -146,7 +146,7 @@ def test_multiple_accuracy_datasets(self):
146146
"""Test config with multiple accuracy datasets."""
147147
config = BenchmarkConfig(
148148
name="multi-acc",
149-
type=TestType.SUBMISSION,
149+
type=BenchmarkTestType.SUBMISSION,
150150
datasets=[
151151
{
152152
"name": "gpqa",

tests/unit/config/test_yaml_loader.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
LoadPattern,
2626
LoadPatternType,
2727
Settings,
28-
TestType,
2928
)
29+
from inference_endpoint.config.schema import TestType as BenchmarkTestType
3030
from inference_endpoint.config.yaml_loader import ConfigError, ConfigLoader
3131

3232

@@ -69,7 +69,7 @@ def test_load_valid_yaml(self, tmp_path):
6969

7070
config = ConfigLoader.load_yaml(config_file)
7171
assert config.name == "test-config"
72-
assert config.type == TestType.OFFLINE
72+
assert config.type == BenchmarkTestType.OFFLINE
7373
assert len(config.datasets) == 1
7474

7575
def test_load_nonexistent_file(self):
@@ -87,15 +87,15 @@ def test_load_invalid_yaml(self, tmp_path):
8787

8888
def test_create_default_offline_config(self):
8989
"""Test creating default offline config."""
90-
config = BenchmarkConfig.create_default_config(TestType.OFFLINE)
90+
config = BenchmarkConfig.create_default_config(BenchmarkTestType.OFFLINE)
9191
assert isinstance(config, BenchmarkConfig)
9292
assert config.settings.load_pattern.type == LoadPatternType.MAX_THROUGHPUT
9393
assert config.settings.runtime.min_duration_ms == 600000
9494
assert config.settings.client.workers == 4
9595

9696
def test_create_default_online_config(self):
9797
"""Test creating default online config."""
98-
config = BenchmarkConfig.create_default_config(TestType.ONLINE)
98+
config = BenchmarkConfig.create_default_config(BenchmarkTestType.ONLINE)
9999
assert isinstance(config, BenchmarkConfig)
100100
assert config.settings.load_pattern.type == LoadPatternType.POISSON
101101
assert config.settings.load_pattern.target_qps == 10.0
@@ -104,7 +104,7 @@ def test_create_default_online_config(self):
104104
def test_serialize_deserialize_roundtrip(self, tmp_path):
105105
"""Test BenchmarkConfig.to_yaml_file() and from_yaml_file() roundtrip."""
106106
# Create a config
107-
original = BenchmarkConfig.create_default_config(TestType.OFFLINE)
107+
original = BenchmarkConfig.create_default_config(BenchmarkTestType.OFFLINE)
108108

109109
# Save to YAML
110110
yaml_file = tmp_path / "test_config.yaml"
@@ -122,7 +122,7 @@ def test_serialize_deserialize_roundtrip(self, tmp_path):
122122

123123
def test_to_yaml_file_creates_directory(self, tmp_path):
124124
"""Test that to_yaml_file creates parent directories."""
125-
config = BenchmarkConfig.create_default_config(TestType.ONLINE)
125+
config = BenchmarkConfig.create_default_config(BenchmarkTestType.ONLINE)
126126

127127
# Save to nested path that doesn't exist
128128
nested_path = tmp_path / "subdir" / "nested" / "config.yaml"
@@ -138,7 +138,7 @@ def test_validate_concurrency_error_when_insufficient(self):
138138
# Create a BenchmarkConfig with insufficient max_concurrency
139139
config = BenchmarkConfig(
140140
name="test",
141-
type=TestType.ONLINE,
141+
type=BenchmarkTestType.ONLINE,
142142
datasets=[],
143143
endpoint_config=EndpointConfig(endpoint="http://test:8000"),
144144
settings=Settings(
@@ -163,7 +163,7 @@ def test_validate_concurrency_sufficient(self):
163163
"""Test validation passes when max_concurrency >= target_concurrency."""
164164
config = BenchmarkConfig(
165165
name="test",
166-
type=TestType.ONLINE,
166+
type=BenchmarkTestType.ONLINE,
167167
datasets=[],
168168
endpoint_config=EndpointConfig(endpoint="http://test:8000"),
169169
settings=Settings(

0 commit comments

Comments
 (0)