indexify 0.2.38__py3-none-any.whl → 0.2.40__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.
indexify/cli.py CHANGED
@@ -6,9 +6,11 @@ import subprocess
6
6
  import sys
7
7
  import threading
8
8
  import time
9
+ from importlib.metadata import version
9
10
  from typing import Annotated, List, Optional
10
11
 
11
12
  import nanoid
13
+ import structlog
12
14
  import typer
13
15
  from rich.console import Console
14
16
  from rich.panel import Panel
@@ -32,6 +34,7 @@ custom_theme = Theme(
32
34
  }
33
35
  )
34
36
 
37
+ logging = structlog.get_logger(module=__name__)
35
38
  console = Console(theme=custom_theme)
36
39
 
37
40
  app = typer.Typer(pretty_exceptions_enable=False, no_args_is_help=True)
@@ -158,6 +161,9 @@ def build_default_image():
158
161
  @app.command(help="Joins the extractors to the coordinator server")
159
162
  def executor(
160
163
  server_addr: str = "localhost:8900",
164
+ dev: Annotated[
165
+ bool, typer.Option("--dev", "-d", help="Run the executor in development mode")
166
+ ] = False,
161
167
  workers: Annotated[
162
168
  int, typer.Option(help="number of worker processes for extraction")
163
169
  ] = 1,
@@ -174,19 +180,26 @@ def executor(
174
180
  "1", help="Requested Image Version for this executor"
175
181
  ),
176
182
  ):
183
+ # configure structured logging
184
+ if not dev:
185
+ processors = [
186
+ structlog.processors.dict_tracebacks,
187
+ structlog.processors.JSONRenderer(),
188
+ ]
189
+ structlog.configure(processors=processors)
190
+
177
191
  id = nanoid.generate()
178
- console.print(
179
- Panel(
180
- f"Number of workers: {workers}\n"
181
- f"Config path: {config_path}\n"
182
- f"Server address: {server_addr}\n"
183
- f"Executor ID: {id}\n"
184
- f"Executor cache: {executor_cache}\n"
185
- f"Name Alias: {name_alias}"
186
- f"Image Version: {image_version}\n",
187
- title="Agent Configuration",
188
- border_style="info",
189
- )
192
+ executor_version = version("indexify")
193
+ logging.info(
194
+ "executor started",
195
+ workers=workers,
196
+ server_addr=server_addr,
197
+ config_path=config_path,
198
+ executor_id=id,
199
+ executor_version=executor_version,
200
+ executor_cache=executor_cache,
201
+ name_alias=name_alias,
202
+ image_version=image_version,
190
203
  )
191
204
 
192
205
  from pathlib import Path
@@ -208,8 +221,8 @@ def executor(
208
221
 
209
222
  try:
210
223
  asyncio.get_event_loop().run_until_complete(agent.run())
211
- except asyncio.CancelledError as ex:
212
- console.print(Text(f"Exiting gracefully: {ex}", style="bold yellow"))
224
+ except asyncio.CancelledError:
225
+ logging.info("graceful shutdown")
213
226
 
214
227
 
215
228
  def _create_image(image: Image, python_sdk_path):
@@ -299,7 +299,12 @@ class ExtractorAgent:
299
299
  image_version=image_version,
300
300
  labels=runtime_probe.labels,
301
301
  ).model_dump()
302
- logging.info("registering_executor", executor_id=self._executor_id, url=url)
302
+ logging.info(
303
+ "registering_executor",
304
+ executor_id=self._executor_id,
305
+ url=url,
306
+ executor_version=executor_version,
307
+ )
303
308
  try:
304
309
  async with get_httpx_client(self._config_path, True) as client:
305
310
  async with aconnect_sse(
@@ -65,7 +65,11 @@ def is_pydantic_model_from_annotation(type_annotation):
65
65
 
66
66
  class Graph:
67
67
  def __init__(
68
- self, name: str, start_node: IndexifyFunction, description: Optional[str] = None
68
+ self,
69
+ name: str,
70
+ start_node: IndexifyFunction,
71
+ description: Optional[str] = None,
72
+ tags: Dict[str, str] = {},
69
73
  ):
70
74
  self.name = name
71
75
  self.description = description
@@ -73,6 +77,7 @@ class Graph:
73
77
  self.routers: Dict[str, List[str]] = defaultdict(list)
74
78
  self.edges: Dict[str, List[str]] = defaultdict(list)
75
79
  self.accumulator_zero_values: Dict[str, Any] = {}
80
+ self.tags = tags
76
81
 
77
82
  self.add_node(start_node)
78
83
  if issubclass(start_node, IndexifyRouter):
@@ -204,12 +209,15 @@ class Graph:
204
209
  )
205
210
  )
206
211
 
212
+ print("TAGS", self.tags)
213
+
207
214
  return ComputeGraphMetadata(
208
215
  name=self.name,
209
216
  description=self.description or "",
210
217
  start_node=NodeMetadata(compute_fn=start_node),
211
218
  nodes=metadata_nodes,
212
219
  edges=metadata_edges,
220
+ tags=self.tags,
213
221
  runtime_information=RuntimeInformation(
214
222
  major_version=sys.version_info.major,
215
223
  minor_version=sys.version_info.minor,
@@ -44,6 +44,7 @@ class ComputeGraphMetadata(BaseModel):
44
44
  name: str
45
45
  description: str
46
46
  start_node: NodeMetadata
47
+ tags: Dict[str, str] = {}
47
48
  nodes: Dict[str, NodeMetadata]
48
49
  edges: Dict[str, List[str]]
49
50
  accumulator_zero_values: Dict[str, bytes] = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.2.38
3
+ Version: 0.2.40
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -1,23 +1,22 @@
1
1
  indexify/__init__.py,sha256=P0mvM8sbkeS2CjYzRYyzb42CnXGhyJXdz4FdmTBMSWM,697
2
- indexify/cli.py,sha256=TBycogrXcTK7q8IIcJxcpPPoZYve_rp6FYipWbkiTUI,8528
2
+ indexify/cli.py,sha256=QqaRpm-XywJQ3zh-2pgABi15Jl0IkwA_sz6PRNvQ4wc,8872
3
3
  indexify/common_util.py,sha256=LKS6yZ3yv8nF2J-KzisGIjqjTvCn7tLFifQJLT4gHRg,3529
4
4
  indexify/data_loaders/__init__.py,sha256=Y5NEuseTcYAICRiweYw5wBQ2m2YplbsY21I7df-rdi4,1339
5
5
  indexify/data_loaders/local_directory_loader.py,sha256=fCrgj5drnW71ZUdDDvcB1-VJjIs1w6Q8sEW0HSGSAiA,1247
6
6
  indexify/data_loaders/url_loader.py,sha256=32SERljcq1Xsi4RdLz2dgyk2TER5pQPTtXl3gUzwHbY,1533
7
7
  indexify/error.py,sha256=qAWr8R6AxPkjsxHSzXTc8zqYnNO_AjOqqYEPsQvF1Zs,238
8
- indexify/executor/agent.py,sha256=zWdcroELAA-C8LaChR518ey5UKaUhfTHtkyawpdOkIE,14053
8
+ indexify/executor/agent.py,sha256=6xcGDZLwFHlFDiqW9EOI_Dfxh8ahdhGZq4PZUoyPLEY,14167
9
9
  indexify/executor/api_objects.py,sha256=mvmwGbK4paJNQGFvbtNHMPpiH_LpVhrlRnCcrqS6HOQ,859
10
10
  indexify/executor/downloader.py,sha256=dHLxoBnX8-Bh4yZtFDYptZNF6rlVtmTk_70JK8Ect5w,4184
11
11
  indexify/executor/executor_tasks.py,sha256=A0UIEZ5VaB6zSkFQG81UmTW0E57MTYhGlaXuAbRV8lQ,1884
12
12
  indexify/executor/function_worker.py,sha256=wRW2-X9dNI80KhwTD1vD-pcyetsVKVs6vVdg7L7JjcQ,6462
13
- indexify/executor/image_dependency_installer.py,sha256=ct8GmzgkaPi6NAblk68IJJWo5MecIUubELotmSrgoRQ,1759
14
13
  indexify/executor/indexify_executor.py,sha256=2Ut_VX-Su_lm4b4aEROyRJ3gXx-uFHA-V7EN0sWiARE,771
15
14
  indexify/executor/runtime_probes.py,sha256=mjw2_mGQ622wRT_39WPGGgPEZQTgtrf3-ICcUUZOeyg,2126
16
15
  indexify/executor/task_reporter.py,sha256=XlEhNf_ScNnzG67zbtVwL7_9Bo8MvPZiHLI5UHymUnM,5305
17
16
  indexify/executor/task_store.py,sha256=JlRlWwAm4YjFRkTNRx-6GsUcmOzcyvzb5Csa5XDpRTI,3982
18
17
  indexify/functions_sdk/data_objects.py,sha256=wXbUa9hjU6rsXmmk19vQ5Kixf3FsI59VBWPNmHasAX0,854
19
- indexify/functions_sdk/graph.py,sha256=K7ZF8fPhISVWoNzUTkDF8dMfpF-NKw88FSe9dZHISME,13301
20
- indexify/functions_sdk/graph_definition.py,sha256=rJmGcy9u5A_Sme6Ol33NsCnSKQVjyUfeN9LnH3bU88Y,1732
18
+ indexify/functions_sdk/graph.py,sha256=jZSOVmlQB8Eb8MBz0TeRADl_4y5rnrjdTTy6VdRLISY,13448
19
+ indexify/functions_sdk/graph_definition.py,sha256=W3zRERTOC-UbiRms-NqvtlLDpSZM-33TocKeZXb5o_A,1762
21
20
  indexify/functions_sdk/graph_validation.py,sha256=mN2Fcp91GIwFZEQP6z_qGqt4LkLM70SnI7AWBi4CmKQ,2509
22
21
  indexify/functions_sdk/image.py,sha256=QK0H6KxLWriB_z4M0kunKzzHdHxYLWL670RPYgYuf_8,1762
23
22
  indexify/functions_sdk/indexify_functions.py,sha256=kjGmkRYnA_KO5ypkyaIhqrz0-3UJOFTPGldgOrHSRHY,13401
@@ -28,8 +27,8 @@ indexify/http_client.py,sha256=iLafZagCFnlTS6uHfOjInogjg0uXW_zXEspIN7ttB5I,15903
28
27
  indexify/remote_graph.py,sha256=OzBucU4buR5UdTViNJvh1RfnOTmYA34Uel5qXnRsQsA,5006
29
28
  indexify/remote_pipeline.py,sha256=oqx57rSPszNS3DToXO_nf-CKqkCZWptm1u_p3orV_gQ,790
30
29
  indexify/settings.py,sha256=Ny59mzYI4gbXoK8hjx66a_men6ndbd1J1zCTcKOoyzg,50
31
- indexify-0.2.38.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
32
- indexify-0.2.38.dist-info/METADATA,sha256=zS1J2a8q0kGIzLLKyGlqSKiJv6nWfHVLXKehq0KXd9U,6199
33
- indexify-0.2.38.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
34
- indexify-0.2.38.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
35
- indexify-0.2.38.dist-info/RECORD,,
30
+ indexify-0.2.40.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
31
+ indexify-0.2.40.dist-info/METADATA,sha256=x-8XRtgGLpvgQ5fEXUxamZwgoNtGCWPcbyvAgciO2HE,6199
32
+ indexify-0.2.40.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
33
+ indexify-0.2.40.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
34
+ indexify-0.2.40.dist-info/RECORD,,
@@ -1,64 +0,0 @@
1
- import os
2
- import subprocess
3
-
4
- from rich.console import Console
5
- from rich.text import Text
6
- from rich.theme import Theme
7
-
8
- from indexify.functions_sdk.image import ImageInformation
9
-
10
- custom_theme = Theme(
11
- {
12
- "info": "cyan",
13
- "warning": "yellow",
14
- "error": "red",
15
- "success": "green",
16
- }
17
- )
18
-
19
- console = Console(theme=custom_theme)
20
-
21
-
22
- def _record_image_name(name: str, version: int):
23
- dir_path = os.path.expanduser("~/.indexify/")
24
-
25
- file_path = os.path.expanduser("~/.indexify/image_name")
26
- os.makedirs(dir_path, exist_ok=True)
27
- with open(file_path, "w") as file:
28
- file.write(name)
29
-
30
- file_path = os.path.expanduser("~/.indexify/image_version")
31
- os.makedirs(dir_path, exist_ok=True)
32
- with open(file_path, "w") as file:
33
- file.write(str(version))
34
-
35
-
36
- def _install_dependencies(run_str: str):
37
- # Throw error to the caller if these subprocesses fail.
38
- proc = subprocess.run(run_str.split())
39
- if proc.returncode != 0:
40
- raise Exception(f"Unable to install dep `{run_str}`")
41
-
42
-
43
- def executor_image_builder(
44
- image_info: ImageInformation, name_alias: str, image_version: int
45
- ):
46
- console.print(Text("Attempting Executor Bootstrap.", style="red bold"))
47
-
48
- run_strs = image_info.run_strs
49
- console.print(Text("Attempting to install dependencies.", style="red bold"))
50
-
51
- for run_str in run_strs:
52
- console.print(Text(f"Attempting {run_str}", style="red bold"))
53
- _install_dependencies(run_str)
54
-
55
- console.print(Text("Install dependencies done.", style="red bold"))
56
-
57
- console.print(
58
- Text(
59
- f"Recording image name {name_alias} and version {image_version}",
60
- style="red bold",
61
- )
62
- )
63
-
64
- _record_image_name(name_alias, image_version)