orchestrator-core 4.4.0rc2__py3-none-any.whl → 5.0.0a1__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.
- orchestrator/__init__.py +1 -1
- orchestrator/api/api_v1/api.py +7 -0
- orchestrator/api/api_v1/endpoints/agent.py +62 -0
- orchestrator/api/api_v1/endpoints/processes.py +6 -12
- orchestrator/api/api_v1/endpoints/search.py +197 -0
- orchestrator/api/api_v1/endpoints/subscriptions.py +0 -1
- orchestrator/app.py +4 -0
- orchestrator/cli/index_llm.py +73 -0
- orchestrator/cli/main.py +8 -1
- orchestrator/cli/resize_embedding.py +136 -0
- orchestrator/cli/scheduler.py +29 -40
- orchestrator/cli/search_explore.py +203 -0
- orchestrator/db/models.py +37 -1
- orchestrator/graphql/schema.py +0 -5
- orchestrator/graphql/schemas/process.py +2 -2
- orchestrator/graphql/utils/create_resolver_error_handler.py +1 -1
- orchestrator/migrations/versions/schema/2025-08-12_52b37b5b2714_search_index_model_for_llm_integration.py +95 -0
- orchestrator/schedules/__init__.py +2 -1
- orchestrator/schedules/resume_workflows.py +2 -2
- orchestrator/schedules/scheduling.py +24 -64
- orchestrator/schedules/task_vacuum.py +2 -2
- orchestrator/schedules/validate_products.py +2 -8
- orchestrator/schedules/validate_subscriptions.py +2 -2
- orchestrator/schemas/search.py +101 -0
- orchestrator/search/__init__.py +0 -0
- orchestrator/search/agent/__init__.py +1 -0
- orchestrator/search/agent/prompts.py +62 -0
- orchestrator/search/agent/state.py +8 -0
- orchestrator/search/agent/tools.py +122 -0
- orchestrator/search/core/__init__.py +0 -0
- orchestrator/search/core/embedding.py +64 -0
- orchestrator/search/core/exceptions.py +16 -0
- orchestrator/search/core/types.py +162 -0
- orchestrator/search/core/validators.py +27 -0
- orchestrator/search/docs/index.md +37 -0
- orchestrator/search/docs/running_local_text_embedding_inference.md +45 -0
- orchestrator/search/filters/__init__.py +27 -0
- orchestrator/search/filters/base.py +236 -0
- orchestrator/search/filters/date_filters.py +75 -0
- orchestrator/search/filters/definitions.py +76 -0
- orchestrator/search/filters/ltree_filters.py +31 -0
- orchestrator/search/filters/numeric_filter.py +60 -0
- orchestrator/search/indexing/__init__.py +3 -0
- orchestrator/search/indexing/indexer.py +316 -0
- orchestrator/search/indexing/registry.py +88 -0
- orchestrator/search/indexing/tasks.py +53 -0
- orchestrator/search/indexing/traverse.py +209 -0
- orchestrator/search/retrieval/__init__.py +3 -0
- orchestrator/search/retrieval/builder.py +64 -0
- orchestrator/search/retrieval/engine.py +96 -0
- orchestrator/search/retrieval/ranker.py +202 -0
- orchestrator/search/retrieval/utils.py +88 -0
- orchestrator/search/retrieval/validation.py +174 -0
- orchestrator/search/schemas/__init__.py +0 -0
- orchestrator/search/schemas/parameters.py +114 -0
- orchestrator/search/schemas/results.py +47 -0
- orchestrator/services/processes.py +11 -16
- orchestrator/services/subscriptions.py +0 -4
- orchestrator/settings.py +29 -1
- orchestrator/targets.py +0 -1
- orchestrator/workflow.py +1 -8
- orchestrator/workflows/utils.py +1 -48
- {orchestrator_core-4.4.0rc2.dist-info → orchestrator_core-5.0.0a1.dist-info}/METADATA +6 -3
- {orchestrator_core-4.4.0rc2.dist-info → orchestrator_core-5.0.0a1.dist-info}/RECORD +66 -30
- orchestrator/graphql/resolvers/scheduled_tasks.py +0 -36
- orchestrator/graphql/schemas/scheduled_task.py +0 -8
- orchestrator/schedules/scheduler.py +0 -163
- {orchestrator_core-4.4.0rc2.dist-info → orchestrator_core-5.0.0a1.dist-info}/WHEEL +0 -0
- {orchestrator_core-4.4.0rc2.dist-info → orchestrator_core-5.0.0a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import structlog
|
|
2
|
-
|
|
3
|
-
from orchestrator.db.filters import Filter
|
|
4
|
-
from orchestrator.db.sorting import Sort
|
|
5
|
-
from orchestrator.graphql.pagination import Connection
|
|
6
|
-
from orchestrator.graphql.schemas.scheduled_task import ScheduledTaskGraphql
|
|
7
|
-
from orchestrator.graphql.types import GraphqlFilter, GraphqlSort, OrchestratorInfo
|
|
8
|
-
from orchestrator.graphql.utils import create_resolver_error_handler, to_graphql_result_page
|
|
9
|
-
from orchestrator.graphql.utils.is_query_detailed import is_querying_page_data
|
|
10
|
-
from orchestrator.schedules.scheduler import get_scheduler_tasks, scheduled_task_filter_keys, scheduled_task_sort_keys
|
|
11
|
-
|
|
12
|
-
logger = structlog.get_logger(__name__)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
async def resolve_scheduled_tasks(
|
|
16
|
-
info: OrchestratorInfo,
|
|
17
|
-
filter_by: list[GraphqlFilter] | None = None,
|
|
18
|
-
sort_by: list[GraphqlSort] | None = None,
|
|
19
|
-
first: int = 10,
|
|
20
|
-
after: int = 0,
|
|
21
|
-
) -> Connection[ScheduledTaskGraphql]:
|
|
22
|
-
_error_handler = create_resolver_error_handler(info)
|
|
23
|
-
|
|
24
|
-
pydantic_filter_by: list[Filter] = [item.to_pydantic() for item in filter_by] if filter_by else []
|
|
25
|
-
pydantic_sort_by: list[Sort] = [item.to_pydantic() for item in sort_by] if sort_by else []
|
|
26
|
-
scheduled_tasks, total = get_scheduler_tasks(
|
|
27
|
-
first=first, after=after, filter_by=pydantic_filter_by, sort_by=pydantic_sort_by, error_handler=_error_handler
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
graphql_scheduled_tasks = []
|
|
31
|
-
if is_querying_page_data(info):
|
|
32
|
-
graphql_scheduled_tasks = [ScheduledTaskGraphql.from_pydantic(p) for p in scheduled_tasks]
|
|
33
|
-
|
|
34
|
-
return to_graphql_result_page(
|
|
35
|
-
graphql_scheduled_tasks, first, after, total, scheduled_task_filter_keys, scheduled_task_sort_keys
|
|
36
|
-
)
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
# Copyright 2019-2020 SURF.
|
|
2
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
# you may not use this file except in compliance with the License.
|
|
4
|
-
# You may obtain a copy of the License at
|
|
5
|
-
#
|
|
6
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
#
|
|
8
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
# See the License for the specific language governing permissions and
|
|
12
|
-
# limitations under the License.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
from contextlib import contextmanager
|
|
16
|
-
from datetime import datetime
|
|
17
|
-
from typing import Any, Generator
|
|
18
|
-
|
|
19
|
-
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
|
|
20
|
-
from apscheduler.schedulers.background import BackgroundScheduler
|
|
21
|
-
from more_itertools import partition
|
|
22
|
-
from pydantic import BaseModel
|
|
23
|
-
|
|
24
|
-
from orchestrator.db.filters import Filter
|
|
25
|
-
from orchestrator.db.filters.filters import CallableErrorHandler
|
|
26
|
-
from orchestrator.db.sorting import Sort
|
|
27
|
-
from orchestrator.db.sorting.sorting import SortOrder
|
|
28
|
-
from orchestrator.settings import app_settings
|
|
29
|
-
from orchestrator.utils.helpers import camel_to_snake, to_camel
|
|
30
|
-
|
|
31
|
-
jobstores = {"default": SQLAlchemyJobStore(url=str(app_settings.DATABASE_URI))}
|
|
32
|
-
|
|
33
|
-
scheduler = BackgroundScheduler(jobstores=jobstores)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def scheduler_dispose_db_connections() -> None:
|
|
37
|
-
jobstores["default"].engine.dispose()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@contextmanager
|
|
41
|
-
def get_paused_scheduler() -> Generator[BackgroundScheduler, Any, None]:
|
|
42
|
-
scheduler.start(paused=True)
|
|
43
|
-
|
|
44
|
-
try:
|
|
45
|
-
yield scheduler
|
|
46
|
-
finally:
|
|
47
|
-
scheduler.shutdown(wait=False)
|
|
48
|
-
scheduler_dispose_db_connections()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class ScheduledTask(BaseModel):
|
|
52
|
-
id: str
|
|
53
|
-
name: str | None = None
|
|
54
|
-
next_run_time: datetime | None = None
|
|
55
|
-
trigger: str
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
scheduled_task_keys = set(ScheduledTask.model_fields.keys())
|
|
59
|
-
scheduled_task_filter_keys = sorted(scheduled_task_keys | {to_camel(key) for key in scheduled_task_keys})
|
|
60
|
-
scheduled_task_sort_keys = scheduled_task_filter_keys
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def scheduled_task_in_filter(job: ScheduledTask, filter_by: list[Filter]) -> bool:
|
|
64
|
-
return any(f.value.lower() in getattr(job, camel_to_snake(f.field), "").lower() for f in filter_by)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def filter_scheduled_tasks(
|
|
68
|
-
scheduled_tasks: list[ScheduledTask],
|
|
69
|
-
handle_filter_error: CallableErrorHandler,
|
|
70
|
-
filter_by: list[Filter] | None = None,
|
|
71
|
-
) -> list[ScheduledTask]:
|
|
72
|
-
if not filter_by:
|
|
73
|
-
return scheduled_tasks
|
|
74
|
-
|
|
75
|
-
try:
|
|
76
|
-
invalid_filters, valid_filters = partition(lambda x: x.field in scheduled_task_filter_keys, filter_by)
|
|
77
|
-
|
|
78
|
-
if invalid_list := [item.field for item in invalid_filters]:
|
|
79
|
-
handle_filter_error(
|
|
80
|
-
"Invalid filter arguments", invalid_filters=invalid_list, valid_filter_keys=scheduled_task_filter_keys
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
valid_filter_list = list(valid_filters)
|
|
84
|
-
return [task for task in scheduled_tasks if scheduled_task_in_filter(task, valid_filter_list)]
|
|
85
|
-
except Exception as e:
|
|
86
|
-
handle_filter_error(str(e))
|
|
87
|
-
return []
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def _invert(value: Any) -> Any:
|
|
91
|
-
"""Invert value for descending order."""
|
|
92
|
-
if isinstance(value, (int, float)):
|
|
93
|
-
return -value
|
|
94
|
-
if isinstance(value, str):
|
|
95
|
-
return tuple(-ord(c) for c in value)
|
|
96
|
-
if isinstance(value, datetime):
|
|
97
|
-
return -value.timestamp()
|
|
98
|
-
return value
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def sort_key(sort_field: str, sort_order: SortOrder) -> Any:
|
|
102
|
-
def _sort_key(task: Any) -> Any:
|
|
103
|
-
value = getattr(task, camel_to_snake(sort_field), None)
|
|
104
|
-
if sort_field == "next_run_time" and value is None:
|
|
105
|
-
return float("inf") if sort_order == SortOrder.ASC else float("-inf")
|
|
106
|
-
return value if sort_order == SortOrder.ASC else _invert(value)
|
|
107
|
-
|
|
108
|
-
return _sort_key
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def sort_scheduled_tasks(
|
|
112
|
-
scheduled_tasks: list[ScheduledTask], handle_sort_error: CallableErrorHandler, sort_by: list[Sort] | None = None
|
|
113
|
-
) -> list[ScheduledTask]:
|
|
114
|
-
if not sort_by:
|
|
115
|
-
return scheduled_tasks
|
|
116
|
-
|
|
117
|
-
try:
|
|
118
|
-
invalid_sorting, valid_sorting = partition(lambda x: x.field in scheduled_task_sort_keys, sort_by)
|
|
119
|
-
if invalid_list := [item.field for item in invalid_sorting]:
|
|
120
|
-
handle_sort_error(
|
|
121
|
-
"Invalid sort arguments", invalid_sorting=invalid_list, valid_sort_keys=scheduled_task_sort_keys
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
valid_sort_list = list(valid_sorting)
|
|
125
|
-
return sorted(
|
|
126
|
-
scheduled_tasks, key=lambda task: tuple(sort_key(sort.field, sort.order)(task) for sort in valid_sort_list)
|
|
127
|
-
)
|
|
128
|
-
except Exception as e:
|
|
129
|
-
handle_sort_error(str(e))
|
|
130
|
-
return []
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def default_error_handler(message: str, **context) -> None: # type: ignore
|
|
134
|
-
from orchestrator.graphql.utils.create_resolver_error_handler import _format_context
|
|
135
|
-
|
|
136
|
-
raise ValueError(f"{message} {_format_context(context)}")
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def get_scheduler_tasks(
|
|
140
|
-
first: int = 10,
|
|
141
|
-
after: int = 0,
|
|
142
|
-
filter_by: list[Filter] | None = None,
|
|
143
|
-
sort_by: list[Sort] | None = None,
|
|
144
|
-
error_handler: CallableErrorHandler = default_error_handler,
|
|
145
|
-
) -> tuple[list[ScheduledTask], int]:
|
|
146
|
-
with get_paused_scheduler() as pauzed_scheduler:
|
|
147
|
-
scheduled_tasks = pauzed_scheduler.get_jobs()
|
|
148
|
-
|
|
149
|
-
scheduled_tasks = filter_scheduled_tasks(scheduled_tasks, error_handler, filter_by)
|
|
150
|
-
scheduled_tasks = sort_scheduled_tasks(scheduled_tasks, error_handler, sort_by)
|
|
151
|
-
|
|
152
|
-
total = len(scheduled_tasks)
|
|
153
|
-
paginated_tasks = scheduled_tasks[after : after + first + 1]
|
|
154
|
-
|
|
155
|
-
return [
|
|
156
|
-
ScheduledTask(
|
|
157
|
-
id=task.id,
|
|
158
|
-
name=task.name,
|
|
159
|
-
next_run_time=task.next_run_time,
|
|
160
|
-
trigger=str(task.trigger),
|
|
161
|
-
)
|
|
162
|
-
for task in paginated_tasks
|
|
163
|
-
], total
|
|
File without changes
|
{orchestrator_core-4.4.0rc2.dist-info → orchestrator_core-5.0.0a1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|