Skip to content

Commit d600eb4

Browse files
refactor(mistralai): simplify the workflow integration
1 parent fcec503 commit d600eb4

3 files changed

Lines changed: 1595 additions & 57 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ agents = [
2929
"griffe >=1.7.3,<2.0",
3030
"authlib >=1.5.2,<2.0",
3131
]
32+
workflows = [
33+
"mistralai-workflows; python_version >= '3.12'",
34+
]
3235

3336
[project.urls]
3437
Repository = "https://github.com/mistralai/client-python.git"
@@ -58,6 +61,9 @@ default-groups = [
5861
"lint",
5962
]
6063

64+
[tool.uv.sources]
65+
mistralai-workflows = { path = "../dashboard/workflow_sdk" }
66+
6167
[tool.setuptools.package-data]
6268
"*" = ["py.typed", "src/mistralai/py.typed"]
6369

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,6 @@
1-
import importlib.util
2-
import os
3-
import sys
4-
from types import ModuleType
5-
6-
# Find and import the installed mistral-workflows package
7-
bridge_path = os.path.abspath(__file__)
8-
sys.modules.pop(__name__, None) # Remove bridge to avoid recursion
9-
101
try:
11-
# Search for the installed package (skip this bridge file)
12-
for path in sys.path:
13-
if not path:
14-
continue
15-
target = os.path.join(path, "mistralai", "workflows", "__init__.py")
16-
if os.path.exists(target) and os.path.abspath(target) != bridge_path:
17-
spec = importlib.util.spec_from_file_location("mistralai.workflows", target)
18-
if spec and spec.loader:
19-
workflows: ModuleType = importlib.util.module_from_spec(spec)
20-
sys.modules["mistralai.workflows"] = workflows
21-
spec.loader.exec_module(workflows)
22-
globals().update(
23-
{name: getattr(workflows, name) for name in workflows.__all__}
24-
)
25-
break
26-
else:
27-
raise ImportError(
28-
"mistral-workflows not installed. Run: pip install mistral-workflows"
29-
)
30-
finally:
31-
current_module = sys.modules.get("mistralai.workflows") or sys.modules.get(__name__)
32-
if current_module is not None:
33-
sys.modules[__name__] = current_module
2+
from mistralai_workflows import * # type: ignore
3+
except ImportError:
4+
raise ImportError(
5+
"mistralai-workflows not installed. Run: pip install 'mistralai[workflows]'"
6+
)

0 commit comments

Comments
 (0)