From 9f0a30c7882e616876781ac6dbbf721fa57a56e4 Mon Sep 17 00:00:00 2001 From: Jack Leland Date: Mon, 16 Oct 2023 16:52:34 +0100 Subject: [PATCH] Update get_transaction_state to use new values --- nlds_client/clientlib/transactions.py | 81 +++++++++++++-------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/nlds_client/clientlib/transactions.py b/nlds_client/clientlib/transactions.py index 48485cf..9cf44bb 100644 --- a/nlds_client/clientlib/transactions.py +++ b/nlds_client/clientlib/transactions.py @@ -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"]: @@ -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: