Skip to content

Commit a84cd79

Browse files
committed
♻️ clean: remove schedule route marking.
1 parent e8b94d3 commit a84cd79

8 files changed

Lines changed: 3 additions & 283 deletions

File tree

README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,6 @@ it will use default value and do not raise any error to you.
244244
| **AUDIT_PATH** | Log | `./audits` | |
245245
| **AUDIT_ENABLE_WRITE** | Log | `true` | A flag that enable logging object saving log to its destination. |
246246

247-
**API Application**:
248-
249-
This config part use for the workflow application that build from the FastAPI
250-
only.
251-
252-
| Environment | Component | Default | Description |
253-
|:---------------------------|:-----------:|---------|------------------------------------------------------------------------------------|
254-
| **ENABLE_ROUTE_WORKFLOW** | API | `true` | A flag that enable workflow route to manage execute manually and workflow logging. |
255-
256247
## :rocket: Deployment
257248

258249
This package able to run as an application service for receive manual trigger

docs/configuration.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ and do not raise any error to you.
3434
| **AUDIT_PATH** | Log | `./audits` | |
3535
| **AUDIT_ENABLE_WRITE** | Log | `true` | A flag that enable logging object saving log to its destination. |
3636

37-
### API
38-
39-
| Environment | Component | Default | <div style="width:25em">Description</div> |
40-
|:---------------------------|:-----------:|---------|------------------------------------------------------------------------------------|
41-
| **ENABLE_ROUTE_WORKFLOW** | API | `true` | A flag that enable workflow route to manage execute manually and workflow logging. |
42-
4337
## Execution Override
4438

4539
Some config can override by an extra parameters. For the below example, I override

src/ddeutil/workflow/api/__init__.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
from ..__about__ import __version__
2121
from ..conf import api_config
2222
from ..logs import get_logger
23-
from .routes import job, log
24-
from .utils import repeat_at
23+
from .routes import job, log, workflow
2524

2625
load_dotenv()
2726
logger = get_logger("uvicorn.error")
@@ -67,53 +66,7 @@ async def health():
6766
# NOTE Add the jobs and logs routes by default.
6867
app.include_router(job, prefix=api_config.prefix_path)
6968
app.include_router(log, prefix=api_config.prefix_path)
70-
71-
72-
# NOTE: Enable the workflows route.
73-
if api_config.enable_route_workflow:
74-
from .routes import workflow
75-
76-
app.include_router(workflow, prefix=api_config.prefix_path)
77-
78-
79-
# NOTE: Enable the schedules route.
80-
# if api_config.enable_route_schedule:
81-
# from ..logs import get_audit
82-
# from ..scheduler import schedule_task
83-
# from .routes import schedule
84-
#
85-
# app.include_router(schedule, prefix=api_config.prefix_path)
86-
#
87-
# @schedule.on_event("startup")
88-
# @repeat_at(cron="* * * * *", delay=2)
89-
# def scheduler_listener():
90-
# """Schedule broker every minute at 02 second."""
91-
# logger.debug(
92-
# f"[SCHEDULER]: Start listening schedule from queue "
93-
# f"{app.state.scheduler}"
94-
# )
95-
# if app.state.workflow_tasks:
96-
# schedule_task(
97-
# app.state.workflow_tasks,
98-
# stop=datetime.now(config.tz) + timedelta(minutes=1),
99-
# queue=app.state.workflow_queue,
100-
# threads=app.state.workflow_threads,
101-
# audit=get_audit(),
102-
# )
103-
#
104-
# @schedule.on_event("startup")
105-
# @repeat_at(cron="*/5 * * * *", delay=10)
106-
# def monitoring():
107-
# """Monitoring workflow thread that running in the background."""
108-
# logger.debug("[MONITOR]: Start monitoring threading.")
109-
# snapshot_threads: list[str] = list(app.state.workflow_threads.keys())
110-
# for t_name in snapshot_threads:
111-
#
112-
# thread_release: ReleaseThread = app.state.workflow_threads[t_name]
113-
#
114-
# # NOTE: remove the thread that running success.
115-
# if not thread_release["thread"].is_alive():
116-
# app.state.workflow_threads.pop(t_name)
69+
app.include_router(workflow, prefix=api_config.prefix_path)
11770

11871

11972
@app.exception_handler(RequestValidationError)

src/ddeutil/workflow/api/utils.py

Lines changed: 0 additions & 174 deletions
This file was deleted.

src/ddeutil/workflow/conf.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
from __future__ import annotations
77

88
import copy
9-
import json
109
import os
1110
from abc import ABC, abstractmethod
1211
from collections.abc import Iterator
13-
from datetime import timedelta
1412
from functools import cached_property
1513
from inspect import isclass
1614
from pathlib import Path
@@ -163,28 +161,6 @@ def max_cron_per_workflow(self) -> int:
163161
def max_queue_complete_hist(self) -> int:
164162
return int(env("CORE_MAX_QUEUE_COMPLETE_HIST", "16"))
165163

166-
# NOTE: App
167-
@property
168-
def max_schedule_process(self) -> int:
169-
return int(env("APP_MAX_PROCESS", "2"))
170-
171-
@property
172-
def max_schedule_per_process(self) -> int:
173-
return int(env("APP_MAX_SCHEDULE_PER_PROCESS", "100"))
174-
175-
@property
176-
def stop_boundary_delta(self) -> timedelta:
177-
stop_boundary_delta_str: str = env(
178-
"APP_STOP_BOUNDARY_DELTA", '{"minutes": 5, "seconds": 20}'
179-
)
180-
try:
181-
return timedelta(**json.loads(stop_boundary_delta_str))
182-
except Exception as err:
183-
raise ValueError(
184-
"Config `WORKFLOW_APP_STOP_BOUNDARY_DELTA` can not parsing to"
185-
f"timedelta with {stop_boundary_delta_str}."
186-
) from err
187-
188164

189165
class APIConfig:
190166
"""API Config object."""
@@ -193,14 +169,6 @@ class APIConfig:
193169
def prefix_path(self) -> str:
194170
return env("API_PREFIX_PATH", "/api/v1")
195171

196-
@property
197-
def enable_route_workflow(self) -> bool:
198-
return str2bool(env("API_ENABLE_ROUTE_WORKFLOW", "true"))
199-
200-
@property
201-
def enable_route_schedule(self) -> bool:
202-
return str2bool(env("API_ENABLE_ROUTE_SCHEDULE", "true"))
203-
204172

205173
class BaseLoad(ABC): # pragma: no cov
206174
"""Base Load object is the abstraction object for any Load object that

tests/api/test_api_workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def test_workflows_get_by_name(client):
77
assert response.json() == {
88
"name": "wf-run-common",
99
"desc": "## Run Python Workflow\n\nThis is a running python workflow\n",
10-
"params": {"name": {}},
10+
"params": {"name": {"type": "str"}},
1111
"on": [{"cronjob": "*/5 * * * *", "timezone": "Asia/Bangkok"}],
1212
"jobs": {
1313
"demo-run": {

tests/test_conf.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919

2020

2121
def test_config():
22-
origin_stop = os.getenv("WORKFLOW_APP_STOP_BOUNDARY_DELTA")
23-
os.environ["WORKFLOW_APP_STOP_BOUNDARY_DELTA"] = "{"
24-
25-
with pytest.raises(ValueError):
26-
_ = Config().stop_boundary_delta
27-
28-
os.environ["WORKFLOW_APP_STOP_BOUNDARY_DELTA"] = origin_stop
29-
3022
conf = Config()
3123
os.environ["WORKFLOW_CORE_TIMEZONE"] = "Asia/Bangkok"
3224
assert conf.tz == ZoneInfo("Asia/Bangkok")

tests/utils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ def dotenv_setting() -> None:
4242
WORKFLOW_CORE_GENERATE_ID_SIMPLE_MODE=true
4343
WORKFLOW_LOG_TRACE_ENABLE_WRITE=false
4444
WORKFLOW_LOG_AUDIT_ENABLE_WRITE=true
45-
WORKFLOW_APP_MAX_PROCESS=2
46-
WORKFLOW_APP_STOP_BOUNDARY_DELTA='{{"minutes": 5, "seconds": 20}}'
47-
WORKFLOW_API_ENABLE_ROUTE_WORKFLOW=true
48-
WORKFLOW_API_ENABLE_ROUTE_SCHEDULE=true
4945
"""
5046
).strip()
5147
env_path.write_text(env_str)

0 commit comments

Comments
 (0)