def calculation_list(calculations, past_days, groups, all_entries, calculation_state, process_state, exit_status, failed, limit, order_by, project, all_users, raw, absolute_time): """Return a list of job calculations that are still running.""" from aiida.cmdline.utils.common import print_last_process_state_change from aiida.orm.calculation.job import JobCalculation from aiida.work.processes import ProcessState if all_entries: process_state = None calculation_state = None PROCESS_STATE_KEY = 'attributes.{}'.format( JobCalculation.PROCESS_STATE_KEY) EXIT_STATUS_KEY = 'attributes.{}'.format(JobCalculation.EXIT_STATUS_KEY) filters = {} if calculation_state: process_state = None if process_state: calculation_state = None filters[PROCESS_STATE_KEY] = {'in': process_state} if failed: calculation_state = None filters[PROCESS_STATE_KEY] = {'==': ProcessState.FINISHED.value} filters[EXIT_STATUS_KEY] = {'>': 0} if exit_status is not None: calculation_state = None filters[PROCESS_STATE_KEY] = {'==': ProcessState.FINISHED.value} filters[EXIT_STATUS_KEY] = {'==': exit_status} JobCalculation._list_calculations( states=calculation_state, past_days=past_days, pks=[calculation.pk for calculation in calculations], all_users=all_users, groups=groups, relative_ctime=not absolute_time, order_by=order_by, limit=limit, filters=filters, projections=project, raw=raw, ) if not raw: print_last_process_state_change(process_type='calculation')
def calculation_list(self, *args): """ Return a list of calculations on screen. """ if not is_dbenv_loaded(): load_dbenv() from aiida.common.datastructures import calc_states import argparse from aiida.orm.calculation.job import JobCalculation as C from aiida.common.setup import get_property parser = argparse.ArgumentParser( prog=self.get_full_command_name(), description='List AiiDA calculations.') # The default states are those that are shown if no option is given parser.add_argument('-s', '--states', nargs='+', type=str, help="show only the AiiDA calculations with given state", default=[calc_states.WITHSCHEDULER, calc_states.NEW, calc_states.TOSUBMIT, calc_states.SUBMITTING, calc_states.COMPUTED, calc_states.RETRIEVING, calc_states.PARSING, ]) parser.add_argument('-p', '--past-days', metavar='N', help="add a filter to show only calculations created in the past N days", action='store', type=int) parser.add_argument('-g', '--group', '--group-name', metavar='GROUPNAME', help="add a filter to show only calculations within a given group", action='store', type=str) parser.add_argument('-G', '--group-pk', metavar='GROUPPK', help="add a filter to show only calculations within a given group", action='store', type=int) parser.add_argument('pks', type=int, nargs='*', help="a list of calculations to show. If empty, all running calculations are shown. If non-empty, ignores the -p and -r options.") parser.add_argument('-a', '--all-states', dest='all_states', action='store_true', help="Overwrite manual set of states if present, and look for calculations in every possible state") parser.set_defaults(all_states=False) parser.add_argument('-A', '--all-users', dest='all_users', action='store_true', help="Show calculations for all users, rather than only for the current user") parser.set_defaults(all_users=False) parser.add_argument('-t', '--absolute-time', dest='relative_ctime', action='store_false', default=True, help="Print the absolute creation time, rather than the relative creation time") parser.add_argument('-l', '--limit', type=int, default=None, help='set a limit to the number of rows returned') parser.add_argument('-o', '--order-by', choices=['id', 'ctime'], default='ctime', help='order the results') parser.add_argument('--project', choices=( 'pk', 'state', 'ctime', 'sched', 'computer', 'type', 'description', 'label', 'uuid', 'mtime', 'user' ), nargs='+', default=get_property("verdishell.calculation_list"), #('pk', 'ctime', 'state', 'sched', 'computer', 'type', 'label'), help="Define the list of properties to show" ) args = list(args) parsed_args = parser.parse_args(args) capital_states = [i.upper() for i in parsed_args.states] parsed_args.states = capital_states if parsed_args.all_states: parsed_args.states = None C._list_calculations( states=parsed_args.states, past_days=parsed_args.past_days, pks=parsed_args.pks, all_users=parsed_args.all_users, group=parsed_args.group, group_pk=parsed_args.group_pk, relative_ctime=parsed_args.relative_ctime, # with_scheduler_state=parsed_args.with_scheduler_state, order_by=parsed_args.order_by, limit=parsed_args.limit, projections=parsed_args.project, )
def calculation_list(self, *args): """ Return a list of calculations on screen. """ if not is_dbenv_loaded(): load_dbenv() from aiida.common.datastructures import calc_states import argparse from aiida.orm.calculation.job import JobCalculation as C parser = argparse.ArgumentParser( prog=self.get_full_command_name(), description='List AiiDA calculations.') # The default states are those that are shown if no option is given parser.add_argument( '-s', '--states', nargs='+', type=str, help="show only the AiiDA calculations with given state", default=[ calc_states.WITHSCHEDULER, calc_states.NEW, calc_states.TOSUBMIT, calc_states.SUBMITTING, calc_states.COMPUTED, calc_states.RETRIEVING, calc_states.PARSING, ]) parser.add_argument( '-p', '--past-days', metavar='N', help= "add a filter to show only calculations created in the past N days", action='store', type=int) parser.add_argument( '-g', '--group', '--group-name', metavar='GROUPNAME', help="add a filter to show only calculations within a given group", action='store', type=str) parser.add_argument( '-G', '--group-pk', metavar='GROUPPK', help="add a filter to show only calculations within a given group", action='store', type=int) parser.add_argument( 'pks', type=int, nargs='*', help= "a list of calculations to show. If empty, all running calculations are shown. If non-empty, ignores the -p and -r options." ) parser.add_argument( '-a', '--all-states', dest='all_states', action='store_true', help= "Overwrite manual set of states if present, and look for calculations in every possible state" ) parser.set_defaults(all_states=False) parser.add_argument( '-A', '--all-users', dest='all_users', action='store_true', help= "Show calculations for all users, rather than only for the current user" ) parser.set_defaults(all_users=False) parser.add_argument( '-t', '--absolute-time', dest='relative_ctime', action='store_false', help= "Print the absolute creation time, rather than the relative creation time" ) # ~ parser.add_argument('-w', '--with-scheduler-state', # ~ action='store_true', # ~ help='Print the scheduler state (slow)') parser.add_argument('-l', '--limit', type=int, default=None, help='set a limit to the number of rows returned') parser.add_argument('-o', '--order-by', choices=['id', 'ctime'], default='ctime', help='order the results') parser.set_defaults(relative_ctime=True) args = list(args) parsed_args = parser.parse_args(args) capital_states = [i.upper() for i in parsed_args.states] parsed_args.states = capital_states if parsed_args.all_states: parsed_args.states = None try: C._list_calculations( states=parsed_args.states, past_days=parsed_args.past_days, pks=parsed_args.pks, all_users=parsed_args.all_users, group=parsed_args.group, group_pk=parsed_args.group_pk, relative_ctime=parsed_args.relative_ctime, # with_scheduler_state=parsed_args.with_scheduler_state, order_by=parsed_args.order_by, limit=parsed_args.limit) except Exception as e: import traceback print '1', e.__doc__ print '2', sys.exc_info() print '3', sys.exc_info()[0] print '4', sys.exc_info()[1] print '5', sys.exc_info()[2], print 'Sorry I mean line...', print traceback.tb_lineno(sys.exc_info()[2]) ex_type, ex, tb = sys.exc_info() print '6', traceback.print_tb(tb)