Modify retrying of sync tasks to use resumesync command #9493
Modify retrying of sync tasks to use resumesync command #9493bjester wants to merge 4 commits intolearningequality:developfrom
Conversation
Build Artifacts
|
0aee570 to
ea5f630
Compare
rtibbles
left a comment
There was a problem hiding this comment.
I think I am following - but I think I'd prefer the invocation of the retry validation to be a little more explicit.
| return Job(func, **working_dictionary) | ||
|
|
||
| @classmethod | ||
| def from_job(cls, job, **kwargs): |
There was a problem hiding this comment.
I think I'd prefer to leave this method here and reference it elsewhere - so that it can continue to be updated in lockstep with updates to the Job constructor.
For example in this PR where I've added a new parameter to the Job object: https://github.com/learningequality/kolibri/pull/9503/files#diff-09ac69ff66caa119977d3ae21fe8dc8bf59f0eaa27b34fbb002e8446f09ca98bR151
Seeing how you're now using it below, maybe we change it from a class method to a regular method and it becomes to_constructor_args or some such?
| "facility_id": job.facility_id, | ||
| } | ||
|
|
||
| def to_representation(self, instance): |
There was a problem hiding this comment.
It took me a little while to work through in my head why this was doing something in the case of a restart, but not in any other instance.
I wonder if it might be better to not override to_representation here, and just explicitly call validate_for_restart in the API endpoint restart method to get the final data that we want?
There was a problem hiding this comment.
The hacking of a REST serializer for job validation is what makes this awkward, in my opinion.
There was a problem hiding this comment.
It's for validating data coming from the API endpoint, so I think it's a reasonable use case - any suggestions for how to update the way we're using it to make it less awkward? I was not a biggest fan of having to return and update the dict of the job args, but I couldn't think of another way while implementing it.
There was a problem hiding this comment.
It's fairly uncoupled from the API endpoints, so its implementation doesn't seem to enforce use solely through API requests. If that's the intent, it seems that the logic in Task.validate_job_data would be better placed within the TasksViewSet.validate_create_req_data method.
Otherwise, if we keep validate_job_data, then I think removing inheritance of serializers.Serializer and defining only the functionality we intend, purely validation related logic, will clarify the implementation. The to_representation method is an unimplemented method in BaseSerializer but has an implementation in the Serializer which seems we don't intend to utilize, per your comments. That would remove the validator's use case of accepting an instance, as opposed to a data object, which is the functionality that I hacked given the current structure.
There was a problem hiding this comment.
It's fairly uncoupled from the API endpoints, so its implementation doesn't seem to enforce use solely through API requests.
This is also a feature of DRF Serializers in general - they can be used for deserialization/validation outside of an API endpoint.
If that's the intent, it seems that the logic in Task.validate_job_data would be better placed within the TasksViewSet.validate_create_req_data method.
There is one place it is used outside of an API endpoint - in migrating the validate_sync_task function that it replaced, it is used not to process data from an API endpoint within the single user syncing functions.
I think removing inheritance of serializers.Serializer and defining only the functionality we intend, purely validation related logic, will clarify the implementation
This seems fine - I had not done this previously to avoid vendoring/duplicating code from DRF, but I think as long as it is using the serializer MetaClass there shouldn't be any gotchas here.
I can file a follow up issue for cleanup to avoid this being blocking here!
There was a problem hiding this comment.
they can be used for deserialization/validation outside of an API endpoint.
And serialization, like I've done here :)
There was a problem hiding this comment.
And serialization, like I've done here :)
Hah - true - maybe just some code comments to sign post it would be enough, I just had to think longer than I thought I should have to realize.
|
I want to work on this issue please assign me this issue |
|
I think I'd rather start fresh with this. I could pull bits of code from this to pull in a new PR. Just some of the Facility task panel updates look rather complicated. |
Summary
JobValidatorfor customization on a per-task basissynctasks to attempt aresumesyncif possibleReferences
Addresses #7270
Reviewer guidance
Testing checklist
PR process
Reviewer checklist
yarnandpip)