From f86152f632cefd6482cb8be981a36ee7d60f2de4 Mon Sep 17 00:00:00 2001 From: Qiyu8 Date: Tue, 12 Apr 2022 11:15:13 +0800 Subject: [PATCH 1/3] reconstruct config service and data service, use singeleton mode --- src/configService.py | 6 +++++- src/dataService.py | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/configService.py b/src/configService.py index ae0652a..12fabdc 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 32b8162..901770e 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, dict): + super(Singleton,self).__init__(name,bases, dict) + 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() -- Gitee From a7c8f37ac28ec0ed5e3f604b095c77583b9cd57b Mon Sep 17 00:00:00 2001 From: Qiyu8 Date: Tue, 12 Apr 2022 20:36:07 +0800 Subject: [PATCH 2/3] add init before build and run --- src/dataService.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dataService.py b/src/dataService.py index 901770e..55d1ac1 100644 --- a/src/dataService.py +++ b/src/dataService.py @@ -7,8 +7,8 @@ from toolService import ToolService class Singleton(type): - def __init__(self, name, bases, dict): - super(Singleton,self).__init__(name,bases, dict) + def __init__(self, name, bases, dictItem): + super(Singleton,self).__init__(name,bases, dictItem) self._instance = None def __call__(self, *args, **kwargs): @@ -154,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}''' -- Gitee From 96437233cd28fe780c6fcfa29125942956ba63b4 Mon Sep 17 00:00:00 2001 From: Qiyu8 Date: Wed, 13 Apr 2022 15:15:00 +0800 Subject: [PATCH 3/3] The mpi environment should be set before container run --- container/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/container/README.md b/container/README.md index a253e81..bd48ef5 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 后面的数字为核数,请按实际核数指定) -- Gitee