Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ By default, it's under `GreenAlgorithms4HPC/outputs/`, but this can be changed.
## Full list of options

```
usage: __init__.py [-h] [-S STARTDAY] [-E ENDDAY] [-o OUTPUT] [--outputDir OUTPUTDIR] [--filterCWD] [--filterJobIDs FILTERJOBIDS] [--filterAccount FILTERACCOUNT] [--customSuccessStates CUSTOMSUCCESSSTATES]
usage: myCarbonFootprint [-h] [-S STARTDAY] [-E ENDDAY] [-o OUTPUT] [--outputDir OUTPUTDIR] [--filterCWD] [--filterJobIDs FILTERJOBIDS] [--filterAccount FILTERACCOUNT] [--customSuccessStates CUSTOMSUCCESSSTATES]
[--reportBug | --reportBugHere] [--useCustomLogs USECUSTOMLOGS]

Calculate your carbon footprint on the server.
Expand Down Expand Up @@ -105,12 +105,12 @@ optional arguments:
2. Edit `myCarbonFootprint.sh` line 20 to create the virtual environment with Python 3.8 or later.
The default line is:
```bash
/usr/bin/python3.8 -m venv GA_env
/usr/bin/python3.8 -m venv .venv
```
But it may be something else on your server, for example:
```bash
module load python/3.11.7
python -m venv GA_env
python -m venv .venv
```

3. Make the bash script executable:
Expand Down
25 changes: 15 additions & 10 deletions __init__.py → greenalgorithms4HPC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import datetime
import os

from backend import main_backend
from frontend import main_frontend
from greenalgorithms4HPC.backend import main_backend
from greenalgorithms4HPC.frontend import main_frontend

SYSTEM_CONF="/etc/GreenAlgorithms4HPC.conf"
def create_arguments():
"""
Command line arguments for the tool.
Expand Down Expand Up @@ -108,17 +109,21 @@ def all(self, args):
self._validate_dates(args)
self._validate_output(args)

if __name__ == "__main__":
def main():
# print("Working dir0: ", os.getcwd()) # DEBUGONLY

args = create_arguments()

## Decide which infrastructure info to use
if args.useOtherInfrastuctureInfo != '':
args.path_infrastucture_info = args.useOtherInfrastuctureInfo
print(f"Overriding infrastructure info with: {args.path_infrastucture_info}")
else:
args.path_infrastucture_info = 'data'
# Load cluster specific info
cluster_config = os.environ.get("GA4HPC_CONFDIR", None)

if not cluster_config:
if os.path.exists(SYSTEM_CONF):
cluster_config = SYSTEM_CONF
else:
cluster_config = os.path.join(os.path.dirname(__file__), 'data')

args.path_infrastucture_info = cluster_config

## Organise the unique output directory (used for output report and logs export for debugging)
## creating a uniquely named subdirectory in whatever
Expand Down Expand Up @@ -149,5 +154,5 @@ def all(self, args):

### Run backend to get data
extracted_data = main_backend(args)
main_frontend(extracted_data, args)

main_frontend(extracted_data, args)
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pandas as pd
import numpy as np

from backend.helpers import check_empty_results, simulate_mock_jobs
from backend.slurm_extract import WorkloadManager
from greenalgorithms4HPC.backend.helpers import check_empty_results, simulate_mock_jobs
from greenalgorithms4HPC.backend.slurm_extract import WorkloadManager

# print("Working dir1: ", os.getcwd()) # DEBUGONLY

Expand Down Expand Up @@ -220,7 +220,7 @@ def main_backend(args):
print(exc)

### Load fixed parameters
with open("data/fixed_parameters.yaml", "r") as stream:
with open(os.path.join(args.path_infrastucture_info,"fixed_parameters.yaml"), "r") as stream:
try:
fParams = yaml.safe_load(stream)
except yaml.YAMLError as exc:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import yaml
import os

from frontend.terminal_output import generate_terminal_view
from frontend.dashboard_output import dashboard_html
from greenalgorithms4HPC.frontend.terminal_output import generate_terminal_view
from greenalgorithms4HPC.frontend.dashboard_output import dashboard_html

def main_frontend(dict_stats, args):
### Load cluster specific info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import plotly.express as px

from frontend.helpers import formatText_footprint, formatText_treemonths, formatText_flying
from greenalgorithms4HPC.frontend.helpers import formatText_footprint, formatText_treemonths, formatText_flying

# class SilentUndefined(Undefined): # DEBUGONLY
# def _fail_with_undefined_error(self, *args, **kwargs):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import math
from frontend.helpers import formatText_footprint, formatText_treemonths, formatText_flying
from greenalgorithms4HPC.frontend.helpers import formatText_footprint, formatText_treemonths, formatText_flying
import pandas as pd
import os

Expand Down
14 changes: 7 additions & 7 deletions myCarbonFootprint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ userCWD="$(pwd)"
# Cd into the directory where the GA files are located
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"

export GA4HPC_CONFDIR=$parent_path/greenalgorithms4HPC/data
# Test if the virtualenv GA_env already exists, and if not, creates it. Download python 3.8 or higher for better results.
if [ ! -f GA_env/bin/activate ]; then
if [ ! -f .venv/bin/activate ]; then
echo "Need to create virtualenv"
/usr/bin/python3.8 -m venv GA_env # this line needs updating to load python on your server
source GA_env/bin/activate
pip3 install -r requirements.txt
/usr/bin/python3.8 -m venv .venv # this line needs updating to load python on your server
source .venv/bin/activate
pip3 install .
else
echo "Virtualenv: OK"
source GA_env/bin/activate
source .venv/bin/activate
fi

# Test if the python version is at least 3.8
Expand All @@ -40,4 +40,4 @@ echo "Python versions: OK"

# Run the python code and pass on the arguments
#userCWD="/home/ll582/ with space" # DEBUGONLY
python __init__.py "$@" --userCWD "$userCWD"
myCarbonFootprint "$@" --userCWD "$userCWD"
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "greenalgorithms4HPC"
version = "0.4"
dependencies = [
"numpy","pandas>=2.0", "PyYAML", "jinja2", "plotly"
]
requires-python = ">=3.6"
authors = [
{name = " Loïc Lannelongue", email = "[email protected]"},
]
maintainers = [
{name = " Loïc Lannelongue", email = "[email protected]"},
]
description = "Green Algorithms for High Performance Computing"

[project.scripts]
myCarbonFootprint = "greenalgorithms4HPC:main"

[tool.setuptools.package-data]
"*" = ["*.yaml"]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.