(self)
| 59 | self.assertIsNone(api.run_id) |
| 60 | |
| 61 | def test_call_api(self): |
| 62 | with requests_mock.Mocker() as m: |
| 63 | m.post( |
| 64 | "http://test.com/runs", |
| 65 | json={ |
| 66 | "id": "82ba0923-0713-4da1-9e57-cea70b460ee9", |
| 67 | "timestamp": "2021-04-04T08:43:00+02:00", |
| 68 | "experiment_id": "8edb03e1-9a28-452a-9c93-a3b6560136d7", |
| 69 | "os": "macOS-10.15.7-x86_64-i386-64bit", |
| 70 | "python_version": "3.8.0", |
| 71 | "codecarbon_version": "2.1.3", |
| 72 | "cpu_count": 12, |
| 73 | "cpu_model": "Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz", |
| 74 | "gpu_count": 4, |
| 75 | "gpu_model": "NVIDIA", |
| 76 | "longitude": -7.6174, |
| 77 | "latitude": 33.5822, |
| 78 | "region": "EUROPE", |
| 79 | "provider": "AWS", |
| 80 | "ram_total_size": 83948.22, |
| 81 | "tracking_mode": "Machine", |
| 82 | }, |
| 83 | status_code=201, |
| 84 | ) |
| 85 | api = ApiClient( |
| 86 | experiment_id="experiment_id", |
| 87 | endpoint_url="http://test.com", |
| 88 | api_key="Toto", |
| 89 | conf=conf, |
| 90 | ) |
| 91 | assert api.run_id == "82ba0923-0713-4da1-9e57-cea70b460ee9" |
| 92 | |
| 93 | with requests_mock.Mocker() as m: |
| 94 | m.post("http://test.com/emissions", status_code=201) |
| 95 | carbon_emission = EmissionsData( |
| 96 | timestamp="222", |
| 97 | project_name="", |
| 98 | run_id=uuid4(), |
| 99 | experiment_id="test", |
| 100 | duration=1.5, |
| 101 | emissions=2.0, |
| 102 | emissions_rate=2.0, |
| 103 | cpu_energy=2, |
| 104 | gpu_energy=0, |
| 105 | ram_energy=1, |
| 106 | cpu_power=3.0, |
| 107 | gpu_power=0, |
| 108 | ram_power=0.15, |
| 109 | energy_consumed=3.0, |
| 110 | water_consumed=0.0, |
| 111 | country_name="Groland", |
| 112 | country_iso_code="GRD", |
| 113 | region="EU", |
| 114 | on_cloud="N", |
| 115 | cloud_provider="", |
| 116 | cloud_region="", |
| 117 | os="Linux", |
| 118 | python_version="3.8.0", |
nothing calls this directly
no test coverage detected