lmnr 0.2.10__py3-none-any.whl → 0.2.12__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.
lmnr/cli/cli.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from pathlib import Path
2
+ import sys
2
3
  import requests
3
4
  from dotenv import load_dotenv
4
5
  import os
@@ -8,6 +9,8 @@ from cookiecutter.main import cookiecutter
8
9
  from pydantic.alias_generators import to_pascal
9
10
 
10
11
  from lmnr.cli.zip import zip_directory
12
+ from lmnr.sdk.registry import Registry as Pipeline
13
+ from lmnr.sdk.remote_debugger import RemoteDebugger
11
14
 
12
15
  from .parser.parser import runnable_graph_to_template_vars
13
16
 
@@ -134,3 +137,47 @@ def deploy(endpoint_id, project_api_key):
134
137
  logging.exception("Error in deploying code")
135
138
  finally:
136
139
  Path.unlink(zip_file_path, missing_ok=True)
140
+
141
+
142
+ @cli.command(name="dev")
143
+ @click.option(
144
+ "-p",
145
+ "--project-api-key",
146
+ help="Project API key",
147
+ )
148
+ def dev(project_api_key):
149
+ project_api_key = project_api_key or os.environ.get("LMNR_PROJECT_API_KEY")
150
+ if not project_api_key:
151
+ load_dotenv()
152
+ project_api_key = os.environ.get("LMNR_PROJECT_API_KEY")
153
+ if not project_api_key:
154
+ raise ValueError("LMNR_PROJECT_API_KEY is not set")
155
+
156
+ print(f"Sys path: {sys.path}")
157
+
158
+ cur_dir = os.getcwd() # e.g. /Users/username/project_name
159
+ parent_dir, name = os.path.split(cur_dir) # e.g. /Users/username, project_name
160
+
161
+ # Needed to __import__ pipeline.py
162
+ if sys.path[0] != parent_dir:
163
+ sys.path.insert(0, parent_dir)
164
+ # Needed to import src in pipeline.py and other files
165
+ if cur_dir not in sys.path:
166
+ sys.path.insert(0, cur_dir)
167
+
168
+ print(f"Sys path: {sys.path}")
169
+
170
+ module_name = f"{name}.pipeline"
171
+ __import__(module_name)
172
+ module = sys.modules[module_name]
173
+
174
+ matches = [v for v in module.__dict__.values() if isinstance(v, Pipeline)]
175
+ if not matches:
176
+ raise ValueError("No Pipeline found in the module")
177
+ if len(matches) > 1:
178
+ raise ValueError("Multiple Pipelines found in the module")
179
+ pipeline = matches[0]
180
+
181
+ tools = pipeline.functions
182
+ debugger = RemoteDebugger(project_api_key, tools)
183
+ debugger.start()
lmnr/cli/zip.py CHANGED
@@ -7,6 +7,10 @@ def zip_directory(directory_path: Path, zip_file_path: Path):
7
7
  with zipfile.ZipFile(zip_file_path, "w", zipfile.ZIP_DEFLATED) as zipf:
8
8
  for root, _, files in os.walk(directory_path):
9
9
  for file in files:
10
+ # Don't include the zip file itself, otherwise goes to infinite loop
11
+ if file == zip_file_path.name:
12
+ continue
13
+
10
14
  file_path = os.path.join(root, file)
11
15
  arcname = os.path.relpath(file_path, directory_path)
12
16
  zipf.write(file_path, arcname)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lmnr
3
- Version: 0.2.10
3
+ Version: 0.2.12
4
4
  Summary: Python SDK for Laminar AI
5
5
  License: Apache-2.0
6
6
  Author: lmnr.ai
@@ -1,7 +1,7 @@
1
1
  lmnr/__init__.py,sha256=BBJ87AiHC_OpaYOCzF8QSsf7eO3LlJPOCBXHNKurbE4,235
2
2
  lmnr/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  lmnr/cli/__main__.py,sha256=8hDtWlaFZK24KhfNq_ZKgtXqYHsDQDetukOCMlsbW0Q,59
4
- lmnr/cli/cli.py,sha256=qG3-aY2EJIW3BSD-_s1vUsxHcxC9kiuIeAO8aVUq3ik,4103
4
+ lmnr/cli/cli.py,sha256=HWnsIc5kFajq_VVJdJzRzEeNhBiVLgKaVp-GmC1itxI,5581
5
5
  lmnr/cli/parser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  lmnr/cli/parser/nodes/__init__.py,sha256=2MkPdKulb1kuNe6aT71CaqBA8iBrXyb5pq5bu_EvCb8,1052
7
7
  lmnr/cli/parser/nodes/code.py,sha256=8lTPBibUzaw_t-9QoPljhxH3KA4CLn9DJjA-iWpprOA,933
@@ -15,14 +15,14 @@ lmnr/cli/parser/nodes/semantic_search.py,sha256=DWDPpV78XZ7vPIaPd86FbeDFAnKah4e6
15
15
  lmnr/cli/parser/nodes/types.py,sha256=OVXj-iMEDY9nPKCX1-zddtoszZcUL3CXYYryI7O3et0,6094
16
16
  lmnr/cli/parser/parser.py,sha256=yDa-ysAkh6si_hHU8Gw8EdtNWc4pFc5RbvgWEXGEPys,2370
17
17
  lmnr/cli/parser/utils.py,sha256=1oy6BApHXOF7BTXbP8v3Oi9bwOdWZjoxDlRIOfXVxro,1169
18
- lmnr/cli/zip.py,sha256=DpAfSVg6k0Ly55SY7rsIZkX0XG6U6IPD-HzsNi5Cf-U,445
18
+ lmnr/cli/zip.py,sha256=u2-LcYtQdZ_FIW0-PM-WGjclNPoB8v6OecrI79PyLPw,607
19
19
  lmnr/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  lmnr/sdk/endpoint.py,sha256=0HjcxMUcJz-klFZO2f5xtTaoLjcaEb8vrJ_YldTWUc8,7467
21
21
  lmnr/sdk/registry.py,sha256=sEYQFOjO72YvgBSEkBrvoewFExoyBzx6nELgBarvD6Y,755
22
22
  lmnr/sdk/remote_debugger.py,sha256=BYAN13KUDxH412qD3HXdDH0RfokrePquDt35fzB7GUg,5010
23
23
  lmnr/types.py,sha256=3HpLBQZr6F5YMISHYLnzzyrTwUttNqJxpyobw31YYJQ,2347
24
- lmnr-0.2.10.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
25
- lmnr-0.2.10.dist-info/METADATA,sha256=STv0WzrtahyFBUaq_uLDuPVts5pd3dLgCfjdeQJ0Oyk,5565
26
- lmnr-0.2.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
27
- lmnr-0.2.10.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
28
- lmnr-0.2.10.dist-info/RECORD,,
24
+ lmnr-0.2.12.dist-info/LICENSE,sha256=67b_wJHVV1CBaWkrKFWU1wyqTPSdzH77Ls-59631COg,10411
25
+ lmnr-0.2.12.dist-info/METADATA,sha256=ioChA7mM_fEj2KfrvXEtsHnyH5uTMgkPD46b-HcvkfE,5565
26
+ lmnr-0.2.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
27
+ lmnr-0.2.12.dist-info/entry_points.txt,sha256=Qg7ZRax4k-rcQsZ26XRYQ8YFSBiyY2PNxYfq4a6PYXI,41
28
+ lmnr-0.2.12.dist-info/RECORD,,
File without changes
File without changes