orchestrator-core 4.4.0rc1__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/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 -39
- 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/settings.py +29 -1
- orchestrator/workflow.py +1 -8
- {orchestrator_core-4.4.0rc1.dist-info → orchestrator_core-5.0.0a1.dist-info}/METADATA +6 -3
- {orchestrator_core-4.4.0rc1.dist-info → orchestrator_core-5.0.0a1.dist-info}/RECORD +62 -26
- orchestrator/graphql/resolvers/scheduled_tasks.py +0 -36
- orchestrator/graphql/schemas/scheduled_task.py +0 -8
- orchestrator/schedules/scheduler.py +0 -153
- {orchestrator_core-4.4.0rc1.dist-info → orchestrator_core-5.0.0a1.dist-info}/WHEEL +0 -0
- {orchestrator_core-4.4.0rc1.dist-info → orchestrator_core-5.0.0a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,153 +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 datetime import datetime
|
|
16
|
-
from typing import Any
|
|
17
|
-
|
|
18
|
-
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
|
|
19
|
-
from apscheduler.schedulers.background import BackgroundScheduler
|
|
20
|
-
from more_itertools import partition
|
|
21
|
-
from pydantic import BaseModel
|
|
22
|
-
|
|
23
|
-
from orchestrator.db.filters import Filter
|
|
24
|
-
from orchestrator.db.filters.filters import CallableErrorHandler
|
|
25
|
-
from orchestrator.db.sorting import Sort
|
|
26
|
-
from orchestrator.db.sorting.sorting import SortOrder
|
|
27
|
-
from orchestrator.settings import app_settings
|
|
28
|
-
from orchestrator.utils.helpers import camel_to_snake, to_camel
|
|
29
|
-
|
|
30
|
-
jobstores = {"default": SQLAlchemyJobStore(url=str(app_settings.DATABASE_URI))}
|
|
31
|
-
|
|
32
|
-
scheduler = BackgroundScheduler(jobstores=jobstores)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def scheduler_dispose_db_connections() -> None:
|
|
36
|
-
jobstores["default"].engine.dispose()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
class ScheduledTask(BaseModel):
|
|
40
|
-
id: str
|
|
41
|
-
name: str | None = None
|
|
42
|
-
next_run_time: datetime | None = None
|
|
43
|
-
trigger: str
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
scheduled_task_keys = set(ScheduledTask.model_fields.keys())
|
|
47
|
-
scheduled_task_filter_keys = sorted(scheduled_task_keys | {to_camel(key) for key in scheduled_task_keys})
|
|
48
|
-
scheduled_task_sort_keys = scheduled_task_filter_keys
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def scheduled_task_in_filter(job: ScheduledTask, filter_by: list[Filter]) -> bool:
|
|
52
|
-
return any(f.value.lower() in getattr(job, camel_to_snake(f.field), "").lower() for f in filter_by)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def filter_scheduled_tasks(
|
|
56
|
-
scheduled_tasks: list[ScheduledTask],
|
|
57
|
-
handle_filter_error: CallableErrorHandler,
|
|
58
|
-
filter_by: list[Filter] | None = None,
|
|
59
|
-
) -> list[ScheduledTask]:
|
|
60
|
-
if not filter_by:
|
|
61
|
-
return scheduled_tasks
|
|
62
|
-
|
|
63
|
-
try:
|
|
64
|
-
invalid_filters, valid_filters = partition(lambda x: x.field in scheduled_task_filter_keys, filter_by)
|
|
65
|
-
|
|
66
|
-
if invalid_list := [item.field for item in invalid_filters]:
|
|
67
|
-
handle_filter_error(
|
|
68
|
-
"Invalid filter arguments", invalid_filters=invalid_list, valid_filter_keys=scheduled_task_filter_keys
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
valid_filter_list = list(valid_filters)
|
|
72
|
-
return [task for task in scheduled_tasks if scheduled_task_in_filter(task, valid_filter_list)]
|
|
73
|
-
except Exception as e:
|
|
74
|
-
handle_filter_error(str(e))
|
|
75
|
-
return []
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def _invert(value: Any) -> Any:
|
|
79
|
-
"""Invert value for descending order."""
|
|
80
|
-
if isinstance(value, (int, float)):
|
|
81
|
-
return -value
|
|
82
|
-
if isinstance(value, str):
|
|
83
|
-
return tuple(-ord(c) for c in value)
|
|
84
|
-
if isinstance(value, datetime):
|
|
85
|
-
return -value.timestamp()
|
|
86
|
-
return value
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def sort_key(sort_field: str, sort_order: SortOrder) -> Any:
|
|
90
|
-
def _sort_key(task: Any) -> Any:
|
|
91
|
-
value = getattr(task, camel_to_snake(sort_field), None)
|
|
92
|
-
if sort_field == "next_run_time" and value is None:
|
|
93
|
-
return float("inf") if sort_order == SortOrder.ASC else float("-inf")
|
|
94
|
-
return value if sort_order == SortOrder.ASC else _invert(value)
|
|
95
|
-
|
|
96
|
-
return _sort_key
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def sort_scheduled_tasks(
|
|
100
|
-
scheduled_tasks: list[ScheduledTask], handle_sort_error: CallableErrorHandler, sort_by: list[Sort] | None = None
|
|
101
|
-
) -> list[ScheduledTask]:
|
|
102
|
-
if not sort_by:
|
|
103
|
-
return scheduled_tasks
|
|
104
|
-
|
|
105
|
-
try:
|
|
106
|
-
invalid_sorting, valid_sorting = partition(lambda x: x.field in scheduled_task_sort_keys, sort_by)
|
|
107
|
-
if invalid_list := [item.field for item in invalid_sorting]:
|
|
108
|
-
handle_sort_error(
|
|
109
|
-
"Invalid sort arguments", invalid_sorting=invalid_list, valid_sort_keys=scheduled_task_sort_keys
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
valid_sort_list = list(valid_sorting)
|
|
113
|
-
return sorted(
|
|
114
|
-
scheduled_tasks, key=lambda task: tuple(sort_key(sort.field, sort.order)(task) for sort in valid_sort_list)
|
|
115
|
-
)
|
|
116
|
-
except Exception as e:
|
|
117
|
-
handle_sort_error(str(e))
|
|
118
|
-
return []
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def default_error_handler(message: str, **context) -> None: # type: ignore
|
|
122
|
-
from orchestrator.graphql.utils.create_resolver_error_handler import _format_context
|
|
123
|
-
|
|
124
|
-
raise ValueError(f"{message} {_format_context(context)}")
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def get_scheduler_tasks(
|
|
128
|
-
first: int = 10,
|
|
129
|
-
after: int = 0,
|
|
130
|
-
filter_by: list[Filter] | None = None,
|
|
131
|
-
sort_by: list[Sort] | None = None,
|
|
132
|
-
error_handler: CallableErrorHandler = default_error_handler,
|
|
133
|
-
) -> tuple[list[ScheduledTask], int]:
|
|
134
|
-
scheduler.start(paused=True)
|
|
135
|
-
scheduled_tasks = scheduler.get_jobs()
|
|
136
|
-
scheduler.shutdown(wait=False)
|
|
137
|
-
scheduler_dispose_db_connections()
|
|
138
|
-
|
|
139
|
-
scheduled_tasks = filter_scheduled_tasks(scheduled_tasks, error_handler, filter_by)
|
|
140
|
-
scheduled_tasks = sort_scheduled_tasks(scheduled_tasks, error_handler, sort_by)
|
|
141
|
-
|
|
142
|
-
total = len(scheduled_tasks)
|
|
143
|
-
paginated_tasks = scheduled_tasks[after : after + first + 1]
|
|
144
|
-
|
|
145
|
-
return [
|
|
146
|
-
ScheduledTask(
|
|
147
|
-
id=task.id,
|
|
148
|
-
name=task.name,
|
|
149
|
-
next_run_time=task.next_run_time,
|
|
150
|
-
trigger=str(task.trigger),
|
|
151
|
-
)
|
|
152
|
-
for task in paginated_tasks
|
|
153
|
-
], total
|
|
File without changes
|
{orchestrator_core-4.4.0rc1.dist-info → orchestrator_core-5.0.0a1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|