-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add audit for succesfull imports #192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you modified current pipeline steps instead of adding a general pipeline step that allows to audit the whole process ?
I think the scope was only for the successful import, do you think I would audit all the pipeline execution? |
95f0023
to
abbc564
Compare
b364213
to
8505e35
Compare
eox_nelp/pearson_vue/pipeline.py
Outdated
@@ -613,3 +614,43 @@ def get_enrollment_from_id(enrollment_id, enrollment=None, **kwargs): # pylint: | |||
pass | |||
|
|||
return {} | |||
|
|||
|
|||
def save_audit_pipeline(pipeline_backend, last_step, cdd_import=None, ead_import=None, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned this is not a pipeline step, so I don't understand why you included this in the pipeline file, anyway I wondering why you split the logic into this method and audit pipeline decorator
eox_nelp/pearson_vue/pipeline.py
Outdated
cdd_import (dict, optional): Defaults to None. | ||
ead_import (dict, optional): Defaults to None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ? this implementation is too specific, you are assuming in advanced that the backend will implement cdd and ead pipelines steps and that is not true, probably your answer will include that there are some default values but again this code was written to work with something specific instead of a general solution
eox_nelp/pearson_vue/pipeline.py
Outdated
def executed_pipeline( | ||
pipeline_backend, | ||
last_step, | ||
cdd_import, | ||
ead_import, | ||
**kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def executed_pipeline( | |
pipeline_backend, | |
last_step, | |
cdd_import, | |
ead_import, | |
**kwargs | |
def executed_pipeline( | |
backend_name, | |
last_pipeline_step, | |
backend_data, |
eox_nelp/pearson_vue/pipeline.py
Outdated
logger.info( | ||
"Succesfull imports. cdd_import: %s. ead_import: %s", | ||
cdd_import, | ||
ead_import, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.info( | |
"Succesfull imports. cdd_import: %s. ead_import: %s", | |
cdd_import, | |
ead_import, | |
) |
Since this is not a general implementation
eox_nelp/pearson_vue/rti_backend.py
Outdated
return func(self, *args, **kwargs) | ||
finally: | ||
if self.use_audit_pipeline and not self.backend_data.get("catched_pearson_error"): | ||
save_audit_pipeline( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a simple log, why you didn't include the logic here ?
eox_nelp/pearson_vue/rti_backend.py
Outdated
save_audit_pipeline( | ||
pipeline_backend=self.__class__.__name__, | ||
last_step=self.get_pipeline()[self.backend_data.get("pipeline_index", 0)].__name__, | ||
**self.backend_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**self.backend_data | |
backend_data=self.backend_data |
eox_nelp/pearson_vue/rti_backend.py
Outdated
@@ -53,15 +78,17 @@ class AbstractBackend(ABC): | |||
handle_error(exception: Exception, failed_step_pipeline: str): Handles errors during pipeline execution. | |||
""" | |||
|
|||
def __init__(self, **kwargs): | |||
def __init__(self, use_audit_pipeline=True, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The advantage of this is that you can change the backend behavior based on the initialization, but do we need that?, it's not better stable backends whose execution or behavior is always the same ?
def __init__(self, use_audit_pipeline=True, **kwargs): | |
use_audit_pipeline=True | |
def __init__(self, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but then I must apply the decorator to the specific pipeline backend. Otherwise I would get something like this.
https://edunext.stage.nelp.gov.sa/admin/eox_audit_model/auditmodel/32026/change/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see the error pipeline is also audited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happen if you override that in the subclass ?
eox_nelp/pearson_vue/rti_backend.py
Outdated
validate_cdd_request, | ||
validate_ead_request, | ||
) | ||
|
||
|
||
def audit_pipeline(func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please move this to a decorators.py file ?
8505e35
to
ef9a5b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove some things like the use_audit_pipeline
and the catched_pearson_error
?
@@ -227,7 +227,7 @@ def import_candidate_demographics(cdd_request, **kwargs): # pylint: disable=unu | |||
response = api_client.import_candidate_demographics(payload) | |||
|
|||
if response.get("status", "error") == "accepted": | |||
return response | |||
return {"cdd_import": response} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think we will need this ?
@@ -276,7 +276,7 @@ def import_exam_authorization(ead_request, **kwargs): # pylint: disable=unused- | |||
response = api_client.import_exam_authorization(payload) | |||
|
|||
if response.get("status", "error") == "accepted": | |||
return response | |||
return {"ead_import": response} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments as above
The use audit because don't you recommend using the override in the |
Nop, there was a misunderstanding, my previous recommendation was to test use_audit_pipeline as attribute class and then override that in the subclass class AbstractBackend(ABC):
use_audit_pipeline=True
class ErrorRealTimeImportHandler(AbstractBackend):
use_audit_pipeline=False |
Description
add audit to pipelines
Testing instructions
Before
After
Additional information
Include anything else that will help reviewers and consumers understand the change.
Checklist for Merge