-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12155 from vkuznet/fix-issue-12040
Implement logic to remake input data placement upon site list changes
- Loading branch information
Showing
7 changed files
with
300 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/python/WMCore/MicroService/MSTransferor/MSTransferorError.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
""" | ||
File : MSTransferorError.py | ||
Author : Valentin Kuznetsov <vkuznet AT gmail dot com> | ||
Description: MSTransferorError represents MSTransferor errors | ||
""" | ||
|
||
# system modules | ||
import json | ||
|
||
# WMCore modules | ||
from WMCore.WMException import WMException | ||
|
||
|
||
# MSTransferor error codes | ||
MSPILEUP_GENERIC_ERROR = 1 | ||
MSPILEUP_STORAGE_ERROR = 2 | ||
|
||
|
||
class MSTransferorError(WMException): | ||
""" | ||
MSTransferorError represents generic MSTransferor error | ||
""" | ||
def __init__(self, msg, errorNo=None, **data): | ||
""" | ||
Constructor of MSTransferorError class | ||
""" | ||
super().__init__(self, msg) | ||
self.data = data | ||
self.code = errorNo | ||
self.assign(msg) | ||
|
||
def error(self): | ||
""" | ||
JSON representation of MSTransferorError | ||
:return: MSTransferorError representation | ||
""" | ||
edict = {'data': self.data, 'message': self.msg, 'code': self.code, 'error': 'MSTransferorError'} | ||
return edict | ||
|
||
def __str__(self): | ||
""" | ||
String representation of MSTransferorError | ||
:return: human readable MSTransferorError representation | ||
""" | ||
return json.dumps(self.error(), indent=4) | ||
|
||
def assign(self, msg="", code=0): | ||
""" | ||
Assign proper message and error codes | ||
:param msg: string | ||
:param code: int | ||
:return: None | ||
""" | ||
if msg: | ||
self.msg = msg | ||
else: | ||
self.msg = 'Generic MSTransferor error' | ||
if code > 0: | ||
self.code = code | ||
else: | ||
self.code = MSPILEUP_GENERIC_ERROR | ||
|
||
|
||
class MSTransferorGenericError(MSTransferorError): | ||
""" | ||
Generic MSTransferor exception | ||
""" | ||
def __init__(self, msg, errorNo=None, **data): | ||
super().__init__(msg, errorNo, **data) | ||
if not msg: | ||
msg = "generic error" | ||
self.assign(msg=msg, code=MSPILEUP_GENERIC_ERROR) | ||
|
||
|
||
class MSTransferorStorageError(MSTransferorError): | ||
""" | ||
Storage MSTransferor exception | ||
""" | ||
def __init__(self, msg, errorNo=None, **data): | ||
super().__init__(msg, errorNo, **data) | ||
if not msg: | ||
msg = "storage error" | ||
self.assign(msg=msg, code=MSPILEUP_STORAGE_ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/python/WMCore_t/MicroService_t/MSTransferor_t/MSTransferorError_t.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
Unit tests for MSTransferorError.py module | ||
Author: Valentin Kuznetsov <vkuznet [AT] gmail [DOT] com> | ||
""" | ||
|
||
# system modules | ||
import unittest | ||
|
||
# WMCore modules | ||
from WMCore.MicroService.MSTransferor.MSTransferorError import MSTransferorStorageError, MSPILEUP_STORAGE_ERROR | ||
|
||
|
||
class TransferorErrorTest(unittest.TestCase): | ||
"Unit test for TransferorError module" | ||
|
||
def testError(self): | ||
"""Test MSTransferorError""" | ||
rec = {'workflow': 'testWorkflow'} | ||
|
||
# test custom emessage | ||
msg = 'test error' | ||
err = MSTransferorStorageError(msg, **rec) | ||
edict = err.error() | ||
self.assertEqual(edict['message'], msg) | ||
self.assertEqual(edict['code'], MSPILEUP_STORAGE_ERROR) | ||
self.assertEqual(edict['data'], rec) | ||
|
||
# test default assigned message | ||
err = MSTransferorStorageError('', **rec) | ||
edict = err.error() | ||
self.assertEqual(edict['message'], 'storage error') | ||
self.assertEqual(edict['code'], MSPILEUP_STORAGE_ERROR) | ||
self.assertEqual(edict['data'], rec) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.