Commit b9fb4937 authored by Benjamin Murauer's avatar Benjamin Murauer
Browse files

Resolve "Search for project root"

parent d2e0a08d
......@@ -7,6 +7,7 @@ import json
import logging
import os
from os.path import basename
from os.path import join
from os.path import splitext
import pickle
import platform
......@@ -35,14 +36,29 @@ SECTION_MAIL = 'mail'
INI_FILE_NAME = 'dbispipeline.ini'
def load_project_config():
"""Loads the project configuration."""
config_files = ['/usr/local/etc/dbispipeline.ini']
config_files = [join('/usr/local/etc', INI_FILE_NAME)]
user_home = os.getenv('HOME')
if user_home:
config_files.append(user_home + '/.config/dbispipeline.ini')
config_files.append(join(user_home, '.config', INI_FILE_NAME))
# find a configuration in any parent folder
parent_directory_configs = []
directory = os.path.realpath('.')
while directory != os.path.dirname(directory):
candidate = join(directory, INI_FILE_NAME)
if os.path.isfile(candidate):
directory = os.path.dirname(directory)
# directories 'closer' to the current cwd are preferred
config_files += parent_directory_configs
config = configparser.ConfigParser()
if os.getenv('DBISPIPELINE_ENV') == 'ci':
......@@ -347,7 +363,7 @@ def prepare_slurm_job(dryrun, force, verbose, restore, mail, plan):
timestamp ='%Y_%m_%d__%H_%M_%S')
plan_noext = os.path.splitext(os.path.basename(plan))[0]
job_filename = f'{timestamp}_{job_name}_{plan_noext}.job'
jobfile = os.path.join('slurmjobs', job_filename)
jobfile = join('slurmjobs', job_filename)
with open(jobfile, 'w') as o_f:
return jobfile
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment