@motiadev/core 0.9.2-beta.147 → 0.9.4-beta.149
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.
|
@@ -96,7 +96,7 @@ const callStepFile = (options, motia) => {
|
|
|
96
96
|
return motia.state.get(input.traceId, input.key);
|
|
97
97
|
});
|
|
98
98
|
processManager.handler('state.set', async (input) => {
|
|
99
|
-
tracer.stateOperation('set', { traceId: input.traceId, key: input.key, value:
|
|
99
|
+
tracer.stateOperation('set', { traceId: input.traceId, key: input.key, value: input.value });
|
|
100
100
|
return motia.state.set(input.traceId, input.key, input.value);
|
|
101
101
|
});
|
|
102
102
|
processManager.handler('state.delete', async (input) => {
|
|
@@ -134,7 +134,7 @@ const callStepFile = (options, motia) => {
|
|
|
134
134
|
return stateStream.get(input.groupId, input.id);
|
|
135
135
|
});
|
|
136
136
|
processManager.handler(`streams.${name}.set`, async (input) => {
|
|
137
|
-
tracer.streamOperation(name, 'set', { groupId: input.groupId, id: input.id, data:
|
|
137
|
+
tracer.streamOperation(name, 'set', { groupId: input.groupId, id: input.id, data: input.data });
|
|
138
138
|
return stateStream.set(input.groupId, input.id, input.data);
|
|
139
139
|
});
|
|
140
140
|
processManager.handler(`streams.${name}.delete`, async (input) => {
|
|
@@ -3,6 +3,7 @@ import json
|
|
|
3
3
|
import importlib.util
|
|
4
4
|
import os
|
|
5
5
|
import platform
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
|
|
7
8
|
def sendMessage(text):
|
|
8
9
|
'sends a Node IPC message to parent proccess'
|
|
@@ -21,21 +22,27 @@ def sendMessage(text):
|
|
|
21
22
|
|
|
22
23
|
async def run_python_module(file_path: str) -> None:
|
|
23
24
|
try:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
path = Path(file_path).resolve()
|
|
26
|
+
steps_dir = next((p for p in path.parents if p.name == "steps"), None)
|
|
27
|
+
if steps_dir is None:
|
|
28
|
+
raise RuntimeError("Could not find 'steps' directory in path")
|
|
29
|
+
|
|
30
|
+
project_root = steps_dir.parent
|
|
31
|
+
project_parent = project_root.parent
|
|
32
|
+
if str(project_parent) not in sys.path:
|
|
33
|
+
sys.path.insert(0, str(project_parent))
|
|
34
|
+
|
|
35
|
+
rel_parts = path.relative_to(project_parent).with_suffix("").parts
|
|
36
|
+
module_name = ".".join(rel_parts)
|
|
37
|
+
package_name = module_name.rsplit(".", 1)[0] if "." in module_name else ""
|
|
38
|
+
|
|
39
|
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
34
40
|
if spec is None or spec.loader is None:
|
|
35
41
|
raise ImportError(f"Could not load module from {file_path}")
|
|
36
|
-
|
|
42
|
+
|
|
37
43
|
module = importlib.util.module_from_spec(spec)
|
|
38
|
-
module.__package__ =
|
|
44
|
+
module.__package__ = package_name
|
|
45
|
+
sys.modules[module_name] = module
|
|
39
46
|
spec.loader.exec_module(module)
|
|
40
47
|
|
|
41
48
|
if not hasattr(module, 'config'):
|
|
@@ -57,4 +64,4 @@ if __name__ == "__main__":
|
|
|
57
64
|
file_path = sys.argv[1]
|
|
58
65
|
|
|
59
66
|
import asyncio
|
|
60
|
-
asyncio.run(run_python_module(file_path))
|
|
67
|
+
asyncio.run(run_python_module(file_path))
|
|
@@ -10,6 +10,7 @@ from motia_context import Context
|
|
|
10
10
|
from motia_middleware import compose_middleware
|
|
11
11
|
from motia_rpc_stream_manager import RpcStreamManager
|
|
12
12
|
from motia_dot_dict import DotDict
|
|
13
|
+
from pathlib import Path
|
|
13
14
|
|
|
14
15
|
def parse_args(arg: str) -> Dict:
|
|
15
16
|
"""Parse command line arguments into HandlerArgs"""
|
|
@@ -22,19 +23,27 @@ def parse_args(arg: str) -> Dict:
|
|
|
22
23
|
async def run_python_module(file_path: str, rpc: RpcSender, args: Dict) -> None:
|
|
23
24
|
"""Execute a Python module with the given arguments"""
|
|
24
25
|
try:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
path = Path(file_path).resolve()
|
|
27
|
+
steps_dir = next((p for p in path.parents if p.name == "steps"), None)
|
|
28
|
+
if steps_dir is None:
|
|
29
|
+
raise RuntimeError("Could not find 'steps' directory in path")
|
|
30
|
+
|
|
31
|
+
project_root = steps_dir.parent
|
|
32
|
+
project_parent = project_root.parent
|
|
33
|
+
if str(project_parent) not in sys.path:
|
|
34
|
+
sys.path.insert(0, str(project_parent))
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
rel_parts = path.relative_to(project_parent).with_suffix("").parts
|
|
37
|
+
module_name = ".".join(rel_parts)
|
|
38
|
+
package_name = module_name.rsplit(".", 1)[0] if "." in module_name else ""
|
|
39
|
+
|
|
40
|
+
spec = importlib.util.spec_from_file_location(module_name, file_path)
|
|
33
41
|
if spec is None or spec.loader is None:
|
|
34
42
|
raise ImportError(f"Could not load module from {file_path}")
|
|
35
|
-
|
|
43
|
+
|
|
36
44
|
module = importlib.util.module_from_spec(spec)
|
|
37
|
-
module.__package__ =
|
|
45
|
+
module.__package__ = package_name
|
|
46
|
+
sys.modules[module_name] = module
|
|
38
47
|
spec.loader.exec_module(module)
|
|
39
48
|
|
|
40
49
|
if not hasattr(module, "handler"):
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.4-beta.149",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"ajv": "^8.17.1",
|