lucos-schedule-tracker-pythonclient 1.0.30__py3-none-any.whl → 2.0.0__py3-none-any.whl

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.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: lucos_schedule_tracker_pythonclient
3
+ Version: 2.0.0
4
+ Summary: Python library for sending updates to lucos_schedule_tracker
5
+ Classifier: Programming Language :: Python :: 3
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: requests>=2.28
9
+
10
+ # lucos_schedule_tracker_pythonclient
11
+
12
+ Python library for sending updates to [lucos_schedule_tracker](https://github.com/lucas42/lucos_schedule_tracker).
13
+
14
+ This library posts to the v2 `/report-status` endpoint. See [ADR-0004](https://github.com/lucas42/lucos/blob/main/docs/adr/0004-scheduled-jobs-monitoring-architecture.md) for the architectural background on `system` vs `job_name`.
15
+
16
+ ## Configuration
17
+
18
+ The following environment variables must be set for the library to function:
19
+
20
+ * **`SYSTEM`**: A unique identifier for the system being tracked. This is used as the `User-Agent` header and as the default `system` name in reports.
21
+ * **`SCHEDULE_TRACKER_ENDPOINT`**: The v2 report endpoint URL of the `lucos_schedule_tracker` instance (e.g., `https://schedule-tracker.example.com/v2/report-status`). The URL must contain `/v2/` — the library validates this at startup and exits with an error if it does not.
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+ from schedule_tracker import updateScheduleTracker
27
+
28
+ # Report a successful run
29
+ updateScheduleTracker(True, "ingestor_dbpedia")
30
+
31
+ # Report a failure with a message
32
+ updateScheduleTracker(False, "ingestor_loc", message="Database connection failed")
33
+ ```
34
+
35
+ ## API Reference
36
+
37
+ ### `updateScheduleTracker(success: bool, job_name: str, system: str = SYSTEM, message: str | None = None, frequency: int = 86400)`
38
+
39
+ Sends a status update to the v2 schedule tracker endpoint.
40
+
41
+ * **`success`** (*bool*, required): Whether the job completed successfully.
42
+ * **`job_name`** (*str*, required): A sub-job identifier within the system (e.g. `"ingestor_dbpedia_meanOfTransportation"`). Naming the job explicitly makes it easier to add further jobs to the same system later without schema changes.
43
+ * **`system`** (*str*, optional): The identifier for the owning system (e.g. `"lucos_arachne"`). Defaults to the value of the `SYSTEM` environment variable.
44
+ * **`message`** (*str | None*, optional): A human-readable message, typically used to provide details on failure.
45
+ * **`frequency`** (*int*, optional): How often the job is expected to run, in seconds. Defaults to `86400` (24 hours).
@@ -0,0 +1,5 @@
1
+ schedule_tracker.py,sha256=NChovy2osw_O1DPcSYZa-5av0Hr1IN9OLA3Hj5ViBJQ,2563
2
+ lucos_schedule_tracker_pythonclient-2.0.0.dist-info/METADATA,sha256=E4ihUz87AQFHYG54IvS8v0D0uAVi4E-71rYAC-3aOzg,2400
3
+ lucos_schedule_tracker_pythonclient-2.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
4
+ lucos_schedule_tracker_pythonclient-2.0.0.dist-info/top_level.txt,sha256=8rZs9mXbH-upOjeJSeQXcwZEWqs4pHwz-WbF83YVy7Y,17
5
+ lucos_schedule_tracker_pythonclient-2.0.0.dist-info/RECORD,,
schedule_tracker.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import os, sys, requests
2
2
  from datetime import datetime
3
+ from typing import Optional
3
4
 
4
5
  try:
5
6
  SYSTEM = os.environ["SYSTEM"]
@@ -8,7 +9,10 @@ except KeyError:
8
9
  try:
9
10
  SCHEDULE_TRACKER_ENDPOINT = os.environ["SCHEDULE_TRACKER_ENDPOINT"]
10
11
  except KeyError:
11
- sys.exit("\033[91mSCHEDULE_TRACKER_ENDPOINT environment variable not set - needs to be the URL of a running lucos_schedule_tracker instance\033[0m")
12
+ sys.exit("\033[91mSCHEDULE_TRACKER_ENDPOINT environment variable not set - must be the v2 endpoint URL of a running lucos_schedule_tracker instance (e.g. http://host/v2/report-status)\033[0m")
13
+
14
+ if "/v2/" not in SCHEDULE_TRACKER_ENDPOINT:
15
+ sys.exit("\033[91mSCHEDULE_TRACKER_ENDPOINT must point at the v2 endpoint (e.g. http://host/v2/report-status) — got: {}\033[0m".format(SCHEDULE_TRACKER_ENDPOINT))
12
16
 
13
17
  session = requests.Session()
14
18
  session.headers.update({
@@ -16,12 +20,21 @@ session.headers.update({
16
20
  "Content-Type": "application/json",
17
21
  })
18
22
 
19
- def updateScheduleTracker(success: bool, system: str = SYSTEM, message: str = None, frequency: int = (24 * 60 * 60)):
23
+ def updateScheduleTracker(success: bool, job_name: str, system: str = SYSTEM, message: Optional[str] = None, frequency: int = (24 * 60 * 60)):
20
24
  """Report the outcome of a scheduled run to lucos_schedule_tracker.
21
25
 
26
+ Posts to the v2 /report-status endpoint.
27
+
22
28
  Args:
23
29
  success: Whether the job completed successfully.
24
- system: Identifier of the calling system. Defaults to the SYSTEM env var.
30
+ job_name: Sub-job identifier within the system (e.g.
31
+ "ingestor_dbpedia_meanOfTransportation"). Required — naming the job
32
+ explicitly makes it easier to add further jobs to the same system
33
+ later without schema changes. See ADR-0004 for the architectural
34
+ background:
35
+ https://github.com/lucas42/lucos/blob/main/docs/adr/0004-scheduled-jobs-monitoring-architecture.md
36
+ system: Identifier of the owning system (e.g. "lucos_arachne"). Defaults
37
+ to the SYSTEM env var.
25
38
  message: Optional human-readable detail, typically used to describe a
26
39
  failure.
27
40
  frequency: How often this job is genuinely scheduled to run, in seconds.
@@ -33,6 +46,7 @@ def updateScheduleTracker(success: bool, system: str = SYSTEM, message: str = No
33
46
  """
34
47
  payload = {
35
48
  "system": system,
49
+ "job_name": job_name,
36
50
  "frequency": frequency,
37
51
  "status": "success" if success else "error",
38
52
  "message": message,
@@ -41,4 +55,4 @@ def updateScheduleTracker(success: bool, system: str = SYSTEM, message: str = No
41
55
  schedule_tracker_response = requests.post(SCHEDULE_TRACKER_ENDPOINT, json=payload, timeout=30)
42
56
  schedule_tracker_response.raise_for_status()
43
57
  except Exception as error:
44
- print("\033[91m [{}] ** Error calling schedule-tracker: {}\033[0m".format(datetime.now().isoformat(), error), flush=True)
58
+ print("\033[91m [{}] ** Error calling schedule-tracker: {}\033[0m".format(datetime.now().isoformat(), error), flush=True)
@@ -1,42 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: lucos_schedule_tracker_pythonclient
3
- Version: 1.0.30
4
- Summary: Python library for sending updates to lucos_schedule_tracker
5
- Classifier: Programming Language :: Python :: 3
6
- Requires-Python: >=3.8
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: requests>=2.28
9
-
10
- # lucos_schedule_tracker_pythonclient
11
-
12
- Python library for sending updates to [lucos_schedule_tracker](https://github.com/lucas42/lucos_schedule_tracker).
13
-
14
- ## Configuration
15
-
16
- The following environment variables must be set for the library to function:
17
-
18
- * **`SYSTEM`**: A unique identifier for the system or job being tracked. This is used as the `User-Agent` header and as the default `system` name in reports.
19
- * **`SCHEDULE_TRACKER_ENDPOINT`**: The full URL of the `lucos_schedule_tracker` instance's report endpoint (e.g., `https://schedule-tracker.example.com/report-status`).
20
-
21
- ## Usage
22
-
23
- ```python
24
- from schedule_tracker import updateScheduleTracker
25
-
26
- # Report a successful run
27
- updateScheduleTracker(success=True)
28
-
29
- # Report a failure with a message
30
- updateScheduleTracker(success=False, message="Database connection failed")
31
- ```
32
-
33
- ## API Reference
34
-
35
- ### `updateScheduleTracker(success: bool, system: str = SYSTEM, message: str = None, frequency: int = 86400)`
36
-
37
- Sends a status update to the schedule tracker.
38
-
39
- * **`success`** (*bool*, required): Whether the job completed successfully.
40
- * **`system`** (*str*, optional): The identifier for the system. Defaults to the value of the `SYSTEM` environment variable.
41
- * **`message`** (*str*, optional): A human-readable message, typically used to provide details on failure.
42
- * **`frequency`** (*int*, optional): How often the job is expected to run, in seconds. Defaults to `86400` (24 hours).
@@ -1,5 +0,0 @@
1
- schedule_tracker.py,sha256=FJ-ZEmhbNohnfNPFdkdjY_DFaHqmdU3LInTDfhjs3lM,1780
2
- lucos_schedule_tracker_pythonclient-1.0.30.dist-info/METADATA,sha256=VY0gxhNRjCgMGUcMh0IiIX0ihhQX1ndD4BqUZ_TTNRA,1736
3
- lucos_schedule_tracker_pythonclient-1.0.30.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
4
- lucos_schedule_tracker_pythonclient-1.0.30.dist-info/top_level.txt,sha256=8rZs9mXbH-upOjeJSeQXcwZEWqs4pHwz-WbF83YVy7Y,17
5
- lucos_schedule_tracker_pythonclient-1.0.30.dist-info/RECORD,,