orchestrator-core 2.10.0rc1__py3-none-any.whl → 3.0.0rc1__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 +24 -3
- orchestrator/api/api_v1/endpoints/processes.py +1 -1
- orchestrator/api/api_v1/endpoints/product_blocks.py +56 -0
- orchestrator/api/api_v1/endpoints/products.py +28 -1
- orchestrator/api/api_v1/endpoints/resource_types.py +56 -0
- orchestrator/api/api_v1/endpoints/workflows.py +54 -0
- orchestrator/app.py +3 -2
- orchestrator/cli/generator/generator/product_block.py +1 -9
- orchestrator/cli/generator/templates/create_product.j2 +2 -1
- orchestrator/cli/generator/templates/modify_product.j2 +2 -1
- orchestrator/cli/generator/templates/shared_workflows.j2 +2 -1
- orchestrator/cli/generator/templates/terminate_product.j2 +1 -1
- orchestrator/cli/generator/templates/test_create_workflow.j2 +0 -1
- orchestrator/cli/generator/templates/test_modify_workflow.j2 +1 -2
- orchestrator/cli/generator/templates/test_terminate_workflow.j2 +1 -1
- orchestrator/cli/generator/templates/validate_product.j2 +3 -1
- orchestrator/cli/helpers/print_helpers.py +1 -1
- orchestrator/config/assignee.py +1 -1
- orchestrator/devtools/populator.py +1 -1
- orchestrator/devtools/scripts/migrate_20.py +11 -106
- orchestrator/devtools/scripts/migrate_30.py +61 -0
- orchestrator/devtools/scripts/shared.py +108 -0
- orchestrator/domain/base.py +1 -2
- orchestrator/domain/lifecycle.py +2 -1
- orchestrator/migrations/helpers.py +1 -1
- orchestrator/schemas/engine_settings.py +1 -1
- orchestrator/schemas/product.py +4 -0
- orchestrator/schemas/product_block.py +4 -0
- orchestrator/schemas/resource_type.py +4 -0
- orchestrator/schemas/subscription.py +2 -1
- orchestrator/schemas/workflow.py +4 -0
- orchestrator/services/celery.py +1 -1
- orchestrator/services/processes.py +2 -1
- orchestrator/services/products.py +1 -1
- orchestrator/services/subscriptions.py +2 -1
- orchestrator/services/tasks.py +2 -1
- orchestrator/settings.py +1 -1
- orchestrator/targets.py +1 -1
- orchestrator/types.py +8 -43
- orchestrator/utils/errors.py +2 -1
- orchestrator/utils/state.py +2 -1
- orchestrator/workflow.py +3 -1
- orchestrator/workflows/modify_note.py +1 -2
- orchestrator/workflows/steps.py +2 -1
- orchestrator/workflows/tasks/cleanup_tasks_log.py +1 -1
- orchestrator/workflows/tasks/resume_workflows.py +1 -1
- orchestrator/workflows/tasks/validate_product_type.py +1 -1
- orchestrator/workflows/tasks/validate_products.py +1 -1
- orchestrator/workflows/utils.py +2 -2
- {orchestrator_core-2.10.0rc1.dist-info → orchestrator_core-3.0.0rc1.dist-info}/METADATA +1 -1
- {orchestrator_core-2.10.0rc1.dist-info → orchestrator_core-3.0.0rc1.dist-info}/RECORD +54 -49
- {orchestrator_core-2.10.0rc1.dist-info → orchestrator_core-3.0.0rc1.dist-info}/LICENSE +0 -0
- {orchestrator_core-2.10.0rc1.dist-info → orchestrator_core-3.0.0rc1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Helper script to rewrite import statements in your orchestrator.
|
|
2
|
+
|
|
3
|
+
Since types have been externalised in `pydantic_forms`, they were re-imported in `orchestrator.types` for backwards
|
|
4
|
+
compatibility. These import statements have been removed, and therefore need to be updated in orchestrator
|
|
5
|
+
implementations.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from orchestrator.devtools.scripts.shared import migrate, move_import
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def migrate_file(f: Path) -> bool:
|
|
15
|
+
imports = {
|
|
16
|
+
"JSON": move_import(f, "JSON", "orchestrator.types", "pydantic_forms.types"),
|
|
17
|
+
"AcceptData": move_import(f, "AcceptData", "orchestrator.types", "pydantic_forms.types"),
|
|
18
|
+
"AcceptItemType": move_import(f, "AcceptItemType", "orchestrator.types", "pydantic_forms.types"),
|
|
19
|
+
"FormGenerator": move_import(f, "FormGenerator", "orchestrator.types", "pydantic_forms.types"),
|
|
20
|
+
"FormGeneratorAsync": move_import(f, "FormGeneratorAsync", "orchestrator.types", "pydantic_forms.types"),
|
|
21
|
+
"InputForm": move_import(f, "InputForm", "orchestrator.types", "pydantic_forms.types"),
|
|
22
|
+
"InputFormGenerator": move_import(f, "InputFormGenerator", "orchestrator.types", "pydantic_forms.types"),
|
|
23
|
+
"InputStepFunc": move_import(f, "InputStepFunc", "orchestrator.types", "pydantic_forms.types"),
|
|
24
|
+
"SimpleInputFormGenerator": move_import(
|
|
25
|
+
f, "SimpleInputFormGenerator", "orchestrator.types", "pydantic_forms.types"
|
|
26
|
+
),
|
|
27
|
+
"State": move_import(f, "State", "orchestrator.types", "pydantic_forms.types"),
|
|
28
|
+
"StateInputFormGenerator": move_import(
|
|
29
|
+
f, "StateInputFormGenerator", "orchestrator.types", "pydantic_forms.types"
|
|
30
|
+
),
|
|
31
|
+
"StateInputFormGeneratorAsync": move_import(
|
|
32
|
+
f, "StateInputFormGeneratorAsync", "orchestrator.types", "pydantic_forms.types"
|
|
33
|
+
),
|
|
34
|
+
"StateInputStepFunc": move_import(f, "StateInputStepFunc", "orchestrator.types", "pydantic_forms.types"),
|
|
35
|
+
"StateSimpleInputFormGenerator": move_import(
|
|
36
|
+
f, "StateSimpleInputFormGenerator", "orchestrator.types", "pydantic_forms.types"
|
|
37
|
+
),
|
|
38
|
+
"SubscriptionMapping": move_import(f, "SubscriptionMapping", "orchestrator.types", "pydantic_forms.types"),
|
|
39
|
+
"SummaryData": move_import(f, "SummaryData", "orchestrator.types", "pydantic_forms.types"),
|
|
40
|
+
"UUIDstr": move_import(f, "UUIDstr", "orchestrator.types", "pydantic_forms.types"),
|
|
41
|
+
"strEnum": move_import(f, "strEnum", "orchestrator.types", "pydantic_forms.types"),
|
|
42
|
+
}
|
|
43
|
+
lines = []
|
|
44
|
+
lines.extend([f"Moved {k} import" for k, v in imports.items() if v])
|
|
45
|
+
|
|
46
|
+
if lines:
|
|
47
|
+
formatted_lines = "\n".join(f" - {line}" for line in lines)
|
|
48
|
+
print(f"Updated {f.name:50s}\n{formatted_lines}")
|
|
49
|
+
|
|
50
|
+
return bool(lines)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
try:
|
|
55
|
+
_target_dir = Path(sys.argv[1])
|
|
56
|
+
assert _target_dir.is_dir()
|
|
57
|
+
except Exception:
|
|
58
|
+
print("Need a directory as parameter")
|
|
59
|
+
sys.exit(1)
|
|
60
|
+
|
|
61
|
+
sys.exit(0 if migrate(_target_dir, migrate_file) else 1)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from subprocess import run
|
|
4
|
+
from typing import Callable
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def remove_imports(text: str, module: str, symbol: str) -> tuple[str, bool]:
|
|
8
|
+
"""Find imports and remove them.
|
|
9
|
+
|
|
10
|
+
Assumes code is formatted through Black to keep the regex somewhat readable.
|
|
11
|
+
"""
|
|
12
|
+
text_orig = text
|
|
13
|
+
|
|
14
|
+
# single import from module (may have a #comment) -> remove line
|
|
15
|
+
rgx = r"(from %s import \b%s\b(\s*#[^\n]*)*\n)" % (re.escape(module), symbol)
|
|
16
|
+
text = re.sub(rgx, "", text)
|
|
17
|
+
|
|
18
|
+
# middle or last of multiple imports from module -> strip symbol
|
|
19
|
+
rgx = r"(from %s import .+)(, \b%s\b)" % (re.escape(module), symbol)
|
|
20
|
+
text = re.sub(rgx, r"\1", text)
|
|
21
|
+
|
|
22
|
+
# first of multiple imports from same module -> strip symbol
|
|
23
|
+
rgx = r"(from %s import )\b%s\b, " % (re.escape(module), symbol)
|
|
24
|
+
text = re.sub(rgx, r"\1", text)
|
|
25
|
+
|
|
26
|
+
# multiline import -> remove line with symbol
|
|
27
|
+
rgx_verbose = r"""(?P<before>^from\s%s\simport\s*\([^\n]*\n(?:^[^\n]+,\n)*)
|
|
28
|
+
(^\s*\b%s\b,[^\n]*\n)
|
|
29
|
+
(?P<after>(?:^[^\n]+,\n)*\)[^\n]*$)"""
|
|
30
|
+
text = re.sub(rgx_verbose % (re.escape(module), symbol), r"\g<before>\g<after>", text, flags=re.M | re.X)
|
|
31
|
+
return text, text_orig != text
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def insert_import(text: str, import_stmt: str) -> str:
|
|
35
|
+
# Find the first import line and add our line above that
|
|
36
|
+
# Rely on ruff & black for formatting
|
|
37
|
+
return re.sub(r"(^(?:from .+|import .+)$)", f"{import_stmt}\n" + r"\1", text, count=1, flags=re.M)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def move_import(f: Path, symbol: str, old_module: str, new_module: str) -> bool:
|
|
41
|
+
text = f.read_text()
|
|
42
|
+
text, changed = remove_imports(text, old_module, symbol)
|
|
43
|
+
if not changed:
|
|
44
|
+
return False
|
|
45
|
+
text = insert_import(text, f"from {new_module} import {symbol}")
|
|
46
|
+
with f.open(mode="w"):
|
|
47
|
+
f.write_text(text)
|
|
48
|
+
return True
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def find_and_remove_aliases(text: str, symbol: str) -> tuple[str, list[str]]:
|
|
52
|
+
"""In the given text find aliases of the given symbol and remove them.
|
|
53
|
+
|
|
54
|
+
Return updated text and aliases removed.
|
|
55
|
+
"""
|
|
56
|
+
rgx = r"(\b%s as (\w+))" % (symbol,)
|
|
57
|
+
aliases = [aliasgroup for fullgroup, aliasgroup in re.findall(rgx, text)]
|
|
58
|
+
newtext = re.sub(rgx, symbol, text)
|
|
59
|
+
return newtext, aliases
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def replace_words(text: str, words: list[str], replace: str) -> str:
|
|
63
|
+
rgx = r"\b(%s)\b" % ("|".join(words),)
|
|
64
|
+
return re.sub(rgx, replace, text)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def has_word(text: str, word: str) -> bool:
|
|
68
|
+
return bool(re.search(r"\b%s\b" % (word,), text))
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def run_tool(*args: str) -> bool:
|
|
72
|
+
cmd = " ".join(args)
|
|
73
|
+
try:
|
|
74
|
+
r = run(args, capture_output=True) # noqa: S603
|
|
75
|
+
if r.returncode == 0:
|
|
76
|
+
return True
|
|
77
|
+
print(f"{cmd} failed:", r.stdout, r.stderr)
|
|
78
|
+
except FileNotFoundError:
|
|
79
|
+
print(f"{cmd} failed: could not find executable in the current venv")
|
|
80
|
+
return False
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def migrate(target_dir: Path, migrate_file: Callable[[Path], bool]) -> bool:
|
|
84
|
+
abs_path = str(target_dir.resolve())
|
|
85
|
+
|
|
86
|
+
def run_tools() -> bool:
|
|
87
|
+
return run_tool("ruff", "check", "--fix", abs_path) and run_tool("black", "--quiet", abs_path)
|
|
88
|
+
|
|
89
|
+
print(f"\n### Verifying files in {abs_path}... ", end="")
|
|
90
|
+
if not run_tools():
|
|
91
|
+
print("Failed to verify files, aborting migration. Please resolve errors.")
|
|
92
|
+
return False
|
|
93
|
+
print("Ok")
|
|
94
|
+
|
|
95
|
+
files_migrated = files_checked = 0
|
|
96
|
+
print(f"\n### Migrating files in {abs_path}")
|
|
97
|
+
try:
|
|
98
|
+
for f in target_dir.glob("**/*.py"):
|
|
99
|
+
if migrate_file(f):
|
|
100
|
+
files_migrated += 1
|
|
101
|
+
files_checked += 1
|
|
102
|
+
except KeyboardInterrupt:
|
|
103
|
+
print("Interrupted...")
|
|
104
|
+
|
|
105
|
+
print(f"\n### Migrated {files_migrated}/{files_checked} files in {abs_path}")
|
|
106
|
+
|
|
107
|
+
print(f"\n### Formatting files in {abs_path}")
|
|
108
|
+
return run_tools()
|
orchestrator/domain/base.py
CHANGED
|
@@ -55,9 +55,7 @@ from orchestrator.domain.lifecycle import (
|
|
|
55
55
|
from orchestrator.services.products import get_product_by_id
|
|
56
56
|
from orchestrator.types import (
|
|
57
57
|
SAFE_USED_BY_TRANSITIONS_FOR_STATUS,
|
|
58
|
-
State,
|
|
59
58
|
SubscriptionLifecycle,
|
|
60
|
-
UUIDstr,
|
|
61
59
|
filter_nonetype,
|
|
62
60
|
get_origin_and_args,
|
|
63
61
|
get_possible_product_block_types,
|
|
@@ -69,6 +67,7 @@ from orchestrator.types import (
|
|
|
69
67
|
)
|
|
70
68
|
from orchestrator.utils.datetime import nowtz
|
|
71
69
|
from orchestrator.utils.docs import make_product_block_docstring, make_subscription_model_docstring
|
|
70
|
+
from pydantic_forms.types import State, UUIDstr
|
|
72
71
|
|
|
73
72
|
logger = structlog.get_logger(__name__)
|
|
74
73
|
|
orchestrator/domain/lifecycle.py
CHANGED
|
@@ -16,7 +16,8 @@ from typing import TYPE_CHECKING, TypeVar
|
|
|
16
16
|
import strawberry
|
|
17
17
|
import structlog
|
|
18
18
|
|
|
19
|
-
from orchestrator.types import SubscriptionLifecycle
|
|
19
|
+
from orchestrator.types import SubscriptionLifecycle
|
|
20
|
+
from pydantic_forms.types import strEnum
|
|
20
21
|
|
|
21
22
|
if TYPE_CHECKING:
|
|
22
23
|
from orchestrator.domain.base import DomainModel
|
orchestrator/schemas/product.py
CHANGED
|
@@ -37,3 +37,7 @@ class ProductBlockSchema(ProductBlockBaseSchema):
|
|
|
37
37
|
end_date: datetime | None = None
|
|
38
38
|
resource_types: list[ResourceTypeSchema] | None = None # type: ignore
|
|
39
39
|
model_config = ConfigDict(from_attributes=True)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ProductBlockPatchSchema(OrchestratorBaseModel):
|
|
43
|
+
description: str | None = None
|
|
@@ -27,3 +27,7 @@ class ResourceTypeBaseSchema(OrchestratorBaseModel):
|
|
|
27
27
|
class ResourceTypeSchema(ResourceTypeBaseSchema):
|
|
28
28
|
resource_type_id: UUID
|
|
29
29
|
model_config = ConfigDict(from_attributes=True)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class ResourceTypePatchSchema(OrchestratorBaseModel):
|
|
33
|
+
description: str | None = None
|
|
@@ -22,7 +22,8 @@ from orchestrator.schemas.product import ProductBaseSchema
|
|
|
22
22
|
from orchestrator.schemas.product_block import ProductBlockSchema
|
|
23
23
|
from orchestrator.schemas.resource_type import ResourceTypeSchema
|
|
24
24
|
from orchestrator.schemas.subscription_descriptions import SubscriptionDescriptionSchema
|
|
25
|
-
from orchestrator.types import SubscriptionLifecycle
|
|
25
|
+
from orchestrator.types import SubscriptionLifecycle
|
|
26
|
+
from pydantic_forms.types import strEnum
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class PortMode(strEnum):
|
orchestrator/schemas/workflow.py
CHANGED
|
@@ -59,3 +59,7 @@ class SubscriptionWorkflowListsSchema(OrchestratorBaseModel):
|
|
|
59
59
|
modify: list[WorkflowListItemSchema]
|
|
60
60
|
terminate: list[WorkflowListItemSchema]
|
|
61
61
|
system: list[WorkflowListItemSchema]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class WorkflowPatchSchema(OrchestratorBaseModel):
|
|
65
|
+
description: str | None = None
|
orchestrator/services/celery.py
CHANGED
|
@@ -24,8 +24,8 @@ from orchestrator.api.error_handling import raise_status
|
|
|
24
24
|
from orchestrator.db import ProcessTable, db
|
|
25
25
|
from orchestrator.services.processes import create_process, delete_process
|
|
26
26
|
from orchestrator.targets import Target
|
|
27
|
-
from orchestrator.types import State
|
|
28
27
|
from orchestrator.workflows import get_workflow
|
|
28
|
+
from pydantic_forms.types import State
|
|
29
29
|
|
|
30
30
|
SYSTEM_USER = "SYSTEM"
|
|
31
31
|
|
|
@@ -39,7 +39,7 @@ from orchestrator.services.settings import get_engine_settings_for_update
|
|
|
39
39
|
from orchestrator.services.workflows import get_workflow_by_name
|
|
40
40
|
from orchestrator.settings import ExecutorType, app_settings
|
|
41
41
|
from orchestrator.targets import Target
|
|
42
|
-
from orchestrator.types import BroadcastFunc
|
|
42
|
+
from orchestrator.types import BroadcastFunc
|
|
43
43
|
from orchestrator.utils.datetime import nowtz
|
|
44
44
|
from orchestrator.utils.errors import error_state_to_dict
|
|
45
45
|
from orchestrator.websocket import broadcast_invalidate_status_counts
|
|
@@ -60,6 +60,7 @@ from orchestrator.workflows import get_workflow
|
|
|
60
60
|
from orchestrator.workflows.removed_workflow import removed_workflow
|
|
61
61
|
from pydantic_forms.core import post_form
|
|
62
62
|
from pydantic_forms.exceptions import FormValidationError
|
|
63
|
+
from pydantic_forms.types import State
|
|
63
64
|
|
|
64
65
|
logger = structlog.get_logger(__name__)
|
|
65
66
|
|
|
@@ -18,7 +18,7 @@ from sqlalchemy import select
|
|
|
18
18
|
from sqlalchemy.orm import joinedload
|
|
19
19
|
|
|
20
20
|
from orchestrator.db import ProductTable, db
|
|
21
|
-
from
|
|
21
|
+
from pydantic_forms.types import UUIDstr
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def get_products(*, filters: list | None = None) -> list[ProductTable]:
|
|
@@ -43,9 +43,10 @@ from orchestrator.db.models import (
|
|
|
43
43
|
)
|
|
44
44
|
from orchestrator.domain.base import SubscriptionModel
|
|
45
45
|
from orchestrator.targets import Target
|
|
46
|
-
from orchestrator.types import SubscriptionLifecycle
|
|
46
|
+
from orchestrator.types import SubscriptionLifecycle
|
|
47
47
|
from orchestrator.utils.datetime import nowtz
|
|
48
48
|
from orchestrator.utils.helpers import is_ipaddress_type
|
|
49
|
+
from pydantic_forms.types import UUIDstr
|
|
49
50
|
|
|
50
51
|
logger = structlog.get_logger(__name__)
|
|
51
52
|
|
orchestrator/services/tasks.py
CHANGED
|
@@ -30,10 +30,11 @@ from orchestrator.services.processes import (
|
|
|
30
30
|
safe_logstep,
|
|
31
31
|
thread_resume_process,
|
|
32
32
|
)
|
|
33
|
-
from orchestrator.types import BroadcastFunc
|
|
33
|
+
from orchestrator.types import BroadcastFunc
|
|
34
34
|
from orchestrator.utils.json import json_dumps, json_loads
|
|
35
35
|
from orchestrator.workflow import ProcessStat, ProcessStatus, Success, runwf
|
|
36
36
|
from orchestrator.workflows import get_workflow
|
|
37
|
+
from pydantic_forms.types import State
|
|
37
38
|
|
|
38
39
|
logger = get_task_logger(__name__)
|
|
39
40
|
|
orchestrator/settings.py
CHANGED
|
@@ -20,7 +20,7 @@ from pydantic import PostgresDsn, RedisDsn
|
|
|
20
20
|
from pydantic_settings import BaseSettings
|
|
21
21
|
|
|
22
22
|
from oauth2_lib.settings import oauth2lib_settings
|
|
23
|
-
from
|
|
23
|
+
from pydantic_forms.types import strEnum
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class ExecutorType(strEnum):
|
orchestrator/targets.py
CHANGED
orchestrator/types.py
CHANGED
|
@@ -34,59 +34,24 @@ from annotated_types import Len, MaxLen, MinLen
|
|
|
34
34
|
from more_itertools import first, last
|
|
35
35
|
from pydantic.fields import FieldInfo
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
# these types from pydantic_forms themselves
|
|
39
|
-
from pydantic_forms.types import (
|
|
40
|
-
JSON,
|
|
41
|
-
AcceptData,
|
|
42
|
-
AcceptItemType,
|
|
43
|
-
FormGenerator,
|
|
44
|
-
FormGeneratorAsync,
|
|
45
|
-
InputForm,
|
|
46
|
-
InputFormGenerator,
|
|
47
|
-
InputStepFunc,
|
|
48
|
-
SimpleInputFormGenerator,
|
|
49
|
-
State,
|
|
50
|
-
StateInputFormGenerator,
|
|
51
|
-
StateInputFormGeneratorAsync,
|
|
52
|
-
StateInputStepFunc,
|
|
53
|
-
StateSimpleInputFormGenerator,
|
|
54
|
-
SubscriptionMapping,
|
|
55
|
-
SummaryData,
|
|
56
|
-
UUIDstr,
|
|
57
|
-
strEnum,
|
|
58
|
-
)
|
|
37
|
+
from pydantic_forms.types import InputForm, State, strEnum
|
|
59
38
|
|
|
60
39
|
__all__ = [
|
|
61
|
-
"
|
|
40
|
+
"SAFE_USED_BY_TRANSITIONS_FOR_STATUS",
|
|
62
41
|
"BroadcastFunc",
|
|
63
|
-
"AcceptData",
|
|
64
|
-
"AcceptItemType",
|
|
65
42
|
"ErrorDict",
|
|
66
43
|
"ErrorState",
|
|
67
|
-
"FormGenerator",
|
|
68
|
-
"FormGeneratorAsync",
|
|
69
|
-
"InputForm",
|
|
70
|
-
"InputFormGenerator",
|
|
71
|
-
"InputStepFunc",
|
|
72
|
-
"SimpleInputFormGenerator",
|
|
73
|
-
"State",
|
|
74
|
-
"StateInputFormGenerator",
|
|
75
|
-
"StateInputFormGeneratorAsync",
|
|
76
|
-
"StateInputStepFunc",
|
|
77
|
-
"StateSimpleInputFormGenerator",
|
|
78
44
|
"StateStepFunc",
|
|
79
45
|
"StepFunc",
|
|
80
46
|
"SubscriptionLifecycle",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
47
|
+
"filter_nonetype",
|
|
48
|
+
"get_origin_and_args",
|
|
49
|
+
"get_possible_product_block_types",
|
|
84
50
|
"is_list_type",
|
|
85
51
|
"is_of_type",
|
|
86
52
|
"is_optional_type",
|
|
87
53
|
"is_union_type",
|
|
88
|
-
"
|
|
89
|
-
"strEnum",
|
|
54
|
+
"list_factory",
|
|
90
55
|
]
|
|
91
56
|
|
|
92
57
|
if TYPE_CHECKING:
|
|
@@ -97,8 +62,8 @@ def is_union(tp: type[Any] | None) -> bool:
|
|
|
97
62
|
return tp is Union or tp is types.UnionType # type: ignore[comparison-overlap]
|
|
98
63
|
|
|
99
64
|
|
|
100
|
-
# ErrorState is either a string containing an error message, a
|
|
101
|
-
#
|
|
65
|
+
# ErrorState is either a string containing an error message, a caught Exception, or a tuple containing a message and
|
|
66
|
+
# an HTTP status code
|
|
102
67
|
ErrorState = Union[str, Exception, tuple[str, Union[int, HTTPStatus]]]
|
|
103
68
|
# An ErrorDict should have the following keys:
|
|
104
69
|
# error: str # A message describing the error
|
orchestrator/utils/errors.py
CHANGED
|
@@ -18,7 +18,8 @@ from typing import Any, cast
|
|
|
18
18
|
import structlog
|
|
19
19
|
|
|
20
20
|
from nwastdlib.ex import show_ex
|
|
21
|
-
from orchestrator.types import
|
|
21
|
+
from orchestrator.types import ErrorDict
|
|
22
|
+
from pydantic_forms.types import JSON
|
|
22
23
|
|
|
23
24
|
logger = structlog.get_logger(__name__)
|
|
24
25
|
|
orchestrator/utils/state.py
CHANGED
|
@@ -19,7 +19,7 @@ from typing import Any, cast, get_args
|
|
|
19
19
|
from uuid import UUID
|
|
20
20
|
|
|
21
21
|
from orchestrator.domain.base import SubscriptionModel
|
|
22
|
-
from orchestrator.types import
|
|
22
|
+
from orchestrator.types import StepFunc, is_list_type, is_optional_type
|
|
23
23
|
from orchestrator.utils.functional import logger
|
|
24
24
|
from pydantic_forms.types import (
|
|
25
25
|
FormGenerator,
|
|
@@ -27,6 +27,7 @@ from pydantic_forms.types import (
|
|
|
27
27
|
InputFormGenerator,
|
|
28
28
|
InputStepFunc,
|
|
29
29
|
SimpleInputFormGenerator,
|
|
30
|
+
State,
|
|
30
31
|
StateInputStepFunc,
|
|
31
32
|
)
|
|
32
33
|
|
orchestrator/workflow.py
CHANGED
|
@@ -43,7 +43,7 @@ from orchestrator.config.assignee import Assignee
|
|
|
43
43
|
from orchestrator.db import db, transactional
|
|
44
44
|
from orchestrator.services.settings import get_engine_settings
|
|
45
45
|
from orchestrator.targets import Target
|
|
46
|
-
from orchestrator.types import ErrorDict,
|
|
46
|
+
from orchestrator.types import ErrorDict, StepFunc
|
|
47
47
|
from orchestrator.utils.docs import make_workflow_doc
|
|
48
48
|
from orchestrator.utils.errors import error_state_to_dict
|
|
49
49
|
from orchestrator.utils.state import form_inject_args, inject_args
|
|
@@ -52,9 +52,11 @@ from pydantic_forms.types import (
|
|
|
52
52
|
FormGenerator,
|
|
53
53
|
InputFormGenerator,
|
|
54
54
|
InputStepFunc,
|
|
55
|
+
State,
|
|
55
56
|
StateInputFormGenerator,
|
|
56
57
|
StateInputStepFunc,
|
|
57
58
|
StateSimpleInputFormGenerator,
|
|
59
|
+
strEnum,
|
|
58
60
|
)
|
|
59
61
|
|
|
60
62
|
logger = structlog.get_logger(__name__)
|
|
@@ -15,12 +15,11 @@ from orchestrator.forms import SubmitFormPage
|
|
|
15
15
|
from orchestrator.services import subscriptions
|
|
16
16
|
from orchestrator.settings import app_settings
|
|
17
17
|
from orchestrator.targets import Target
|
|
18
|
-
from orchestrator.types import UUIDstr
|
|
19
18
|
from orchestrator.utils.json import to_serializable
|
|
20
19
|
from orchestrator.workflow import StepList, conditional, done, init, step, workflow
|
|
21
20
|
from orchestrator.workflows.steps import cache_domain_models, store_process_subscription
|
|
22
21
|
from orchestrator.workflows.utils import wrap_modify_initial_input_form
|
|
23
|
-
from pydantic_forms.types import FormGenerator, State
|
|
22
|
+
from pydantic_forms.types import FormGenerator, State, UUIDstr
|
|
24
23
|
from pydantic_forms.validators import LongText
|
|
25
24
|
|
|
26
25
|
|
orchestrator/workflows/steps.py
CHANGED
|
@@ -23,11 +23,12 @@ from orchestrator.domain.base import ProductBlockModel, SubscriptionModel
|
|
|
23
23
|
from orchestrator.services.settings import reset_search_index
|
|
24
24
|
from orchestrator.services.subscriptions import build_extended_domain_model, get_subscription
|
|
25
25
|
from orchestrator.targets import Target
|
|
26
|
-
from orchestrator.types import
|
|
26
|
+
from orchestrator.types import SubscriptionLifecycle
|
|
27
27
|
from orchestrator.utils.json import to_serializable
|
|
28
28
|
from orchestrator.utils.redis import delete_from_redis, to_redis
|
|
29
29
|
from orchestrator.websocket import sync_invalidate_subscription_cache
|
|
30
30
|
from orchestrator.workflow import Step, step
|
|
31
|
+
from pydantic_forms.types import State, UUIDstr
|
|
31
32
|
|
|
32
33
|
logger = structlog.get_logger(__name__)
|
|
33
34
|
|
|
@@ -19,9 +19,9 @@ from sqlalchemy import select
|
|
|
19
19
|
from orchestrator.db import ProcessTable, db
|
|
20
20
|
from orchestrator.settings import app_settings
|
|
21
21
|
from orchestrator.targets import Target
|
|
22
|
-
from orchestrator.types import State
|
|
23
22
|
from orchestrator.utils.datetime import nowtz
|
|
24
23
|
from orchestrator.workflow import ProcessStatus, StepList, done, init, step, workflow
|
|
24
|
+
from pydantic_forms.types import State
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
@step("Clean up completed tasks older than TASK_LOG_RETENTION_DAYS")
|
|
@@ -18,8 +18,8 @@ from sqlalchemy import select
|
|
|
18
18
|
from orchestrator.db import ProcessTable, db
|
|
19
19
|
from orchestrator.services import processes
|
|
20
20
|
from orchestrator.targets import Target
|
|
21
|
-
from orchestrator.types import State, UUIDstr
|
|
22
21
|
from orchestrator.workflow import ProcessStatus, StepList, done, init, step, workflow
|
|
22
|
+
from pydantic_forms.types import State, UUIDstr
|
|
23
23
|
|
|
24
24
|
logger = structlog.get_logger(__name__)
|
|
25
25
|
|
|
@@ -26,8 +26,8 @@ from orchestrator.services.workflows import (
|
|
|
26
26
|
start_validation_workflow_for_workflows,
|
|
27
27
|
)
|
|
28
28
|
from orchestrator.targets import Target
|
|
29
|
-
from orchestrator.types import FormGenerator, State
|
|
30
29
|
from orchestrator.workflow import StepList, done, init, step, workflow
|
|
30
|
+
from pydantic_forms.types import FormGenerator, State
|
|
31
31
|
|
|
32
32
|
logger = structlog.get_logger(__name__)
|
|
33
33
|
|
|
@@ -27,10 +27,10 @@ from orchestrator.services.products import get_products
|
|
|
27
27
|
from orchestrator.services.translations import generate_translations
|
|
28
28
|
from orchestrator.services.workflows import get_workflow_by_name, get_workflows
|
|
29
29
|
from orchestrator.targets import Target
|
|
30
|
-
from orchestrator.types import State
|
|
31
30
|
from orchestrator.utils.errors import ProcessFailureError
|
|
32
31
|
from orchestrator.utils.fixed_inputs import fixed_input_configuration as fi_configuration
|
|
33
32
|
from orchestrator.workflow import StepList, done, init, step, workflow
|
|
33
|
+
from pydantic_forms.types import State
|
|
34
34
|
|
|
35
35
|
# Since these errors are probably programming failures we should not throw AssertionErrors
|
|
36
36
|
|
orchestrator/workflows/utils.py
CHANGED
|
@@ -25,7 +25,7 @@ from orchestrator.forms.validators import ProductId
|
|
|
25
25
|
from orchestrator.services import subscriptions
|
|
26
26
|
from orchestrator.settings import app_settings
|
|
27
27
|
from orchestrator.targets import Target
|
|
28
|
-
from orchestrator.types import
|
|
28
|
+
from orchestrator.types import SubscriptionLifecycle
|
|
29
29
|
from orchestrator.utils.errors import StaleDataError
|
|
30
30
|
from orchestrator.utils.redis import caching_models_enabled
|
|
31
31
|
from orchestrator.utils.state import form_inject_args
|
|
@@ -41,7 +41,7 @@ from orchestrator.workflows.steps import (
|
|
|
41
41
|
unsync_unchecked,
|
|
42
42
|
)
|
|
43
43
|
from pydantic_forms.core import FormPage
|
|
44
|
-
from pydantic_forms.types import FormGenerator, InputForm, InputStepFunc, StateInputStepFunc
|
|
44
|
+
from pydantic_forms.types import FormGenerator, InputForm, InputStepFunc, State, StateInputStepFunc
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
def _generate_new_subscription_form(_workflow_target: str, workflow_name: str) -> InputForm:
|