diff --git a/container/README.md b/container/README.md index a253e811a627af8feaca3c50f821d6391d4dc99b..bd48ef5d3a2c35610e7d38f74e0a5d2bab2c3090 100644 --- a/container/README.md +++ b/container/README.md @@ -65,7 +65,8 @@ singularity build openeuler-kgcc9-openmpi4-qe-6.4.sif openeuler-kgcc9-openmpi4-q ``` cp ./templates/qe/6.4/data.qe.container.config ./ ./jarvis -use data.qe.container.config -./jarvis -d -dp +./jarvis -d -dp -e +source ./env.sh ``` 5.5 运行容器(-np 后面的数字为核数,请按实际核数指定) diff --git a/src/configService.py b/src/configService.py index ae0652a46fc06466f55fe81f3756c2323f30a15b..12fabdc4a1a52ea5a92b062b599f21d09ccbaa64 100644 --- a/src/configService.py +++ b/src/configService.py @@ -14,6 +14,10 @@ class ConfigService: def switch_config(self, config_file): print(f"Switch config file to {config_file}") + config_path = os.path.join(self.ROOT, config_file) + if not os.path.exists(config_path): + print("config_path not found, switch failed.") + return self.tool.write_file(self.meta_path, config_file.strip()) - print("Successfully switched.") + print("Successfully switched. config file saved in file .meta") diff --git a/src/dataService.py b/src/dataService.py index 32b8162881ce5d6a3953cb3260ec047520503c01..55d1ac1e353a91a3de7b008e527d9855e422db2f 100644 --- a/src/dataService.py +++ b/src/dataService.py @@ -5,7 +5,18 @@ import platform from toolService import ToolService -class DataService: +class Singleton(type): + + def __init__(self, name, bases, dictItem): + super(Singleton,self).__init__(name,bases, dictItem) + self._instance = None + + def __call__(self, *args, **kwargs): + if self._instance is None: + self._instance = super(Singleton,self).__call__(*args, **kwargs) + return self._instance + +class DataService(object,metaclass=Singleton): # Hardware Info avail_ips='' # Dependent Software environment Info @@ -49,6 +60,9 @@ class DataService: def get_data_config(self): file_name = self.get_config_file_name() file_path = self.get_abspath(file_name) + if not os.path.exists(file_path): + print("config file not found, switch to default data.config.") + file_path = self.get_abspath(DataService.config_file) with open(file_path, encoding='utf-8') as file_obj: contents = file_obj.read() return contents.strip() @@ -140,7 +154,9 @@ cd {DataService.build_dir} {DataService.clean_cmd} ''' def get_env(self): - return f''' + return f'''set -x +set -e +source ./init.sh ./jarvis -e source ./{DataService.env_file}'''