scheduled_tasks
Module with functions used to execute scheduled tasks.
See https://panel.holoviz.org/how_to/callbacks/schedule.html for details.
Classes:
Name | Description |
---|---|
CleanFilesDB |
Task action for cleaning temporary tables and files. |
ResetGuestPassword |
Task action for resetting guest user password. |
Task |
Generic task object. |
TaskAction |
Generic task action object. |
TaskManager |
Task manager object. |
UploadDBToGCP |
Task action for uploading database to Google Cloud Storage. |
Attributes:
CleanFilesDB
¶
Bases: TaskAction
Task action for cleaning temporary tables and files.
Its scope is to build a callable that will be executed when the task is triggered.
Methods:
Name | Description |
---|---|
build_callable |
Build and return the scheduled callable that cleans temporary |
Source code in dlunch/scheduled_tasks.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
build_callable
¶
build_callable(config: DictConfig) -> callable
Build and return the scheduled callable that cleans temporary tables and files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/scheduled_tasks.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
ResetGuestPassword
¶
Bases: TaskAction
Task action for resetting guest user password.
Its scope is to build a callable that will be executed when the task is triggered.
Methods:
Name | Description |
---|---|
build_callable |
Build and return the scheduled callable that resets the guest |
Source code in dlunch/scheduled_tasks.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
build_callable
¶
build_callable(config: DictConfig) -> callable
Build and return the scheduled callable that resets the guest user password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/scheduled_tasks.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
Task
¶
Generic task object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Task name (used for logs). |
required |
enabled
|
bool
|
Flag that marks a task as enabled. |
required |
hour
|
int
|
Start hour (used only if also minute is not None). |
required |
minute
|
int
|
Start minute (used only if also hour is not None). |
required |
period
|
str
|
The period between executions. May be expressed as a timedelta or a string.
|
required |
actions
|
list[TaskAction]
|
List of actions to be executed. |
required |
Methods:
Name | Description |
---|---|
__init__ |
|
build_callable |
Build and return a callable that executes all actions |
schedule_task |
Schedule a task execution using Panel. |
Attributes:
Name | Type | Description |
---|---|---|
actions |
list[TaskAction]
|
List of actions to be executed. |
enabled |
bool
|
Flag that marks a task as enabled. |
hour |
int
|
Start hour (used only if also minute is not None). |
minute |
int
|
Start minute (used only if also hour is not None). |
name |
str
|
Task name (used for logs). |
period |
str
|
The period between executions. |
Source code in dlunch/scheduled_tasks.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
period
instance-attribute
¶
The period between executions. May be expressed as a timedelta or a string.
- Week:
'1w'
- Day:
'1d'
- Hour:
'1h'
- Minute:
'1m'
- Second:
'1s'
__init__
¶
__init__(
name: str,
enabled: bool,
hour: int | None,
minute: int | None,
period: str,
actions: list[TaskAction],
) -> None
Source code in dlunch/scheduled_tasks.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
build_callable
¶
build_callable(config: DictConfig) -> callable
Build and return a callable that executes all actions in the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/scheduled_tasks.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
schedule_task
¶
schedule_task(config: DictConfig) -> None
Schedule a task execution using Panel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
If start time is not defined, the task will start immediately. If hour and minute are defined, the task will start at the specified time. If the time already passed, the task will start the next day.
Source code in dlunch/scheduled_tasks.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
TaskAction
¶
Generic task action object.
Its scope is to build a callable that will be executed when the task is triggered.
Methods:
Name | Description |
---|---|
build_callable |
Build and return the scheduled callable that executes a dummy |
Source code in dlunch/scheduled_tasks.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
build_callable
¶
build_callable(config: DictConfig) -> callable
Build and return the scheduled callable that executes a dummy task action.
It just logs a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/scheduled_tasks.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
TaskManager
¶
Task manager object.
Used to schedule all tasks given a list of tasks.
Parameters:
Methods:
Name | Description |
---|---|
__init__ |
|
log_tasks |
Log all tasks defined in the collection. |
schedule_all |
Schedule all tasks in the collection. |
Attributes:
Source code in dlunch/scheduled_tasks.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
__init__
¶
Source code in dlunch/scheduled_tasks.py
250 251 252 253 254 |
|
log_tasks
¶
log_tasks(enabled_only: bool = False) -> None
Log all tasks defined in the collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled_only
|
bool
|
If True, only enabled tasks will be listed. |
False
|
Source code in dlunch/scheduled_tasks.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
schedule_all
¶
schedule_all() -> None
Schedule all tasks in the collection.
Source code in dlunch/scheduled_tasks.py
282 283 284 285 |
|
UploadDBToGCP
¶
Bases: TaskAction
Task action for uploading database to Google Cloud Storage.
Its scope is to build a callable that will be executed when the task is triggered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
dict
|
Keyword arguments for the cloud.upload_to_gcloud function. |
{}
|
Methods:
Name | Description |
---|---|
__init__ |
|
build_callable |
Build and return the scheduled callable that uploads the database to |
Attributes:
Name | Type | Description |
---|---|---|
gcp_kwargs |
|
Source code in dlunch/scheduled_tasks.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
__init__
¶
__init__(**kwargs) -> None
Source code in dlunch/scheduled_tasks.py
117 118 |
|
build_callable
¶
build_callable(config: DictConfig) -> callable
Build and return the scheduled callable that uploads the database to Google Cloud Storage.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
DictConfig
|
Hydra configuration dictionary. |
required |
Source code in dlunch/scheduled_tasks.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|