pixie-prompts 0.1.8__tar.gz → 0.1.8.dev6__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixie-prompts
3
- Version: 0.1.8
3
+ Version: 0.1.8.dev6
4
4
  Summary: Code-first, type-safe prompt management
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -18,85 +18,6 @@ _storage_observer: Observer | None = None # type: ignore
18
18
  _storage_reload_task: asyncio.Task | None = None
19
19
 
20
20
 
21
- def _preload_pixie_modules(cwd: Path) -> None:
22
- """Pre-load pixie modules from the local source directory.
23
-
24
- This ensures that when dynamically loaded modules import pixie.registry,
25
- they get the same module instance as the rest of the application.
26
-
27
- Without this, namespace package collisions can occur when pixie-prompts
28
- is installed as a package while pixie-sdk-py is run from source. The
29
- dynamic module loading via importlib.util.spec_from_file_location() can
30
- create separate module instances, leading to separate _registry dicts.
31
-
32
- Args:
33
- cwd: The current working directory to search for pixie modules.
34
- """
35
- pixie_dir = cwd / "pixie"
36
- if not pixie_dir.is_dir():
37
- return
38
-
39
- # Find all pixie submodules that exist locally and pre-import them
40
- # This ensures they're in sys.modules before any dynamic loading
41
- pixie_modules_to_preload = []
42
-
43
- for py_file in pixie_dir.rglob("*.py"):
44
- if py_file.name.startswith("_"):
45
- continue
46
- # Skip if in __pycache__ or similar
47
- if "__pycache__" in py_file.parts:
48
- continue
49
-
50
- relative_path = py_file.relative_to(cwd)
51
- module_name = str(relative_path.with_suffix("")).replace("/", ".")
52
- pixie_modules_to_preload.append((module_name, py_file))
53
-
54
- # Sort to ensure parent modules are loaded before children
55
- pixie_modules_to_preload.sort(key=lambda x: x[0])
56
-
57
- for module_name, py_file in pixie_modules_to_preload:
58
- if module_name in sys.modules:
59
- continue
60
-
61
- # Ensure parent packages are in sys.modules
62
- parts = module_name.split(".")
63
- for i in range(1, len(parts)):
64
- parent_name = ".".join(parts[:i])
65
- if parent_name not in sys.modules:
66
- parent_path = cwd / Path(*parts[:i])
67
- init_file = parent_path / "__init__.py"
68
- if init_file.exists():
69
- spec = importlib.util.spec_from_file_location(
70
- parent_name, init_file
71
- )
72
- if spec and spec.loader:
73
- module = importlib.util.module_from_spec(spec)
74
- sys.modules[parent_name] = module
75
- try:
76
- spec.loader.exec_module(module)
77
- except Exception:
78
- pass
79
- else:
80
- # Create a namespace package
81
- import types
82
-
83
- ns_module = types.ModuleType(parent_name)
84
- ns_module.__path__ = [str(parent_path)]
85
- sys.modules[parent_name] = ns_module
86
-
87
- # Now load the actual module
88
- spec = importlib.util.spec_from_file_location(module_name, py_file)
89
- if spec and spec.loader:
90
- try:
91
- module = importlib.util.module_from_spec(spec)
92
- sys.modules[module_name] = module
93
- spec.loader.exec_module(module)
94
- except Exception:
95
- # Don't fail if a module can't be loaded - it might have
96
- # dependencies that aren't available yet
97
- pass
98
-
99
-
100
21
  def discover_and_load_modules():
101
22
  """Discover and load all Python files that use pixie.prompts.create_prompt, or pixie.create_prompt.
102
23
 
@@ -113,10 +34,6 @@ def discover_and_load_modules():
113
34
  if str(cwd) not in sys.path:
114
35
  sys.path.insert(0, str(cwd))
115
36
 
116
- # Pre-load pixie modules from local source to avoid namespace package collisions
117
- # This ensures dynamically loaded modules use the same pixie.registry instance
118
- _preload_pixie_modules(cwd)
119
-
120
37
  loaded_count = 0
121
38
  for py_file in python_files:
122
39
  # Skip __init__.py, private files, and anything in site-packages/venv
@@ -141,12 +58,6 @@ def discover_and_load_modules():
141
58
  # Load the module with a unique name based on path
142
59
  relative_path = py_file.relative_to(cwd)
143
60
  module_name = str(relative_path.with_suffix("")).replace("/", ".")
144
-
145
- # Skip if module was already loaded (e.g., during preload)
146
- if module_name in sys.modules:
147
- loaded_count += 1
148
- continue
149
-
150
61
  spec = importlib.util.spec_from_file_location(module_name, py_file)
151
62
  if spec and spec.loader:
152
63
  try:
@@ -111,8 +111,6 @@ class Query:
111
111
  Returns:
112
112
  A list of model names supported by the server.
113
113
  """
114
- if is_demo_mode():
115
- return ["openai:gpt-4o-mini"]
116
114
  return list(get_args(KnownModelName.__value__))
117
115
 
118
116
  @strawberry.field
@@ -4,7 +4,7 @@ packages = [
4
4
  { include = "pixie" },
5
5
  ]
6
6
 
7
- version = "0.1.8"
7
+ version = "0.1.8.dev6"
8
8
  description = "Code-first, type-safe prompt management"
9
9
  authors = ["Yiou Li <yol@gopixie.ai>"]
10
10
  license = "MIT"