Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

test_system_stats.py 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  1. import pytest
  2. from wandb.stats import SystemStats
  3. from click.testing import CliRunner
  4. import wandb
  5. import json
  6. @pytest.fixture
  7. def api():
  8. return wandb.apis.InternalApi()
  9. @pytest.fixture
  10. def stats(api):
  11. with CliRunner().isolated_filesystem():
  12. run = wandb.wandb_run.Run.from_environment_or_defaults()
  13. yield SystemStats(run, api)
  14. def test_defaults(stats):
  15. stats.shutdown()
  16. print(stats.stats().keys())
  17. assert sorted(stats.stats().keys()) == sorted(
  18. ['cpu', 'memory', 'network', 'disk', 'proc.memory.rssMB', 'proc.memory.availableMB', 'proc.memory.percent', 'proc.cpu.threads'])
  19. assert stats.sample_rate_seconds == 2
  20. assert stats.samples_to_average == 15
  21. def test_dynamic(stats, api):
  22. api.dynamic_settings["system_sample_seconds"] = 1
  23. api.dynamic_settings["system_samples"] = 2
  24. assert stats.sample_rate_seconds == 1
  25. assert stats.samples_to_average == 2
  26. def test_min_max(stats, api):
  27. api.dynamic_settings["system_sample_seconds"] = 0.25
  28. api.dynamic_settings["system_samples"] = 300
  29. assert stats.sample_rate_seconds == 0.5
  30. assert stats.samples_to_average == 30
  31. api.dynamic_settings["system_samples"] = 1
  32. assert stats.samples_to_average == 2
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...