File: remove_from_queue

package info (click to toggle)
python-ase 3.22.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,344 kB
  • sloc: python: 126,379; xml: 946; makefile: 111; javascript: 47
file content (48 lines) | stat: -rwxr-xr-x 1,331 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
""" Program that edits the database in order to requeue a candidate in
case the relaxation went wrong. """
from ase.ga.data import DataConnection
from optparse import OptionParser

try:
    input = raw_input  # Python 2+3 compatibility
except NameError:
    pass

parser = OptionParser(
    description='Show which structures are queued, but not done')
parser.add_option('-f', '--db-file',
                  default='ga_db.sql',
                  help='Location of the SQLite DB file')
parser.add_option('-r', '--remove-all',
                  default='No')

opt, args = parser.parse_args()

db_file = opt.db_file

dc = DataConnection(db_file)

l = dc.get_all_candidates_in_queue()

s = 'h'
while s.find('Q') == -1 and len(l) > 0:
    for s in l:
        print('Queued but not done: %d' % int(s))
    if opt.remove_all == 'Yes':
        s = ''
        for ni in l:
            s += '%d ' % ni
    else:
        s = input('Choose which you want to requeue or type Q to quit: ')
        if s.find('Q') != -1:
            exit()
    iline = s.split()
    for i in iline:
        i = int(i.strip())
        assert i in l, 'Not a valid ID'
        dc.remove_from_queue(i)
        print('Structure removed from queue %d' % i)
    if opt.remove_all == 'Yes':
        exit()
    l = dc.get_all_candidates_in_queue()