clockwork 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {clockwork-0.2.1 → clockwork-0.2.2}/PKG-INFO +2 -2
- clockwork-0.2.2/clockwork/__init__.py +4 -0
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/_base.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/_month_end.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/_quarter_end.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/core.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/decorators.py +0 -1
- clockwork-0.2.2/clockwork/taskmaster/_scheduler.py +27 -0
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/_task.py +4 -3
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/file_monitor.py +5 -6
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/logger.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/taskmaster.py +1 -2
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/utils.py +0 -1
- {clockwork-0.2.1 → clockwork-0.2.2}/pyproject.toml +2 -2
- clockwork-0.2.1/clockwork/__init__.py +0 -4
- clockwork-0.2.1/clockwork/taskmaster/_scheduler.py +0 -20
- {clockwork-0.2.1 → clockwork-0.2.2}/LICENSE +0 -0
- {clockwork-0.2.1 → clockwork-0.2.2}/README.md +0 -0
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/__init__.py +0 -0
- {clockwork-0.2.1 → clockwork-0.2.2}/clockwork/taskmaster/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: clockwork
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Toolkit for time-related operations including scheduling, logging, date manipulation, and more.
|
|
5
5
|
Home-page: https://github.com/zteinck/clockwork
|
|
6
6
|
License: MIT
|
|
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Requires-Dist: holidays
|
|
18
|
-
Requires-Dist: iterlab
|
|
19
18
|
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: oddments
|
|
20
20
|
Requires-Dist: pandas
|
|
21
21
|
Requires-Dist: pathpilot
|
|
22
22
|
Requires-Dist: schedule
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
from schedule import Scheduler, CancelJob
|
|
3
|
+
|
|
4
|
+
from .utils import ContinueFailedJob
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TaskScheduler(Scheduler):
|
|
8
|
+
|
|
9
|
+
#╭-------------------------------------------------------------------------╮
|
|
10
|
+
#| Initialize Instance |
|
|
11
|
+
#╰-------------------------------------------------------------------------╯
|
|
12
|
+
|
|
13
|
+
def __init__(self, *args, **kwargs):
|
|
14
|
+
super().__init__(*args, **kwargs)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#╭-------------------------------------------------------------------------╮
|
|
18
|
+
#| Instance Methods |
|
|
19
|
+
#╰-------------------------------------------------------------------------╯
|
|
20
|
+
|
|
21
|
+
def _run_job(self, job):
|
|
22
|
+
ret = job.run()
|
|
23
|
+
if ret is CancelJob:
|
|
24
|
+
self.cancel_job(job)
|
|
25
|
+
elif ret is ContinueFailedJob:
|
|
26
|
+
job.last_run = datetime.datetime.now()
|
|
27
|
+
job._schedule_next_run()
|
|
@@ -8,7 +8,6 @@ from ..utils import elapsed_time
|
|
|
8
8
|
from .utils import PrerequisiteError, ContinueFailedJob
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
12
11
|
class Task(object):
|
|
13
12
|
'''
|
|
14
13
|
Description
|
|
@@ -35,7 +34,8 @@ class Task(object):
|
|
|
35
34
|
at : str
|
|
36
35
|
at time string
|
|
37
36
|
expiry : Date
|
|
38
|
-
If not None, job will be set inactive and stop running after this
|
|
37
|
+
If not None, job will be set inactive and stop running after this
|
|
38
|
+
datetime
|
|
39
39
|
func : func
|
|
40
40
|
function to run
|
|
41
41
|
args : tuple
|
|
@@ -172,7 +172,8 @@ class Task(object):
|
|
|
172
172
|
print(f' @ {Date()} ->', end=' ')
|
|
173
173
|
print('Job Cancelled')
|
|
174
174
|
|
|
175
|
-
# cancel job if it was cancelled on cascasde or
|
|
175
|
+
# cancel job if it was cancelled on cascasde or
|
|
176
|
+
# if it was set inactive after being scheduled
|
|
176
177
|
if self.status == self.cascade_status or \
|
|
177
178
|
not self.master.is_active(self.name, self.at):
|
|
178
179
|
return CancelJob
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
from .utils import PrerequisiteError
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
class FileMonitor(object):
|
|
6
5
|
'''
|
|
7
6
|
Description
|
|
8
7
|
--------------------
|
|
9
8
|
Monitors a folder for new files and passes latest and 2nd latest file
|
|
10
|
-
names to user-defined function. Class is intended to be used in
|
|
11
|
-
with TaskMaster as a func argument which allows for file
|
|
12
|
-
intervals.
|
|
9
|
+
names to user-defined function. Class is intended to be used in
|
|
10
|
+
conjunction with TaskMaster as a func argument which allows for file
|
|
11
|
+
monitoring at regular intervals.
|
|
13
12
|
|
|
14
13
|
Class Attributes
|
|
15
14
|
--------------------
|
|
@@ -18,8 +17,8 @@ class FileMonitor(object):
|
|
|
18
17
|
Instance Attributes
|
|
19
18
|
--------------------
|
|
20
19
|
func : func
|
|
21
|
-
Custom function that takes the latest and second-latest file names
|
|
22
|
-
folder as the first and second arguments, respectively.
|
|
20
|
+
Custom function that takes the latest and second-latest file names
|
|
21
|
+
in a folder as the first and second arguments, respectively.
|
|
23
22
|
folder : Folder object
|
|
24
23
|
folder to monitor for new files.
|
|
25
24
|
filter_kwargs : dict
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import time
|
|
3
3
|
import uuid
|
|
4
|
-
from
|
|
4
|
+
from oddments import to_iter
|
|
5
5
|
from pathpilot import Folder
|
|
6
6
|
|
|
7
7
|
from ..core import Date
|
|
@@ -9,7 +9,6 @@ from ._scheduler import TaskScheduler
|
|
|
9
9
|
from ._task import Task
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
#╭-------------------------------------------------------------------------╮
|
|
14
13
|
#| Classes |
|
|
15
14
|
#╰-------------------------------------------------------------------------╯
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "clockwork"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.2"
|
|
4
4
|
description = "Toolkit for time-related operations including scheduling, logging, date manipulation, and more."
|
|
5
5
|
authors = ["Zachary Einck <zacharyeinck@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -12,7 +12,7 @@ homepage = "https://github.com/zteinck/clockwork"
|
|
|
12
12
|
python = "^3.8"
|
|
13
13
|
pandas = "*"
|
|
14
14
|
numpy = "*"
|
|
15
|
-
|
|
15
|
+
oddments = "*"
|
|
16
16
|
pathpilot = "*"
|
|
17
17
|
schedule = "*"
|
|
18
18
|
holidays = "*"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
from schedule import Scheduler, CancelJob
|
|
3
|
-
|
|
4
|
-
from .utils import ContinueFailedJob
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TaskScheduler(Scheduler):
|
|
9
|
-
|
|
10
|
-
def __init__(self):
|
|
11
|
-
super().__init__()
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def _run_job(self, job):
|
|
15
|
-
ret = job.run()
|
|
16
|
-
if ret is CancelJob:
|
|
17
|
-
self.cancel_job(job)
|
|
18
|
-
elif ret is ContinueFailedJob:
|
|
19
|
-
job.last_run = datetime.datetime.now()
|
|
20
|
-
job._schedule_next_run()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|