codegreen.decorators

codegreen.decorators.init_experiment(experiment_name, nextflow_logfile=None, area_code=['DE-9'], estimated_runtime_hours=2, estimated_runtime_minutes=40, codecarbon_logfile='emissions.csv', percent_renewable=30, allowed_delay_hours=24, log_request=True, overwrite=False)

Initialize an experiment with the given parameters. This function will write a configuration file which can be used to report using the same configuration later on. The experiment_name paramter identifies the correct file. By default, the codecarbon report is called emissions.csv.

Parameters:
  • experiment_name (str) – Name of the experiment used to identify the correct configuration file.

  • nextflow_logfile (str) – Name of the nextflow trace file generated when running nextflow with the ‘-with-trace’ option/

  • area_code (list[str]) – list of area codes with a two letter country code and an optional postal code separated by a dash. Postal codes can be given as 1-5 digit areas. [‘CC-PPPPP’, ‘CC’, ‘CC-P’]

  • estimated_runtime_hours (int) – Estimated number of hours of runtime

  • estimated_runtime_minutes (int) – Estimated additional minutes of runtime

  • codecarbon_logfile (str, optional) – Name of the emission file generated by codecarbon, defaults to ‘emissions.csv’

  • percent_renewable (int, optional) – User required percentage of renewable energy present at the time of computation in the grid, defaults to 30

  • allowed_delay_hours (int, optional) – Allowed delay of the computation in hours. It defaults to one day. The computation starts at the latest at [current_time + allowed_delay_hours - estimated_runtime_hours-estimated_runtime_minutes]. defaults to 24

  • log_request (bool, optional) – Allow loggin the request server side. This allows us to calculate the carbon that has been saved by time shifting, defaults to True

  • overwrite (bool, optional) – Overwrite the configuration file at the second initialization (when rerunning the code), defaults to False

codegreen.decorators.sleep_until(estimated_runtime_hours, estimated_run_time_in_minutes, percent_renewable, hard_finish_time, area_code, log_request, process_id, experiment_name)

_summary_

Parameters:
  • estimated_runtime_hours (int) – Estimated runtime in hours

  • estimated_run_time_in_minutes (int) – Estimated runtime minutes

  • percent_renewable (int) – User required percentage of renewable energy available in the grid at time of computation

  • hard_finish_time (_type_) – Final deadline for the computation/

  • area_code (list[str]) – Area code passed as a list of strings.

  • log_request (bool) – Allow logging the request at the server. This will allow us to compute how much carbon you saved.

  • process_id (str) – A hash identifying the experiment. Usually autogenerated by the init method.

  • experiment_name (str) – A name of the experiment used to identify the correct configuration file.

Raises:
  • UnauthorizedException – thrown if the API key is invalid.

  • InternalServerErrorException – thrown if there is an error at the server.

codegreen.decorators.time_shift(experiment_name)

Time shift a computation using the experiment configuration defined in the configuration file with the experiment name. Requires to have run @init_experiment at some point in prior to the computation. The function will automatically pause the computation until the best time within the specified experiment parameters is reached.

Parameters:

experiment_name (str) – _description_

codegreen.decorators.upload_cc_report(experiment_name)

Automatically upload the codecarbon report generated by the codecarbon tracker tool.

Parameters:

experiment_name (str) – Name of the experiment used to identify the correct configuration file for the experiment.

codegreen.decorators.upload_nf_report(experiment_name)

Allow uploading a nextflow report generated when running nextflow with the -with-trace option.

Parameters:

experiment_name (str) – Name of the experiment to identify the config file used for this experiment.