quintel / etengine

Calculation engine for the Energy Transition Model
https://energytransitionmodel.com/
MIT License
14 stars 7 forks source link

Introduce scenario-cloner script #1360

Closed thomas-qah closed 10 months ago

thomas-qah commented 10 months ago

What?

This PR adds a Bash script to etengine through which it is easy to clone existing scenario between a number of different environments currently existing for the ETM: production, staging/beta and development/local. The script can also be used to easily and conveniently duplicate scenarios within one environment, for example production.

Why?

From time to time its convenient to move certain scenarios from one environment to another, for as example most recently requested here quintel/mechanical_turk#168. The script can also be used to copy scenarios from production or staging to local development environments for further testing or investigation.

How?

The script leverages the existing ETEngine API endpoints to obtain data from requested scenarios from one ETM environment and create new scenarios in another one. Once it is done cloning scenarios it will print the ids for the source -> cloned scenarios to easily see which belongs to which.

Example usage

The script can be used in two ways:

  1. Starting the script without any arguments will launch it in interactive mode. The script will then ask what the source and target environments are and which scenario ids it should use:
    bash scripts/scenario_cloner.sh
  2. Starting the script with arguments:
    • The first argument is the name of the source enviroment,
    • The second argument is the name of the target enviroment,
    • The third argument are the scenario ids, separated by commas (no spaces)
      # E.g. from production to staging:
      bash scripts/scenario_cloner.sh prod staging 1,2,3
      # Or 'p' for production, 'b' for beta (= staging)
      bash scripts/scenario_cloner.sh p b 1,2,3
      # Or from production to local (= development) :
      bash scripts/scenario_cloner.sh prod local 1,2,3
      # All of the above does the same :)

Closes quintel/mechanical_turk#168