Coverage for /builds/kinetik161/ase/ase/cli/nomadget.py: 40.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

1# Note: 

2# Try to avoid module level import statements here to reduce 

3# import time during CLI execution 

4 

5 

6class CLICommand: 

7 """Get calculations from NOMAD and write to JSON files. 

8 

9 ... 

10 """ 

11 

12 @staticmethod 

13 def add_arguments(p): 

14 p.add_argument('uri', nargs='+', metavar='nmd://<hash>', 

15 help='URIs to get') 

16 

17 @staticmethod 

18 def run(args): 

19 import json 

20 

21 from ase.nomad import download 

22 for uri in args.uri: 

23 calculation = download(uri) 

24 identifier = calculation.hash.replace('/', '.') 

25 fname = f'nmd.{identifier}.nomad-json' 

26 with open(fname, 'w') as fd: 

27 json.dump(calculation, fd) 

28 print(uri)