Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /mlco2_codecarbon /examples /prometheus_call.py
| import logging | |
| import time | |
| from codecarbon import track_emissions | |
| from codecarbon.external.logger import logger | |
| def train_model(): | |
| """ | |
| This function will do nothing during (occurrence * delay) seconds. | |
| The Code Carbon API will be called every (measure_power_secs * api_call_interval) seconds. | |
| """ | |
| occurrence = 60 * 24 * 365 * 100 # Run for 100 years! | |
| delay = 60 # Seconds | |
| for i in range(occurrence): | |
| print(f"{occurrence * delay - i * delay} seconds before ending script...") | |
| time.sleep(delay) | |
| if __name__ == "__main__": | |
| logger.setLevel(logging.DEBUG) | |
| # create a file handler which logs even debug messages | |
| fh = logging.FileHandler("codecarbon.log") | |
| fh.setLevel(logging.DEBUG) | |
| formatter = logging.Formatter( | |
| "%(asctime)s - %(name)-12s: %(levelname)-8s %(message)s" | |
| ) | |
| fh.setFormatter(formatter) | |
| logger.addHandler(fh) | |
| logger.debug("GO!") | |
| model = train_model() | |
| logger.debug("THE END!") | |
Xet Storage Details
- Size:
- 1.09 kB
- Xet hash:
- a2b89feb8a7b885734e5dc12512cb309a9be18b47db6a044c1e2f6520632e0ea
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.