indexify 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.
indexify/cli.py CHANGED
@@ -119,7 +119,9 @@ def server_dev_mode():
119
119
 
120
120
  @app.command(help="Build image for function names")
121
121
  def build_image(
122
- workflow_file_path: str, func_names: List[str], python_sdk_path: Optional[str] = None
122
+ workflow_file_path: str,
123
+ image_names: List[str],
124
+ python_sdk_path: Optional[str] = None,
123
125
  ):
124
126
  globals_dict = {}
125
127
 
@@ -134,20 +136,9 @@ def build_image(
134
136
  raise Exception(
135
137
  f"Could not find workflow file to execute at: " f"`{workflow_file_path}`"
136
138
  )
137
-
138
- found_funcs = []
139
139
  for name, obj in globals_dict.items():
140
- for func_name in func_names:
141
- if name == func_name:
142
- found_funcs.append(name)
143
- _create_image_for_func(
144
- func_name=func_name, func_obj=obj, python_sdk_path=python_sdk_path
145
- )
146
-
147
- console.print(
148
- Text(f"Processed functions: ", style="cyan"),
149
- Text(f"{found_funcs}", style="green"),
150
- )
140
+ if type(obj) and isinstance(obj, Image) and obj._image_name in image_names:
141
+ _create_image(obj, python_sdk_path)
151
142
 
152
143
 
153
144
  @app.command(help="Build default image for indexify")
@@ -208,12 +199,12 @@ def executor(
208
199
  console.print(Text(f"Exiting gracefully: {ex}", style="bold yellow"))
209
200
 
210
201
 
211
- def _create_image_for_func(func_name, func_obj, python_sdk_path):
202
+ def _create_image(image: Image, python_sdk_path):
212
203
  console.print(
213
204
  Text("Creating container for ", style="cyan"),
214
- Text(f"`{func_name}`", style="cyan bold"),
205
+ Text(f"`{image._image_name}`", style="cyan bold"),
215
206
  )
216
- _build_image(image=func_obj.image, python_sdk_path=python_sdk_path)
207
+ _build_image(image=image, python_sdk_path=python_sdk_path)
217
208
 
218
209
 
219
210
  def _build_image(image: Image, python_sdk_path: Optional[str] = None):
@@ -18,6 +18,7 @@ function_wrapper_map: Dict[str, IndexifyFunctionWrapper] = {}
18
18
 
19
19
  import concurrent.futures
20
20
 
21
+
21
22
  class FunctionRunException(Exception):
22
23
  def __init__(
23
24
  self, exception: Exception, stdout: str, stderr: str, is_reducer: bool
@@ -131,7 +132,9 @@ def _run_function(
131
132
  fn_output = None
132
133
  has_failed = False
133
134
  exception_msg = None
134
- print(f"[bold] function_worker: [/bold] invoking function {fn_name} in graph {graph_name}")
135
+ print(
136
+ f"[bold] function_worker: [/bold] invoking function {fn_name} in graph {graph_name}"
137
+ )
135
138
  with redirect_stdout(stdout_capture), redirect_stderr(stderr_capture):
136
139
  try:
137
140
  key = f"{namespace}/{graph_name}/{version}/{fn_name}"
@@ -139,7 +142,10 @@ def _run_function(
139
142
  _load_function(namespace, graph_name, fn_name, code_path, version)
140
143
 
141
144
  fn = function_wrapper_map[key]
142
- if str(type(fn.indexify_function)) == "<class 'indexify.functions_sdk.indexify_functions.IndexifyRo'>":
145
+ if (
146
+ str(type(fn.indexify_function))
147
+ == "<class 'indexify.functions_sdk.indexify_functions.IndexifyRo'>"
148
+ ):
143
149
  router_output = fn.invoke_router(fn_name, input)
144
150
  else:
145
151
  fn_output = fn.invoke_fn_ser(fn_name, input, init_value)
@@ -147,6 +153,7 @@ def _run_function(
147
153
  is_reducer = fn.indexify_function.accumulate is not None
148
154
  except Exception as e:
149
155
  import sys
156
+
150
157
  print(traceback.format_exc(), file=sys.stderr)
151
158
  has_failed = True
152
159
  exception_msg = str(e)
@@ -117,13 +117,16 @@ class Graph:
117
117
  self.routers[from_node.name].append(node.name)
118
118
  return self
119
119
 
120
- def serialize(self):
120
+ def serialize(self, additional_modules):
121
121
  # Get all unique modules from nodes and edges
122
122
  pickled_functions = {}
123
+ for module in additional_modules:
124
+ cloudpickle.register_pickle_by_value(module)
123
125
  for node in self.nodes.values():
124
126
  cloudpickle.register_pickle_by_value(sys.modules[node.__module__])
125
127
  pickled_functions[node.name] = cloudpickle.dumps(node)
126
- cloudpickle.unregister_pickle_by_value(sys.modules[node.__module__])
128
+ if not sys.modules[node.__module__] in additional_modules:
129
+ cloudpickle.unregister_pickle_by_value(sys.modules[node.__module__])
127
130
  return pickled_functions
128
131
 
129
132
  def add_edge(
@@ -4,7 +4,7 @@ class Image:
4
4
 
5
5
  self._tag = "latest"
6
6
 
7
- self._base_image = "python:3.10.15-slim-bookworm"
7
+ self._base_image = "python:3.11.10-slim-bookworm"
8
8
 
9
9
  self._run_strs = []
10
10
 
@@ -29,6 +29,14 @@ DEFAULT_IMAGE = (
29
29
  Image()
30
30
  .name("tensorlake/indexify-executor-default")
31
31
  .base_image("python:3.10.15-slim-bookworm")
32
- .tag("latest")
32
+ .tag("3:10")
33
+ .run("pip install indexify")
34
+ )
35
+
36
+ DEFAULT_IMAGE_3_11 = (
37
+ Image()
38
+ .name("tensorlake/indexify-executor-default")
39
+ .base_image("python:3.11.10-slim-bookworm")
40
+ .tag("3:11")
33
41
  .run("pip install indexify")
34
42
  )
indexify/http_client.py CHANGED
@@ -160,9 +160,9 @@ class IndexifyClient:
160
160
  def __exit__(self, exc_type, exc_value, traceback):
161
161
  self.close()
162
162
 
163
- def register_compute_graph(self, graph: Graph):
163
+ def register_compute_graph(self, graph: Graph, additional_modules):
164
164
  graph_metadata = graph.definition()
165
- serialized_code = cloudpickle.dumps(graph.serialize())
165
+ serialized_code = cloudpickle.dumps(graph.serialize(additional_modules))
166
166
  response = self._post(
167
167
  f"namespaces/{self.namespace}/compute_graphs",
168
168
  files={"code": serialized_code},
@@ -197,9 +197,11 @@ class IndexifyClient:
197
197
  for item in namespaces_dict:
198
198
  namespaces.append(item["name"])
199
199
  return namespaces
200
-
200
+
201
201
  @classmethod
202
- def new_namespace(cls, namespace: str, server_addr: Optional[str] = "http://localhost:8900"):
202
+ def new_namespace(
203
+ cls, namespace: str, server_addr: Optional[str] = "http://localhost:8900"
204
+ ):
203
205
  # Create a new client instance with the specified server address
204
206
  client = cls(service_url=server_addr)
205
207
 
@@ -212,11 +214,10 @@ class IndexifyClient:
212
214
 
213
215
  # Set the namespace for the newly created client
214
216
  client.namespace = namespace
215
-
217
+
216
218
  # Return the client instance with the new namespace
217
219
  return client
218
220
 
219
-
220
221
  def create_namespace(self, namespace: str):
221
222
  self._post("namespaces", json={"name": namespace})
222
223
 
@@ -259,7 +260,9 @@ class IndexifyClient:
259
260
  return v["id"]
260
261
  if k == "DiagnosticMessage":
261
262
  message = v.get("message", None)
262
- print(f"[bold red]scheduler diagnostic: [/bold red]{message}")
263
+ print(
264
+ f"[bold red]scheduler diagnostic: [/bold red]{message}"
265
+ )
263
266
  continue
264
267
  event_payload = InvocationEventPayload.model_validate(v)
265
268
  event = InvocationEvent(event_name=k, payload=event_payload)
indexify/remote_graph.py CHANGED
@@ -32,7 +32,7 @@ class RemoteGraph:
32
32
  return self._client.invoke_graph_with_object(
33
33
  self._name, block_until_done, **kwargs
34
34
  )
35
-
35
+
36
36
  def rerun(self):
37
37
  """
38
38
  Rerun the graph with the given invocation ID.
@@ -41,17 +41,19 @@ class RemoteGraph:
41
41
  self._client.rerun_graph(self._name)
42
42
 
43
43
  @classmethod
44
- def deploy(cls, g: Graph, additional_modules=[], server_url: Optional[str] = "http://localhost:8900"):
44
+ def deploy(
45
+ cls,
46
+ g: Graph,
47
+ additional_modules=[],
48
+ server_url: Optional[str] = "http://localhost:8900",
49
+ ):
45
50
  """
46
51
  Create a new RemoteGraph from a local Graph object.
47
52
  :param g: The local Graph object.
48
53
  :param server_url: The URL of the server where the graph will be registered.
49
54
  """
50
- import cloudpickle
51
- for module in additional_modules:
52
- cloudpickle.register_pickle_by_value(module)
53
55
  client = IndexifyClient(service_url=server_url)
54
- client.register_compute_graph(g)
56
+ client.register_compute_graph(g, additional_modules)
55
57
  return cls(name=g.name, server_url=server_url)
56
58
 
57
59
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.2.10
3
+ Version: 0.2.12
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -1,5 +1,5 @@
1
1
  indexify/__init__.py,sha256=qgMBKVrM_tI-tFeWpE8ktlC5rcExk05nbWyFqxxqeEU,496
2
- indexify/cli.py,sha256=pE_RYmqkF35uRD18kbOQ1k9WIXIt2KQIzxyxRmJUxnI,8382
2
+ indexify/cli.py,sha256=SR4AWCxObIwHZzKb2iKMwtOQ3BcJUJIZ3SRiDvhv1sQ,8101
3
3
  indexify/data_loaders/__init__.py,sha256=Y5NEuseTcYAICRiweYw5wBQ2m2YplbsY21I7df-rdi4,1339
4
4
  indexify/data_loaders/local_directory_loader.py,sha256=fCrgj5drnW71ZUdDDvcB1-VJjIs1w6Q8sEW0HSGSAiA,1247
5
5
  indexify/data_loaders/url_loader.py,sha256=32SERljcq1Xsi4RdLz2dgyk2TER5pQPTtXl3gUzwHbY,1533
@@ -8,24 +8,24 @@ indexify/executor/agent.py,sha256=I08CiOWeJ_mz8OHr9_iJfp07Ma1VMQirZ2MsDp8lDZw,14
8
8
  indexify/executor/api_objects.py,sha256=SysjlGYu4JtYdqfexZHHN1IW4TtaDdFUF3hYZ5mpUJU,810
9
9
  indexify/executor/downloader.py,sha256=0MPiKw0AWs3Z7ReC9l2z-3515yqq85ghPzdh485dnuw,3998
10
10
  indexify/executor/executor_tasks.py,sha256=gAZ2pvza1YwGlaR1o_tJW4SXtdCgK7sLJgp4W7rOjR0,1834
11
- indexify/executor/function_worker.py,sha256=QafSvTiniiQUHIMbSRYcEpmFuy7--Cgk3s0ISCViggE,5372
11
+ indexify/executor/function_worker.py,sha256=RQh-lJD2UtUuYXyCDkGohe8rVpHEriJg-AjBKSgD5KI,5436
12
12
  indexify/executor/indexify_executor.py,sha256=2Ut_VX-Su_lm4b4aEROyRJ3gXx-uFHA-V7EN0sWiARE,771
13
13
  indexify/executor/runtime_probes.py,sha256=L-nB4D2zBZ287xxPwErv5R_gxFOmTEvg61FMe3rUB_A,1460
14
14
  indexify/executor/task_reporter.py,sha256=gnnse0v6rjjni8lNzeb-ZYq6iF2DgafKoT7dcGUZhQ4,3716
15
15
  indexify/executor/task_store.py,sha256=q8s2gImsFffWeXQR0mk1Xlo1Aj_2GfclNPjQ2EA_YBo,3984
16
16
  indexify/functions_sdk/data_objects.py,sha256=CQZMzYiV7l6dyzFkYquWQHqdte6JnC7XA3i2ZyvPvgQ,844
17
- indexify/functions_sdk/graph.py,sha256=2KyEggNTzB56PKnuKcO4g5lOl_XVzuVb7gfQKituDUc,11633
17
+ indexify/functions_sdk/graph.py,sha256=t35z26jRCBgoz7fncdlAL7MVTOYjeJuoPpz-xI7WjBw,11827
18
18
  indexify/functions_sdk/graph_definition.py,sha256=EJfC0MdKEbFF1CBaU0htrveSlcAQJCH96DLSNfZ02V4,1178
19
19
  indexify/functions_sdk/graph_validation.py,sha256=XLHiC9PAtZungJLysU3hIUOPNDkO5TXUDZ_jiZ0H4hg,2508
20
- indexify/functions_sdk/image.py,sha256=RcFhVjmQv83S2wuf7Yn9RMhdpT-WfRqr1-krCF5UjNM,716
20
+ indexify/functions_sdk/image.py,sha256=0-QrvMZSFT0_RGb8aeUfSYpSlh6QQkssFHLibGP9ywI,900
21
21
  indexify/functions_sdk/indexify_functions.py,sha256=oUssAADTt3byhz3Azl_GiYxV1BmhwuGE1CjmN-oiBpg,9575
22
22
  indexify/functions_sdk/local_cache.py,sha256=cNWF67zbhbTJe3g86hyLBy3Rqzs6dNvp2SjLazGZWvw,1348
23
23
  indexify/functions_sdk/object_serializer.py,sha256=Zz4GobW3ZamBBtFDF76QxU3TP6oJNdWnhsfKd0OUFoc,1660
24
- indexify/http_client.py,sha256=HMhNASth9B-sPdxo69v7kRVcqoCfU3ounur3Gxb37uk,13535
25
- indexify/remote_graph.py,sha256=Qy_mxyC00N4zBOV-ibuTak8ht2GlMck3nh0syq0VqOE,3165
24
+ indexify/http_client.py,sha256=0nB-2yQPoVfvTRGvRru_pW6SWjqeT8jtXJPm-MC71pg,13636
25
+ indexify/remote_graph.py,sha256=ILg6IY6EFgyvnfz1DSzicBZhqvPkg2-UUwgI6lxp6sA,3094
26
26
  indexify/settings.py,sha256=LSaWZ0ADIVmUv6o6dHWRC3-Ry5uLbCw2sBSg1e_U7UM,99
27
- indexify-0.2.10.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- indexify-0.2.10.dist-info/METADATA,sha256=zfFaEEl3NCpcX0lidfSePRdLIixeaefwfseOqIFfxlw,6130
29
- indexify-0.2.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
30
- indexify-0.2.10.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
31
- indexify-0.2.10.dist-info/RECORD,,
27
+ indexify-0.2.12.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ indexify-0.2.12.dist-info/METADATA,sha256=ryNoVKX3M3qm7MjZ_briF2E_BBF9kCx0eaKgDgmPpiA,6130
29
+ indexify-0.2.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
30
+ indexify-0.2.12.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
31
+ indexify-0.2.12.dist-info/RECORD,,