indexify 0.2.35__tar.gz → 0.2.37__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.
Files changed (34) hide show
  1. {indexify-0.2.35 → indexify-0.2.37}/PKG-INFO +1 -1
  2. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/agent.py +3 -2
  3. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/graph.py +5 -0
  4. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/indexify_functions.py +56 -9
  5. {indexify-0.2.35 → indexify-0.2.37}/indexify/remote_graph.py +3 -3
  6. {indexify-0.2.35 → indexify-0.2.37}/pyproject.toml +1 -1
  7. {indexify-0.2.35 → indexify-0.2.37}/LICENSE.txt +0 -0
  8. {indexify-0.2.35 → indexify-0.2.37}/README.md +0 -0
  9. {indexify-0.2.35 → indexify-0.2.37}/indexify/__init__.py +0 -0
  10. {indexify-0.2.35 → indexify-0.2.37}/indexify/cli.py +0 -0
  11. {indexify-0.2.35 → indexify-0.2.37}/indexify/common_util.py +0 -0
  12. {indexify-0.2.35 → indexify-0.2.37}/indexify/data_loaders/__init__.py +0 -0
  13. {indexify-0.2.35 → indexify-0.2.37}/indexify/data_loaders/local_directory_loader.py +0 -0
  14. {indexify-0.2.35 → indexify-0.2.37}/indexify/data_loaders/url_loader.py +0 -0
  15. {indexify-0.2.35 → indexify-0.2.37}/indexify/error.py +0 -0
  16. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/api_objects.py +0 -0
  17. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/downloader.py +0 -0
  18. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/executor_tasks.py +0 -0
  19. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/function_worker.py +0 -0
  20. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/image_dependency_installer.py +0 -0
  21. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/indexify_executor.py +0 -0
  22. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/runtime_probes.py +0 -0
  23. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/task_reporter.py +0 -0
  24. {indexify-0.2.35 → indexify-0.2.37}/indexify/executor/task_store.py +0 -0
  25. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/data_objects.py +0 -0
  26. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/graph_definition.py +0 -0
  27. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/graph_validation.py +0 -0
  28. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/image.py +0 -0
  29. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/local_cache.py +0 -0
  30. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/object_serializer.py +0 -0
  31. {indexify-0.2.35 → indexify-0.2.37}/indexify/functions_sdk/pipeline.py +0 -0
  32. {indexify-0.2.35 → indexify-0.2.37}/indexify/http_client.py +0 -0
  33. {indexify-0.2.35 → indexify-0.2.37}/indexify/remote_pipeline.py +0 -0
  34. {indexify-0.2.35 → indexify-0.2.37}/indexify/settings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.2.35
3
+ Version: 0.2.37
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -299,7 +299,7 @@ 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)
302
+ logging.info("registering_executor", executor_id=self._executor_id, url=url)
303
303
  try:
304
304
  async with get_httpx_client(self._config_path, True) as client:
305
305
  async with aconnect_sse(
@@ -310,9 +310,10 @@ class ExtractorAgent:
310
310
  headers={"Content-Type": "application/json"},
311
311
  ) as event_source:
312
312
  if not event_source.response.is_success:
313
+ resp = await event_source.response.aread()
313
314
  logging.error(
314
315
  f"failed to register",
315
- resp=str(event_source.response.content),
316
+ resp=str(resp),
316
317
  status_code=event_source.response.status_code,
317
318
  )
318
319
  await asyncio.sleep(5)
@@ -147,6 +147,11 @@ class Graph:
147
147
  from_node: Union[Type[IndexifyFunction], Type[IndexifyRouter]],
148
148
  to_node: List[Union[Type[IndexifyFunction], Type[IndexifyRouter]]],
149
149
  ) -> "Graph":
150
+ if issubclass(from_node, IndexifyRouter):
151
+ raise ValueError(
152
+ "Cannot add edges from a router node, use route method instead"
153
+ )
154
+
150
155
  self.add_node(from_node)
151
156
  from_node_name = from_node.name
152
157
  for node in to_node:
@@ -112,11 +112,32 @@ class IndexifyRouter:
112
112
  pass
113
113
 
114
114
 
115
- from inspect import signature
115
+ from inspect import Parameter, signature
116
116
 
117
117
  from typing_extensions import get_type_hints
118
118
 
119
119
 
120
+ def _process_dict_arg(dict_arg: dict, sig: inspect.Signature) -> Tuple[list, dict]:
121
+ new_args = []
122
+ new_kwargs = {}
123
+ remaining_kwargs = dict_arg.copy()
124
+
125
+ # Match dictionary keys to function parameters
126
+ for param_name, param in sig.parameters.items():
127
+ if param_name in dict_arg:
128
+ new_args.append(dict_arg[param_name])
129
+ remaining_kwargs.pop(param_name, None)
130
+
131
+ if any(v.kind == Parameter.VAR_KEYWORD for v in sig.parameters.values()):
132
+ # Combine remaining dict items with additional kwargs
133
+ new_kwargs.update(remaining_kwargs)
134
+ elif len(remaining_kwargs) > 0:
135
+ # If there are remaining kwargs, add them as a single dict argument
136
+ new_args.append(remaining_kwargs)
137
+
138
+ return new_args, new_kwargs
139
+
140
+
120
141
  def indexify_router(
121
142
  name: Optional[str] = None,
122
143
  description: Optional[str] = "",
@@ -132,6 +153,13 @@ def indexify_router(
132
153
 
133
154
  # Create run method that preserves signature
134
155
  def run(self, *args, **kwargs):
156
+ # Process dictionary argument mapping it to args or to kwargs.
157
+ if len(args) == 1 and isinstance(args[0], dict):
158
+ sig = inspect.signature(fn)
159
+ dict_arg = args[0]
160
+ new_args, new_kwargs = _process_dict_arg(dict_arg, sig)
161
+ return fn(*new_args, **new_kwargs)
162
+
135
163
  return fn(*args, **kwargs)
136
164
 
137
165
  # Apply original signature and annotations to run method
@@ -173,6 +201,20 @@ def indexify_function(
173
201
 
174
202
  # Create run method that preserves signature
175
203
  def run(self, *args, **kwargs):
204
+ # Process dictionary argument mapping it to args or to kwargs.
205
+ if self.accumulate and len(args) == 2 and isinstance(args[1], dict):
206
+ sig = inspect.signature(fn)
207
+ new_args = [args[0]] # Keep the accumulate argument
208
+ dict_arg = args[1]
209
+ new_args_from_dict, new_kwargs = _process_dict_arg(dict_arg, sig)
210
+ new_args.extend(new_args_from_dict)
211
+ return fn(*new_args, **new_kwargs)
212
+ elif len(args) == 1 and isinstance(args[0], dict):
213
+ sig = inspect.signature(fn)
214
+ dict_arg = args[0]
215
+ new_args, new_kwargs = _process_dict_arg(dict_arg, sig)
216
+ return fn(*new_args, **new_kwargs)
217
+
176
218
  return fn(*args, **kwargs)
177
219
 
178
220
  # Apply original signature and annotations to run method
@@ -252,14 +294,15 @@ class IndexifyFunctionWrapper:
252
294
  def run_router(
253
295
  self, input: Union[Dict, Type[BaseModel]]
254
296
  ) -> Tuple[List[str], Optional[str]]:
255
- kwargs = input if isinstance(input, dict) else {"input": input}
256
297
  args = []
257
298
  kwargs = {}
258
- if isinstance(input, dict):
259
- kwargs = input
260
- else:
261
- args.append(input)
262
299
  try:
300
+ # tuple and list are considered positional arguments, list is used for compatibility
301
+ # with json encoding which won't deserialize in tuple.
302
+ if isinstance(input, tuple) or isinstance(input, list):
303
+ args += input
304
+ else:
305
+ args.append(input)
263
306
  extracted_data = self.indexify_function.run(*args, **kwargs)
264
307
  except Exception as e:
265
308
  return [], traceback.format_exc()
@@ -271,14 +314,18 @@ class IndexifyFunctionWrapper:
271
314
  return edges, None
272
315
 
273
316
  def run_fn(
274
- self, input: Union[Dict, Type[BaseModel]], acc: Type[Any] = None
317
+ self, input: Union[Dict, Type[BaseModel], List, Tuple], acc: Type[Any] = None
275
318
  ) -> Tuple[List[Any], Optional[str]]:
276
319
  args = []
277
320
  kwargs = {}
321
+
278
322
  if acc is not None:
279
323
  args.append(acc)
280
- if isinstance(input, dict):
281
- kwargs = input
324
+
325
+ # tuple and list are considered positional arguments, list is used for compatibility
326
+ # with json encoding which won't deserialize in tuple.
327
+ if isinstance(input, tuple) or isinstance(input, list):
328
+ args += input
282
329
  else:
283
330
  args.append(input)
284
331
 
@@ -23,7 +23,7 @@ class RemoteGraph:
23
23
  :param server_url: The URL of the server where the graph will be registered.
24
24
  Not used if client is provided.
25
25
  :param client: The IndexifyClient used to communicate with the server.
26
- Prefered over server_url.
26
+ Preferred over server_url.
27
27
  """
28
28
  self._name = name
29
29
  if client:
@@ -88,7 +88,7 @@ class RemoteGraph:
88
88
  :param server_url: The URL of the server where the graph will be registered.
89
89
  Not used if client is provided.
90
90
  :param client: The IndexifyClient used to communicate with the server.
91
- Prefered over server_url.
91
+ Preferred over server_url.
92
92
  """
93
93
  g.validate_graph()
94
94
  if not client:
@@ -110,7 +110,7 @@ class RemoteGraph:
110
110
  :param server_url: The URL of the server where the graph will be registered.
111
111
  Not used if client is provided.
112
112
  :param client: The IndexifyClient used to communicate with the server.
113
- Prefered over server_url.
113
+ Preferred over server_url.
114
114
  :return: A RemoteGraph object.
115
115
  """
116
116
  return cls(name=name, server_url=server_url, client=client)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "indexify"
3
- version = "0.2.35"
3
+ version = "0.2.37"
4
4
  description = "Python Client for Indexify"
5
5
  authors = ["Tensorlake Inc. <support@tensorlake.ai>"]
6
6
  license = "Apache 2.0"
File without changes
File without changes
File without changes
File without changes