Spaces:
Sleeping
Sleeping
Delete emissions.py
Browse files- emissions.py +0 -28
emissions.py
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
from codecarbon import EmissionsTracker
|
2 |
-
import os
|
3 |
-
|
4 |
-
# Initialize tracker
|
5 |
-
tracker = EmissionsTracker(allow_multiple_runs=True)
|
6 |
-
|
7 |
-
class EmissionsData:
|
8 |
-
def __init__(self, energy_consumed: float, emissions: float):
|
9 |
-
self.energy_consumed = energy_consumed
|
10 |
-
self.emissions = emissions
|
11 |
-
|
12 |
-
def clean_emissions_data(emissions_data):
|
13 |
-
"""Remove unwanted fields from emissions data"""
|
14 |
-
data_dict = emissions_data.__dict__
|
15 |
-
fields_to_remove = ['timestamp', 'project_name', 'experiment_id', 'latitude', 'longitude']
|
16 |
-
return {k: v for k, v in data_dict.items() if k not in fields_to_remove}
|
17 |
-
|
18 |
-
def get_space_info():
|
19 |
-
"""Get the space username and URL from environment variables"""
|
20 |
-
space_name = os.getenv("SPACE_ID", "")
|
21 |
-
if space_name:
|
22 |
-
try:
|
23 |
-
username = space_name.split("/")[0]
|
24 |
-
space_url = f"https://huggingface.co/spaces/{space_name}"
|
25 |
-
return username, space_url
|
26 |
-
except Exception as e:
|
27 |
-
print(f"Error getting space info: {e}")
|
28 |
-
return "local-user", "local-development"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|