@@ -32,7 +32,7 @@ def verdi_group():
32
32
def group_add_nodes (group , force , nodes ):
33
33
"""Add nodes to a group."""
34
34
if not force :
35
- click .confirm (f'Do you really want to add { len (nodes )} nodes to Group< { group . label } > ?' , abort = True )
35
+ click .confirm (f'Do you really want to add { len (nodes )} nodes to { group } ?' , abort = True )
36
36
37
37
group .add_nodes (nodes )
38
38
@@ -47,9 +47,6 @@ def group_remove_nodes(group, nodes, clear, force):
47
47
"""Remove nodes from a group."""
48
48
from aiida .orm import QueryBuilder , Group , Node
49
49
50
- label = group .label
51
- klass = group .__class__ .__name__
52
-
53
50
if nodes and clear :
54
51
echo .echo_critical (
55
52
'Specify either the `--clear` flag to remove all nodes or the identifiers of the nodes you want to remove.'
@@ -67,18 +64,18 @@ def group_remove_nodes(group, nodes, clear, force):
67
64
group_node_pks = query .all (flat = True )
68
65
69
66
if not group_node_pks :
70
- echo .echo_critical (f'None of the specified nodes are in { klass } < { label } > .' )
67
+ echo .echo_critical (f'None of the specified nodes are in { group } .' )
71
68
72
69
if len (node_pks ) > len (group_node_pks ):
73
70
node_pks = set (node_pks ).difference (set (group_node_pks ))
74
- echo .echo_warning (f'{ len (node_pks )} nodes with PK { node_pks } are not in { klass } < { label } > .' )
71
+ echo .echo_warning (f'{ len (node_pks )} nodes with PK { node_pks } are not in { group } .' )
75
72
76
- message = f'Are you sure you want to remove { len (group_node_pks )} nodes from { klass } < { label } > ?'
73
+ message = f'Are you sure you want to remove { len (group_node_pks )} nodes from { group } ?'
77
74
78
75
elif clear :
79
- message = f'Are you sure you want to remove ALL the nodes from { klass } < { label } > ?'
76
+ message = f'Are you sure you want to remove ALL the nodes from { group } ?'
80
77
else :
81
- echo .echo_critical (f'No nodes were provided for removal from { klass } < { label } > .' )
78
+ echo .echo_critical (f'No nodes were provided for removal from { group } .' )
82
79
83
80
click .confirm (message , abort = True )
84
81
@@ -104,24 +101,21 @@ def group_delete(group, delete_nodes, dry_run, force, verbose, **traversal_rules
104
101
from aiida .tools import delete_group_nodes , DELETE_LOGGER
105
102
from aiida import orm
106
103
107
- label = group .label
108
- klass = group .__class__ .__name__
109
-
110
104
verbosity = logging .DEBUG if verbose else logging .INFO
111
105
DELETE_LOGGER .setLevel (verbosity )
112
106
113
107
if not (force or dry_run ):
114
- click .confirm (f'Are you sure to delete { klass } < { label } > ?' , abort = True )
108
+ click .confirm (f'Are you sure you want to delete { group } ?' , abort = True )
115
109
elif dry_run :
116
- echo .echo_info (f'Would have deleted { klass } < { label } > .' )
110
+ echo .echo_info (f'Would have deleted { group } .' )
117
111
118
112
if delete_nodes :
119
113
120
114
def _dry_run_callback (pks ):
121
115
if not pks or force :
122
116
return False
123
117
echo .echo_warning (f'YOU ARE ABOUT TO DELETE { len (pks )} NODES! THIS CANNOT BE UNDONE!' )
124
- return not click .confirm ('Shall I continue?' , abort = True )
118
+ return not click .confirm ('Do you want to continue?' , abort = True )
125
119
126
120
with override_log_formatter_context ('%(message)s' ):
127
121
_ , nodes_deleted = delete_group_nodes ([group .pk ], dry_run = dry_run or _dry_run_callback , ** traversal_rules )
@@ -130,8 +124,9 @@ def _dry_run_callback(pks):
130
124
return
131
125
132
126
if not dry_run :
127
+ group_str = str (group )
133
128
orm .Group .objects .delete (group .pk )
134
- echo .echo_success (f'{ klass } < { label } > deleted.' )
129
+ echo .echo_success (f'{ group_str } deleted.' )
135
130
136
131
137
132
@verdi_group .command ('relabel' )
@@ -143,9 +138,9 @@ def group_relabel(group, label):
143
138
try :
144
139
group .label = label
145
140
except UniquenessError as exception :
146
- echo .echo_critical (f'Error: { exception } .' )
141
+ echo .echo_critical (str ( exception ) )
147
142
else :
148
- echo .echo_success (f' Label changed to { label } ' )
143
+ echo .echo_success (f" Label changed to ' { label } '" )
149
144
150
145
151
146
@verdi_group .command ('description' )
@@ -155,11 +150,11 @@ def group_relabel(group, label):
155
150
def group_description (group , description ):
156
151
"""Change the description of a group.
157
152
158
- If no DESCRIPTION is defined, the current description will simply be echoed.
153
+ If no description is defined, the current description will simply be echoed.
159
154
"""
160
155
if description :
161
156
group .description = description
162
- echo .echo_success (f'Changed the description of Group< { group . label } > ' )
157
+ echo .echo_success (f'Changed the description of { group } . ' )
163
158
else :
164
159
echo .echo (group .description )
165
160
@@ -172,7 +167,7 @@ def group_description(group, description):
172
167
'--uuid' ,
173
168
is_flag = True ,
174
169
default = False ,
175
- help = 'Show UUIDs together with PKs. Note: if the --raw option is also passed, PKs are not printed, but oly UUIDs.'
170
+ help = 'Show UUIDs together with PKs. Note: if the --raw option is also passed, PKs are not printed, but only UUIDs.'
176
171
)
177
172
@arguments .GROUP ()
178
173
@with_dbenv ()
@@ -223,7 +218,7 @@ def group_show(group, raw, limit, uuid):
223
218
224
219
@verdi_group .command ('list' )
225
220
@options .ALL_USERS (help = 'Show groups for all users, rather than only for the current user.' )
226
- @options .USER (help = 'Add a filter to show only groups belonging to a specific user' )
221
+ @options .USER (help = 'Add a filter to show only groups belonging to a specific user. ' )
227
222
@options .ALL (help = 'Show groups of all types.' )
228
223
@options .TYPE_STRING ()
229
224
@click .option (
@@ -292,7 +287,7 @@ def group_list(
292
287
if past_days :
293
288
filters ['time' ] = {'>' : timezone .now () - datetime .timedelta (days = past_days )}
294
289
295
- # Query for specific group names
290
+ # Query for specific group labels
296
291
filters ['or' ] = []
297
292
if startswith :
298
293
filters ['or' ].append ({'label' : {'like' : f'{ escape_for_sql_like (startswith )} %' }})
@@ -346,10 +341,10 @@ def group_list(
346
341
table .append ([projection_lambdas [field ](group [0 ]) for field in projection_fields ])
347
342
348
343
if not all_entries :
349
- echo .echo_info ('to show groups of all types, use the `-a/--all` option.' )
344
+ echo .echo_info ('To show groups of all types, use the `-a/--all` option.' )
350
345
351
346
if not table :
352
- echo .echo_info ('no groups found matching the specified criteria.' )
347
+ echo .echo_info ('No groups found matching the specified criteria.' )
353
348
else :
354
349
echo .echo (tabulate (table , headers = projection_header ))
355
350
@@ -358,15 +353,15 @@ def group_list(
358
353
@click .argument ('group_label' , nargs = 1 , type = click .STRING )
359
354
@with_dbenv ()
360
355
def group_create (group_label ):
361
- """Create an empty group with a given name ."""
356
+ """Create an empty group with a given label ."""
362
357
from aiida import orm
363
358
364
359
group , created = orm .Group .objects .get_or_create (label = group_label )
365
360
366
361
if created :
367
- echo .echo_success (f"Group created with PK = { group .id } and name '{ group .label } '" )
362
+ echo .echo_success (f"Group created with PK = { group .pk } and label '{ group .label } '. " )
368
363
else :
369
- echo .echo_info (f"Group '{ group .label } ' already exists, PK = { group . id } " )
364
+ echo .echo_info (f"Group with label '{ group .label } ' already exists: { group } . " )
370
365
371
366
372
367
@verdi_group .command ('copy' )
@@ -384,12 +379,12 @@ def group_copy(source_group, destination_group):
384
379
385
380
# Issue warning if destination group is not empty and get user confirmation to continue
386
381
if not created and not dest_group .is_empty :
387
- echo .echo_warning (f'Destination group< { dest_group . label } > already exists and is not empty.' )
382
+ echo .echo_warning (f'Destination { dest_group } already exists and is not empty.' )
388
383
click .confirm ('Do you wish to continue anyway?' , abort = True )
389
384
390
385
# Copy nodes
391
386
dest_group .add_nodes (list (source_group .nodes ))
392
- echo .echo_success (f'Nodes copied from group< { source_group . label } > to group< { dest_group . label } > ' )
387
+ echo .echo_success (f'Nodes copied from { source_group } to { dest_group } . ' )
393
388
394
389
395
390
@verdi_group .group ('path' )
0 commit comments