|
14 | 14 | import random
|
15 | 15 | from sagemaker.experiments._metrics import _MetricsManager
|
16 | 16 | from sagemaker.experiments.trial_component import _TrialComponent
|
| 17 | +import time |
17 | 18 |
|
18 | 19 |
|
19 |
| -def test_epoch(trial_component_obj, sagemaker_session): |
| 20 | +def test_end_to_end(trial_component_obj, sagemaker_session): |
20 | 21 | # The fixture creates deletes, just ensure fixture is used at least once
|
21 |
| - metric_name = "test-x-step" |
22 | 22 | with _MetricsManager(trial_component_obj.trial_component_arn, sagemaker_session) as mm:
|
23 | 23 | for i in range(100):
|
24 |
| - mm.log_metric(metric_name, random.random(), step=i) |
| 24 | + mm.log_metric("test-x-step", random.random(), step=i) |
| 25 | + mm.log_metric("test-x-timestamp", random.random()) |
25 | 26 |
|
26 |
| - updated_tc = _TrialComponent.load( |
27 |
| - trial_component_name=trial_component_obj.trial_component_name, |
28 |
| - sagemaker_session=sagemaker_session, |
29 |
| - ) |
30 |
| - assert len(updated_tc.metrics) == 1 |
31 |
| - assert updated_tc.metrics[0].metric_name == metric_name |
32 |
| - |
33 |
| - |
34 |
| -def test_timestamp(trial_component_obj, sagemaker_session): |
35 |
| - # The fixture creates deletes, just ensure fixture is used at least once |
36 |
| - metric_name = "test-x-timestamp" |
37 |
| - with _MetricsManager(trial_component_obj.trial_component_arn, sagemaker_session) as mm: |
38 |
| - for i in range(100): |
39 |
| - mm.log_metric(metric_name, random.random()) |
| 27 | + # metrics -> eureka propagation |
| 28 | + time.sleep(3) |
40 | 29 |
|
41 | 30 | updated_tc = _TrialComponent.load(
|
42 | 31 | trial_component_name=trial_component_obj.trial_component_name,
|
43 | 32 | sagemaker_session=sagemaker_session,
|
44 | 33 | )
|
45 |
| - # the test-x-step data is added in the previous test_epoch test |
46 |
| - assert len(updated_tc.metrics) == 2 |
47 |
| - assert updated_tc.metrics[0].metric_name == "test-x-step" |
48 |
| - assert updated_tc.metrics[1].metric_name == "test-x-timestamp" |
| 34 | + metrics = updated_tc.metrics |
| 35 | + assert len(metrics) == 2 |
| 36 | + assert list(filter(lambda x: x.metric_name == "test-x-step", metrics)) |
| 37 | + assert list(filter(lambda x: x.metric_name == "test-x-timestamp", metrics)) |
0 commit comments