Skip to content

Commit

Permalink
Added version tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
squoilin committed Oct 15, 2017
1 parent 7b6d0f4 commit 2ecf5af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions DispaSET/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def build_simulation(config,plot_load=False):
:param config: Dictionary with all the configuration fields loaded from the excel file. Output of the 'LoadConfig' function.
:param plot_load: Boolean used to display a plot of the demand curves in the different zones
"""
logging.info('New build started')
dispa_version = str(get_git_revision_tag())
logging.info('New build started. DispaSET version: ' + dispa_version)
# %%################################################################################################################
##################################### Main Inputs ############################################################
###################################################################################################################
Expand Down Expand Up @@ -608,7 +609,7 @@ def build_simulation(config,plot_load=False):
sim = config['SimulationDirectory']

# Simulation data:
SimData = {'sets': sets, 'parameters': parameters, 'config': config, 'units': Plants_merged}
SimData = {'sets': sets, 'parameters': parameters, 'config': config, 'units': Plants_merged, 'version': dispa_version}

# list_vars = []
gdx_out = "Inputs.gdx"
Expand Down Expand Up @@ -684,3 +685,11 @@ def build_simulation(config,plot_load=False):
fig.savefig(sim + '/ALL_YEAR.pdf', dpi=300, bbox_inches='tight')

return SimData

def get_git_revision_tag():
"""Get version of DispaSET used for this run. tag + commit hash"""
from subprocess import check_output
try:
return check_output(["git", "describe"]).strip()
except:
return 'NA'
4 changes: 2 additions & 2 deletions DispaSET/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def is_sim_folder_ok(sim_folder):
return True


def solve_GAMS(sim_folder, gams_folder=None, output_lst=False):
def solve_GAMS(sim_folder, gams_folder=None, work_dir=None, output_lst=False):
if not package_exists('gams'):
logging.warning('Could not import gams. Trying to automatically locate gdxcc folder')
if not import_local_lib('gams'):
Expand All @@ -53,7 +53,7 @@ def solve_GAMS(sim_folder, gams_folder=None, output_lst=False):
# create GAMS workspace:
from gams import GamsWorkspace
try:
ws = GamsWorkspace(system_directory=gams_folder, debug=3)
ws = GamsWorkspace(system_directory=gams_folder, working_directory=work_dir, debug=3)
shutil.copy(os.path.join(sim_folder, 'UCM_h.gms'), ws.working_directory)
shutil.copy(os.path.join(sim_folder, 'Inputs.gdx'), ws.working_directory)
t1 = ws.add_job_from_file('UCM_h.gms')
Expand Down

0 comments on commit 2ecf5af

Please sign in to comment.