-
Notifications
You must be signed in to change notification settings - Fork 160
Changing the Core Models
When adding new features, it may be necessary to add new information to the core classes in core.py: Dagobah, Job, and Task. There are a few places in which you will need to perform your changes. Unfortunately, each of these changes are slightly different than the others, so it was decided that it would be overly complex to abstract out all the differences in the code base itself. Rather than consolidating the changes through a complex config object, the steps are documented here to assist you. You can see our original discussion on this topic here.
Please consider these steps as guidelines rather than an exhaustive list; the best way to make sure your changes work correctly is to implement solid tests.
-
Initialize
new_var
to its starting value in the class's constructor. Ifnew_var
does not have a meaningful starting value, initialize it toNone
. -
If necessary, create a setter for
new_var
similar toTask.set_soft_timeout
. -
If
new_var
can be set when the class is constructed, apply this change to the constructor. By convention, optional constructor arguments are passed around methods as **kwargs. You should therefore definenew_var
as a kwarg in the constructor. -
Update any relevant API calls in
daemon/api.py
, or creation/updating methods incore.py
, to considernew_var
. -
If
new_var
should be permanently stored in the backend or made available to the frontend, for example a Task's soft timeout or a Job's name, do the following:- Add
new_var
to the_serialize
method on its class. - Add
new_var
to all available backends, using the existing code as a guide. - Add a new Alembic revision to handle this migration for SQL-based backends. See SQL Migrations using Alembic.
- Add
-
Test whatever you can because it makes you awesome.