Skip to content

Commit

Permalink
[USGS-R#146] add code dir arg to as_run_config fxn
Browse files Browse the repository at this point in the history
  • Loading branch information
jsadler2 committed Jan 19, 2022
1 parent a32cf2d commit 2628249
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions river_dl/preproc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
import datetime


def asRunConfig(config, outFile):
def asRunConfig(config, code_dir, outFile):
"""
function to save the as-run config settings to a text file
:param config: [dict] the current config dictionary
:param code_dir: [str] path to river-dl directory
:param outFile: [str] the filename for the output
"""
#store some run parameters
config['runDate']=datetime.date.today().strftime("%m/%d/%y")
with open(".git/HEAD",'r') as head:
with open(os.path.join(code_dir,".git/HEAD"),'r') as head:
ref = head.readline().split(' ')[-1].strip()
branch = ref.split("/")[-1]
with open('.git/'+ref,'r') as git_hash:
with open(os.path.join(code_dir,'.git/', ref),'r') as git_hash:
commit = git_hash.readline().strip()
config['gitBranch']=branch
config['gitCommit'] = commit
Expand Down

0 comments on commit 2628249

Please sign in to comment.