def check_and_migrate_config(config, store=True): """ Checks if the config needs to be migrated, and performs the migration if needed. """ if config_needs_migrating(config): config = migrate_config(config) from aiida.common.setup import store_config if store: store_config(config) return config
def perform_migration(self): # Backup the previous config setup.backup_config() # Get the AiiDA directory path aiida_directory = os.path.expanduser(setup.AIIDA_CONFIG_FOLDER) # Construct the daemon directory path daemon_dir = os.path.join(aiida_directory, setup.DAEMON_SUBDIR) # Construct the log directory path log_dir = os.path.join(aiida_directory, setup.LOG_SUBDIR) # Update the configuration if needed confs = self.adding_backend() # Store the configuration setup.store_config(confs) # Update the daemon directory self.install_daemon_files(aiida_directory, daemon_dir, log_dir, getpass.getuser())
def transition_config_files(profile=None): print("Changing backend from Django to SQLAlchemy in config files") # Backup the previous config setup.backup_config() # Get the AiiDA directory path aiida_directory = os.path.expanduser(setup.AIIDA_CONFIG_FOLDER) # Construct the log directory path log_dir = os.path.join(aiida_directory, setup.LOG_SUBDIR) # Update the configuration if needed confs = change_backend_to_sqla(profile) # Store the configuration setup.store_config(confs) # Construct the daemon directory path daemon_dir = os.path.join(aiida_directory, setup.DAEMON_SUBDIR) # Update the daemon directory setup.install_daemon_files(aiida_directory, daemon_dir, log_dir, getpass.getuser()) print("Config file update finished.")