indexify 0.2.18__tar.gz → 0.2.20__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 (33) hide show
  1. {indexify-0.2.18 → indexify-0.2.20}/PKG-INFO +1 -1
  2. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/agent.py +5 -2
  3. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/api_objects.py +1 -0
  4. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/task_reporter.py +4 -4
  5. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/graph.py +3 -3
  6. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/indexify_functions.py +3 -3
  7. indexify-0.2.20/indexify/remote_graph.py +120 -0
  8. {indexify-0.2.18 → indexify-0.2.20}/pyproject.toml +1 -1
  9. indexify-0.2.18/indexify/remote_graph.py +0 -86
  10. {indexify-0.2.18 → indexify-0.2.20}/LICENSE.txt +0 -0
  11. {indexify-0.2.18 → indexify-0.2.20}/README.md +0 -0
  12. {indexify-0.2.18 → indexify-0.2.20}/indexify/__init__.py +0 -0
  13. {indexify-0.2.18 → indexify-0.2.20}/indexify/cli.py +0 -0
  14. {indexify-0.2.18 → indexify-0.2.20}/indexify/data_loaders/__init__.py +0 -0
  15. {indexify-0.2.18 → indexify-0.2.20}/indexify/data_loaders/local_directory_loader.py +0 -0
  16. {indexify-0.2.18 → indexify-0.2.20}/indexify/data_loaders/url_loader.py +0 -0
  17. {indexify-0.2.18 → indexify-0.2.20}/indexify/error.py +0 -0
  18. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/downloader.py +0 -0
  19. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/executor_tasks.py +0 -0
  20. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/function_worker.py +0 -0
  21. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/indexify_executor.py +0 -0
  22. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/runtime_probes.py +0 -0
  23. {indexify-0.2.18 → indexify-0.2.20}/indexify/executor/task_store.py +0 -0
  24. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/data_objects.py +0 -0
  25. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/graph_definition.py +0 -0
  26. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/graph_validation.py +0 -0
  27. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/image.py +0 -0
  28. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/local_cache.py +0 -0
  29. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/object_serializer.py +0 -0
  30. {indexify-0.2.18 → indexify-0.2.20}/indexify/functions_sdk/pipeline.py +0 -0
  31. {indexify-0.2.18 → indexify-0.2.20}/indexify/http_client.py +0 -0
  32. {indexify-0.2.18 → indexify-0.2.20}/indexify/remote_pipeline.py +0 -0
  33. {indexify-0.2.18 → indexify-0.2.20}/indexify/settings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.2.18
3
+ Version: 0.2.20
4
4
  Summary: Python Client for Indexify
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -2,6 +2,7 @@ import asyncio
2
2
  import json
3
3
  import ssl
4
4
  from concurrent.futures.process import BrokenProcessPool
5
+ from importlib.metadata import version
5
6
  from typing import Dict, List, Optional
6
7
 
7
8
  import httpx
@@ -115,9 +116,9 @@ class ExtractorAgent:
115
116
  )
116
117
  console.print(
117
118
  Panel(
118
- f"Reporting outcome of task {task_outcome.task.id}\n"
119
+ f"Reporting outcome of task: {task_outcome.task.id}, function: {task_outcome.task.compute_fn}\n"
119
120
  f"Outcome: {style_outcome}\n"
120
- f"Outputs: {len(task_outcome.outputs or [])} Router Output: {task_outcome.router_output}",
121
+ f"Num Fn Outputs: {len(task_outcome.outputs or [])} Router Output: {task_outcome.router_output}",
121
122
  title="Task Completion",
122
123
  border_style="info",
123
124
  )
@@ -314,8 +315,10 @@ class ExtractorAgent:
314
315
  # rewrite the image name
315
316
  pass
316
317
 
318
+ executor_version = version("indexify")
317
319
  data = ExecutorMetadata(
318
320
  id=self._executor_id,
321
+ executor_version=executor_version,
319
322
  addr="",
320
323
  image_name=runtime_probe.image_name,
321
324
  labels=runtime_probe.labels,
@@ -18,6 +18,7 @@ class Task(BaseModel):
18
18
 
19
19
  class ExecutorMetadata(BaseModel):
20
20
  id: str
21
+ executor_version: str
21
22
  addr: str
22
23
  image_name: str
23
24
  labels: Dict[str, Any]
@@ -28,11 +28,11 @@ class TaskReporter:
28
28
 
29
29
  def report_task_outcome(self, completed_task: CompletedTask):
30
30
  fn_outputs = []
31
- print(
32
- f"[bold]task-reporter[/bold] uploading output of size: {len(completed_task.outputs or [])}"
33
- )
34
31
  for output in completed_task.outputs or []:
35
- output_bytes = MsgPackSerializer.serialize(output)
32
+ print(
33
+ f"[bold]task-reporter[/bold] uploading output of size: {len(output_bytes)} bytes"
34
+ )
35
+ output_bytes = MsgPackSerializer.serialize(output)
36
36
  fn_outputs.append(
37
37
  ("node_outputs", (nanoid.generate(), io.BytesIO(output_bytes)))
38
38
  )
@@ -96,9 +96,9 @@ class Graph:
96
96
  return self
97
97
 
98
98
  if issubclass(indexify_fn, IndexifyFunction) and indexify_fn.accumulate:
99
- self.accumulator_zero_values[
100
- indexify_fn.name
101
- ] = indexify_fn.accumulate().model_dump()
99
+ self.accumulator_zero_values[indexify_fn.name] = (
100
+ indexify_fn.accumulate().model_dump()
101
+ )
102
102
 
103
103
  self.nodes[indexify_fn.name] = indexify_fn
104
104
  return self
@@ -206,9 +206,9 @@ class RouterCallResult(BaseModel):
206
206
 
207
207
  class IndexifyFunctionWrapper:
208
208
  def __init__(self, indexify_function: Union[IndexifyFunction, IndexifyRouter]):
209
- self.indexify_function: Union[
210
- IndexifyFunction, IndexifyRouter
211
- ] = indexify_function()
209
+ self.indexify_function: Union[IndexifyFunction, IndexifyRouter] = (
210
+ indexify_function()
211
+ )
212
212
 
213
213
  def get_output_model(self) -> Any:
214
214
  if not isinstance(self.indexify_function, IndexifyFunction):
@@ -0,0 +1,120 @@
1
+ from typing import Any, List, Optional
2
+
3
+ from indexify.functions_sdk.graph import Graph
4
+
5
+ from .http_client import IndexifyClient
6
+ from .settings import DEFAULT_SERVICE_URL
7
+
8
+
9
+ class RemoteGraph:
10
+ def __init__(
11
+ self,
12
+ name: str,
13
+ server_url: Optional[str] = DEFAULT_SERVICE_URL,
14
+ client: Optional[IndexifyClient] = None,
15
+ ):
16
+ """
17
+ Create a handle to call a RemoteGraph by name.
18
+
19
+ Note: Use the class methods RemoteGraph.deploy or RemoteGraph.by_name to create a RemoteGraph object.
20
+
21
+ :param name: The name of the graph.
22
+ :param server_url: The URL of the server where the graph will be registered.
23
+ Not used if client is provided.
24
+ :param client: The IndexifyClient used to communicate with the server.
25
+ Prefered over server_url.
26
+ """
27
+ self._name = name
28
+ if client:
29
+ self._client = client
30
+ else:
31
+ self._client = IndexifyClient(service_url=server_url)
32
+
33
+ def run(self, block_until_done: bool = False, **kwargs) -> str:
34
+ """
35
+ Run the graph with the given inputs. The input is for the start function of the graph.
36
+
37
+ :param block_until_done: If True, the function will block until the graph execution is complete.
38
+ :param kwargs: The input to the start function of the graph. Pass the input as keyword arguments.
39
+ :return: The invocation ID of the graph execution.
40
+
41
+ Example:
42
+
43
+ @indexify_function()
44
+ def foo(x: int) -> int:
45
+ return x + 1
46
+
47
+ remote_graph = RemoteGraph.by_name("test")
48
+ invocation_id = remote_graph.run(x=1)
49
+ """
50
+ return self._client.invoke_graph_with_object(
51
+ self._name, block_until_done, **kwargs
52
+ )
53
+
54
+ def rerun(self):
55
+ """
56
+ Rerun the graph with the given invocation ID.
57
+
58
+ :param invocation_id: The invocation ID of the graph execution.
59
+ """
60
+ self._client.rerun_graph(self._name)
61
+
62
+ @classmethod
63
+ def deploy(
64
+ cls,
65
+ g: Graph,
66
+ additional_modules=[],
67
+ server_url: Optional[str] = DEFAULT_SERVICE_URL,
68
+ client: Optional[IndexifyClient] = None,
69
+ ):
70
+ """
71
+ Create a new RemoteGraph from a local Graph object.
72
+
73
+ :param g: The local Graph object.
74
+ :param additional_modules: List of additional modules to be registered with the graph.
75
+ Needed for modules that are imported outside of an indexify function.
76
+ :param server_url: The URL of the server where the graph will be registered.
77
+ Not used if client is provided.
78
+ :param client: The IndexifyClient used to communicate with the server.
79
+ Prefered over server_url.
80
+ """
81
+ if not client:
82
+ client = IndexifyClient(service_url=server_url)
83
+ client.register_compute_graph(g, additional_modules)
84
+ return cls(name=g.name, server_url=server_url, client=client)
85
+
86
+ @classmethod
87
+ def by_name(cls, name: str, server_url: Optional[str] = DEFAULT_SERVICE_URL, client: Optional[IndexifyClient] = None):
88
+ """
89
+ Create a handle to call a RemoteGraph by name.
90
+
91
+ :param name: The name of the graph.
92
+ :param server_url: The URL of the server where the graph will be registered.
93
+ Not used if client is provided.
94
+ :param client: The IndexifyClient used to communicate with the server.
95
+ Prefered over server_url.
96
+ :return: A RemoteGraph object.
97
+ """
98
+ return cls(name=name, server_url=server_url, client=client)
99
+
100
+ def output(
101
+ self,
102
+ invocation_id: str,
103
+ fn_name: str,
104
+ ) -> List[Any]:
105
+ """
106
+ Returns the extracted objects by a graph for an ingested object.
107
+
108
+ - If the extractor name is provided, only the objects extracted by that extractor are returned.
109
+ - If the extractor name is not provided, all the extracted objects are returned for the input object.
110
+
111
+ :param invocation_id (str): The ID of the ingested object
112
+ :param fn_name (Optional[str]): The name of the function whose output is to be returned if provided
113
+ :return (List[Any]): Output of the function.
114
+ """
115
+
116
+ return self._client.graph_outputs(
117
+ graph=self._name,
118
+ invocation_id=invocation_id,
119
+ fn_name=fn_name,
120
+ )
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "indexify"
3
- version = "0.2.18"
3
+ version = "0.2.20"
4
4
  description = "Python Client for Indexify"
5
5
  authors = ["Tensorlake Inc. <support@tensorlake.ai>"]
6
6
  license = "Apache 2.0"
@@ -1,86 +0,0 @@
1
- from typing import Any, List, Optional
2
-
3
- from indexify.functions_sdk.graph import Graph
4
-
5
- from .http_client import IndexifyClient
6
- from .settings import DEFAULT_SERVICE_URL
7
-
8
-
9
- class RemoteGraph:
10
- def __init__(
11
- self,
12
- name: str,
13
- server_url: Optional[str] = DEFAULT_SERVICE_URL,
14
- ):
15
- self._name = name
16
- self._client = IndexifyClient(service_url=server_url)
17
-
18
- def run(self, block_until_done: bool = False, **kwargs) -> str:
19
- """
20
- Run the graph with the given inputs. The input is for the start function of the graph.
21
- :param block_until_done: If True, the function will block until the graph execution is complete.
22
- :param kwargs: The input to the start function of the graph. Pass the input as keyword arguments.
23
- :return: The invocation ID of the graph execution.
24
-
25
- Example:
26
- @indexify_function()
27
- def foo(x: int) -> int:
28
- return x + 1
29
- remote_graph = RemoteGraph.by_name("test")
30
- invocation_id = remote_graph.run(x=1)
31
- """
32
- return self._client.invoke_graph_with_object(
33
- self._name, block_until_done, **kwargs
34
- )
35
-
36
- def rerun(self):
37
- """
38
- Rerun the graph with the given invocation ID.
39
- :param invocation_id: The invocation ID of the graph execution.
40
- """
41
- self._client.rerun_graph(self._name)
42
-
43
- @classmethod
44
- def deploy(
45
- cls,
46
- g: Graph,
47
- additional_modules=[],
48
- server_url: Optional[str] = "http://localhost:8900",
49
- ):
50
- """
51
- Create a new RemoteGraph from a local Graph object.
52
- :param g: The local Graph object.
53
- :param server_url: The URL of the server where the graph will be registered.
54
- """
55
- client = IndexifyClient(service_url=server_url)
56
- client.register_compute_graph(g, additional_modules)
57
- return cls(name=g.name, server_url=server_url)
58
-
59
- @classmethod
60
- def by_name(cls, name: str, server_url: Optional[str] = "http://localhost:8900"):
61
- """
62
- Create a handle to call a RemoteGraph by name.
63
- :param name: The name of the graph.
64
- :param server_url: The URL of the server where the graph is registered.
65
- :return: A RemoteGraph object.
66
- """
67
- return cls(name=name, server_url=server_url)
68
-
69
- def output(
70
- self,
71
- invocation_id: str,
72
- fn_name: str,
73
- ) -> List[Any]:
74
- """
75
- Returns the extracted objects by a graph for an ingested object. If the extractor name is provided, only the objects extracted by that extractor are returned.
76
- If the extractor name is not provided, all the extracted objects are returned for the input object.
77
- invocation_id: str: The ID of the ingested object
78
- fn_name: Optional[str]: The name of the function whose output is to be returned if provided
79
- return: List[Any]: Output of the function.
80
- """
81
-
82
- return self._client.graph_outputs(
83
- graph=self._name,
84
- invocation_id=invocation_id,
85
- fn_name=fn_name,
86
- )
File without changes
File without changes
File without changes
File without changes