refactor(setup_schedules): Reduce duplication and improve maintainability. Closes #822#824
Conversation
|
HI @regulartim I did not explicitly mention in the issue that I would use a JSON-based configuration file. While refactoring, I noticed a similar pattern with ml_config.json and decided to follow that structure for consistency and maintainability. Is this structure is fine for you? |
regulartim
left a comment
There was a problem hiding this comment.
Hey @drona-gyawali !
Is this structure is fine for you?
Yeah, it's fine. But I am not sure what we actually gain by using a json file. Looking at this, I wonder if a python list of dicts in schedules.py would be a better solution. Some drawbacks of the json approach:
- introduces file I/O and json parsing, which can fail and should therefore be tested
- the file isn't really pure configuration, as it contains hardcoded import paths
- it contains magic strings "inteverval" and "calc_train_time"
So as you can see, I am a little skeptical. What I do like however is that the active_schedules are not a separate list anymore.
What do you think about that? What's your opinion on the list of dicts idea?
I just wanted to clarify that the JSON-based file configuration I tried was purely for experimentation to test an idea. I now completely understand your concerns, and I agree that simpler is better. So I am planing to refactored setup_schedules() to use a single Python function with:
This approach preserves all existing functional behavior, so no new tests are required the current tests already cover the tasks themselves. Does this sound good to you? |
That's fine! :)
Don't put too much effort into that. I have an idea how to schedule the training in a better way. Will probably do that soon.
Yes, sounds good. Feel free to implement. |
regulartim
left a comment
There was a problem hiding this comment.
Very nice, I like it! :) I only have two minor suggestions.
Description
This PR refactors setup_schedules() to remove repeated update_or_create() blocks and centralize cron job definitions.
Related issues
closes: #822
Type of change
Please delete options that are not relevant.
Checklist
develop.Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.Important Rules