Skip to content

Commit

Permalink
Merge pull request #251 from wguanicedew/dev
Browse files Browse the repository at this point in the history
fix bulk update
  • Loading branch information
wguanicedew authored Nov 29, 2023
2 parents e02159b + e6bddd4 commit 42c477e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion common/lib/idds/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def group_list(input_list, key):
for item in input_list:
item_key = item[key]
del item[key]
item_tuple = tuple(sorted(item.items()))
item_tuple = str(tuple(sorted(item.items())))
if item_tuple not in update_groups:
update_groups[item_tuple] = {'keys': [], 'items': item}
update_groups[item_tuple]['keys'].append(item_key)
Expand Down
9 changes: 5 additions & 4 deletions main/lib/idds/orm/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,18 @@ def update_contents(parameters, use_bulk_update_mappings=False, request_id=None,
"""
try:
for parameter in parameters:
parameter['updated_at'] = datetime.datetime.utcnow()

if use_bulk_update_mappings:
for parameter in parameters:
parameter['updated_at'] = datetime.datetime.utcnow()

session.bulk_update_mappings(models.Content, parameters)
else:
groups = group_list(parameters, key='content_id')
for group_key in groups:
group = groups[group_key]
keys = group['keys']
items = group['items']
items['updated_at'] = datetime.datetime.utcnow()
query = session.query(models.Content)
if request_id:
query = query.filter(models.Content.request_id == request_id)
Expand Down Expand Up @@ -703,7 +704,7 @@ def get_contents_ext_maps():
'trans_exit_code': 'transExitCode', 'pilot_error_code': 'pilotErrorCode', 'pilot_error_diag': 'pilotErrorDiag',
'exe_error_code': 'exeErrorCode', 'exe_error_diag': 'exeErrorDiag', 'sup_error_code': 'supErrorCode',
'sup_error_diag': 'supErrorDiag', 'ddm_error_code': 'ddmErrorCode', 'ddm_error_diag': 'ddmErrorDiag',
'brokerage_error_cdode': 'brokerageErrorCode', 'brokerage_error_diag': 'brokerageErrorDiag',
'brokerage_error_code': 'brokerageErrorCode', 'brokerage_error_diag': 'brokerageErrorDiag',
'job_dispatcher_error_code': 'jobDispatcherErrorCode', 'job_dispatcher_error_diag': 'jobDispatcherErrorDiag',
'task_buffer_error_code': 'taskBufferErrorCode', 'task_buffer_error_diag': 'taskBufferErrorDiag',
'computing_site': 'computingSite', 'computing_element': 'computingElement',
Expand Down

0 comments on commit 42c477e

Please sign in to comment.