def change_backend_to_sqla(profile=None): """ Gets the main AiiDA configuration and searches if there is a backend defined. If there isn't any then Django is added. """ # Get the available configuration conf = setup.get_config() # Profile key _profiles_key = "profiles" # Identifying all the available profiles if _profiles_key in conf.keys(): profiles = conf[_profiles_key] if profile not in profiles.keys(): print( "The provided profile name is not one of the available " "profiles. Exiting") sys.exit(0) curr_profile = profiles[profile] if setup.aiidadb_backend_key in curr_profile.keys(): if curr_profile[aiidadb_backend_key] == aiidadb_backend_value_sqla: print "This is already an SQLAlchemy profile. Exiting" sys.exit(0) curr_profile[aiidadb_backend_key] = \ aiidadb_backend_value_sqla else: print( "No backend entry found in your configuration file. Are you " "sure that you are running a version 0.6.*?") sys.exit(0) # Returning the configuration return conf
def adding_backend(self): """ Gets the main AiiDA configuration and searches if there is a backend defined. If there isn't any then Django is added. """ # Get the available configuration conf = setup.get_config() # Identifying all the available profiles if self._profiles_key in conf.keys(): profiles = conf[self._profiles_key] p_keys = profiles.keys() # For every profile for p_key in p_keys: # get the curr_profile = profiles[p_key] # Check if there is a specific backend in the profile # and if not, add Django as backend if setup.aiidadb_backend_key not in curr_profile.keys(): curr_profile[setup.aiidadb_backend_key] = \ setup.aiidadb_backend_value_django # Returning the configuration return conf
def __init__(self, profile): self.profile = profile self.config = get_config() self.profile_config = self.config['profiles'][self.profile] self.profile_config[CIRCUS_PORT_KEY] = self.profile_config.get( CIRCUS_PORT_KEY, generate_new_circus_port(self.profile)) update_profile(profile, self.profile_config)
def _get_repository_path(self): from aiida.backends import settings from aiida.common.setup import (get_config, get_profile_config, parse_repository_uri) from aiida.common.exceptions import ConfigurationError try: confs = get_config() except ConfigurationError: raise ConfigurationError( "Please run the AiiDA Installation, no config found") if settings.AIIDADB_PROFILE is None: raise ConfigurationError( "settings.AIIDADB_PROFILE not defined, did you load django" "through the AiiDA load_dbenv()?") profile_conf = get_profile_config(settings.AIIDADB_PROFILE, conf_dict=confs) REPOSITORY_URI = profile_conf.get('AIIDADB_REPOSITORY_URI', '') REPOSITORY_PROTOCOL, REPOSITORY_PATH = parse_repository_uri( REPOSITORY_URI) return REPOSITORY_PATH
# get_property is used to read properties stored in the config json from aiida.common.setup import (get_config, get_secret_key, get_property, get_profile_config, parse_repository_uri) from aiida.backends import settings from aiida.utils.timezone import get_current_timezone # Assumes that parent directory of aiida is root for # things like templates/, SQL/ etc. If not, change what follows... AIIDA_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.split(AIIDA_DIR)[0] sys.path = [BASE_DIR] + sys.path try: confs = get_config() except MissingConfigurationError: raise MissingConfigurationError( "Please run the AiiDA Installation, no config found") if settings.AIIDADB_PROFILE is None: raise ConfigurationError( "settings.AIIDADB_PROFILE not defined, did you load django" "through the AiiDA load_dbenv()?") profile_conf = get_profile_config(settings.AIIDADB_PROFILE, conf_dict=confs) # put all database specific portions of settings here DBENGINE = profile_conf.get('AIIDADB_ENGINE', '') DBNAME = profile_conf.get('AIIDADB_NAME', '') DBUSER = profile_conf.get('AIIDADB_USER', '')