Skip to content

Commit

Permalink
Update get_transaction_state to use new values
Browse files Browse the repository at this point in the history
  • Loading branch information
jackleland committed Oct 16, 2023
1 parent 979f9ca commit 9f0a30c
Showing 1 changed file with 40 additions and 41 deletions.
81 changes: 40 additions & 41 deletions nlds_client/clientlib/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,52 +740,51 @@ def get_transaction_state(transaction: dict):
}
possible values of state are:
INITIALISING = -1
ROUTING = 0
SPLITTING = 1
INDEXING = 2
TRANSFER_PUTTING = 3
CATALOG_PUTTING = 4
CATALOG_GETTING = 5
TRANSFER_GETTING = 6
COMPLETE = 8
FAILED = 9
COMPLETE_WITH_ERRORS = 10
COMPLETE_WITH_WARNINGS = 11
INITIALISING = -1
ROUTING = 0
SPLITTING = 1
INDEXING = 2
CATALOG_PUTTING = 3
TRANSFER_PUTTING = 4
CATALOG_ROLLBACK = 5
CATALOG_GETTING = 10
ARCHIVE_GETTING = 11
TRANSFER_GETTING = 12
ARCHIVE_INIT = 20
CATALOG_ARCHIVE_AGGREGATING = 21
ARCHIVE_PUTTING = 22
CATALOG_ARCHIVE_UPDATING = 23
CATALOG_ARCHIVE_ROLLBACK = 40
COMPLETE = 100
FAILED = 101
COMPLETE_WITH_ERRORS = 102
COMPLETE_WITH_WARNINGS = 103
The overall state is the minimum of these
"""
state_mapping = {
"INITIALISING" : -1,
"ROUTING" : 0,
"SPLITTING" : 1,
"INDEXING" : 2,
"CATALOG_PUTTING" : 3,
"TRANSFER_PUTTING" : 4,
"INITIALISING": -1,
"ROUTING": 0,
"SPLITTING": 1,
"INDEXING": 2,
"CATALOG_PUTTING": 3,
"TRANSFER_PUTTING": 4,
"CATALOG_ROLLBACK": 5,
"CATALOG_GETTING" : 6,
"TRANSFER_GETTING" : 7,
"COMPLETE" : 8,
"FAILED" : 9,
"COMPLETE_WITH_ERRORS" : 10,
"COMPLETE_WITH_WARNINGS": 11,
}
state_mapping_reverse = {
-1 : "INITIALISING",
0 : "ROUTING",
1 : "SPLITTING",
2 : "INDEXING",
3 : "CATALOG_PUTTING",
4 : "TRANSFER_PUTTING" ,
5 : "CATALOG_ROLLBACK",
6 : "CATALOG_GETTING",
7 : "TRANSFER_GETTING",
8 : "COMPLETE",
9 : "FAILED",
10: "COMPLETE_WITH_ERRORS",
11: "COMPLETE_WITH_WARNINGS"
"CATALOG_GETTING": 10,
"ARCHIVE_GETTING": 11,
"TRANSFER_GETTING": 12,
"ARCHIVE_INIT": 20,
"CATALOG_ARCHIVE_AGGREGATING": 21,
"ARCHIVE_PUTTING": 22,
"CATALOG_ARCHIVE_UPDATING": 23,
"CATALOG_ARCHIVE_ROLLBACK": 40,
"COMPLETE": 100,
"FAILED": 101,
"COMPLETE_WITH_ERRORS" : 102,
"COMPLETE_WITH_WARNINGS": 103,
}
state_mapping_reverse = {v: k for k, v in state_mapping.items()}

min_state = 100
min_state = 200
min_time = datetime(1970,1,1)
error_count = 0
for sr in transaction["sub_records"]:
Expand All @@ -798,7 +797,7 @@ def get_transaction_state(transaction: dict):
if sr_state == "FAILED":
error_count += 1

if min_state == 100:
if min_state == 200:
return None, None

if min_state == state_mapping["COMPLETE"] and error_count > 0:
Expand Down

0 comments on commit 9f0a30c

Please sign in to comment.