Welcome to the Emission Tracking Toolkit! This project is designed to utilize a variety of tools to measure and analyze the output of different emission tracking experiments.
/docs: Contains the documentation for each tool (e.g.,carbontracker_docs.md)./logs: Stores logs such as API timeshift logs and project logs./output: The directory where tool outputs are saved (e.g.,carbontracker,cloud_carbon_footprint)./test_cases: Contains different project codes to be tested (e.g.,face_masking)./tools: Holds the scripts for each tool (e.g.,carbontracker_tool.py).run_tests.py: The main script to run test cases for all tools or an individual tool.config.json: Contains the configuration and descriptions for the projects.
For conda:
conda create --name emission_env python=3.8
conda activate emission_envFor python virtualenv:
python -m venv emission_env
source emission_env/bin/activate # On Windows use `emission_env\Scripts\activate`After activating the environment, install the required packages using:
pip install -r requirements.txt--tool: Specifies the tool(s) to test. This parameter is versatile and accepts several formats:- A single tool name to run a specific tool.
- Multiple tool names separated by spaces to run a selection of tools.
- The keyword
allto run all available tools in the toolkit.
To run a test case using run_tests.py, you can execute the script with the following command:
python run_tests.py --tool <tool_name> # ex: "python run_tests.py --tool all"
python run_tests.py --tool <tool_name> # ex: "python run_tests.py --tool codecarbon"
python run_tests.py --tool <tool_name> # ex: python run_tests.py --tool codecarbon carbontrackerIf you wish to add a new experiment tool to the toolkit, please follow these steps:
-
Tool Script:
- Place your tool's script in the
/toolsdirectory. - Name the file in a consistent manner, e.g.,
<newtool>_tool.py.
- Place your tool's script in the
-
Test Case:
- Create a new folder within
/test_casesfor your tool's specific experiments. e.g.,new_tool_tests.
- Create a new folder within
-
Configuration:
- Add your project's configuration to
config.jsonfollowing the existing structure. Read below for more information.
- Add your project's configuration to
-
Documentation:
- Write a Markdown documentation file for your tool.
- Place the documentation in
/docswith a name like<newtool>_docs.md.
-
Output Directory:
- Ensure your tool script saves its output to the correct folder under
/output.
- Ensure your tool script saves its output to the correct folder under
The run_tests.py script is the entry point for running test cases across different tools in the Emission Tracking Toolkit. This script allows for executing individual tools or a suite of tools to assess their performance and output.
Before running the script, ensure that:
- The virtual environment is activated.
- All dependencies are installed via
requirements.txt. - The
config.jsonfile is properly configured with your test cases and tools.
To add a new test case:
- Place the test script in the
/test_casesdirectory. - Update the
config.jsonfile to include the path to the new test script. - Ensure the new test case is compatible with the expected input and output structure defined by the toolkit.
The script will execute the specified test cases and generate logs and output files in their respective directories as configured in config.json.
For detailed logs, refer to the /logs directory after running the test cases.
The config.json file is an essential part of the Emission Tracking Toolkit. It centralizes the configuration for various aspects of the project.
The config.json file is structured as follows:
test_cases: An array of strings specifying paths to test case scripts.tools: An object with keys representing tool names and values being settings specific to that tool.log_file: A string indicating the path to the project's log file.
Here is a brief example showing part of the structure:
{
"test_cases": ["test_cases/api_test_timeshift_script.py","testcases/facemasking/main.py"],
"tools": {
"codecarbon": {
"output_path": "output/codecarbon",
"measurement_interval": 2
},
"carbontracker": {
"output_path": "output/carbontracker"
}
// Additional tool configurations would be placed here
},
"log_file": "logs/project_log.log"
}To customize the toolkit, you can modify the config.json file. Add new test cases or tool configurations as needed, ensuring that the file maintains valid JSON syntax.
We welcome contributions to the Emission Tracking Toolkit. If you have suggestions or improvements, please follow the standard Github fork and pull request workflow.
If you encounter any issues or have questions, please file an issue on the project's GitHub repository.
Thank you for participating in our emission tracking efforts!