indexify 0.2.19__py3-none-any.whl → 0.2.20__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.
@@ -29,10 +29,10 @@ class TaskReporter:
29
29
  def report_task_outcome(self, completed_task: CompletedTask):
30
30
  fn_outputs = []
31
31
  for output in completed_task.outputs or []:
32
- output_bytes = MsgPackSerializer.serialize(output)
33
32
  print(
34
33
  f"[bold]task-reporter[/bold] uploading output of size: {len(output_bytes)} bytes"
35
34
  )
35
+ output_bytes = MsgPackSerializer.serialize(output)
36
36
  fn_outputs.append(
37
37
  ("node_outputs", (nanoid.generate(), io.BytesIO(output_bytes)))
38
38
  )
indexify/remote_graph.py CHANGED
@@ -11,23 +11,41 @@ class RemoteGraph:
11
11
  self,
12
12
  name: str,
13
13
  server_url: Optional[str] = DEFAULT_SERVICE_URL,
14
+ client: Optional[IndexifyClient] = None,
14
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
+ """
15
27
  self._name = name
16
- self._client = IndexifyClient(service_url=server_url)
28
+ if client:
29
+ self._client = client
30
+ else:
31
+ self._client = IndexifyClient(service_url=server_url)
17
32
 
18
33
  def run(self, block_until_done: bool = False, **kwargs) -> str:
19
34
  """
20
35
  Run the graph with the given inputs. The input is for the start function of the graph.
36
+
21
37
  :param block_until_done: If True, the function will block until the graph execution is complete.
22
38
  :param kwargs: The input to the start function of the graph. Pass the input as keyword arguments.
23
39
  :return: The invocation ID of the graph execution.
24
40
 
25
41
  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)
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)
31
49
  """
32
50
  return self._client.invoke_graph_with_object(
33
51
  self._name, block_until_done, **kwargs
@@ -36,6 +54,7 @@ class RemoteGraph:
36
54
  def rerun(self):
37
55
  """
38
56
  Rerun the graph with the given invocation ID.
57
+
39
58
  :param invocation_id: The invocation ID of the graph execution.
40
59
  """
41
60
  self._client.rerun_graph(self._name)
@@ -45,26 +64,38 @@ class RemoteGraph:
45
64
  cls,
46
65
  g: Graph,
47
66
  additional_modules=[],
48
- server_url: Optional[str] = "http://localhost:8900",
67
+ server_url: Optional[str] = DEFAULT_SERVICE_URL,
68
+ client: Optional[IndexifyClient] = None,
49
69
  ):
50
70
  """
51
71
  Create a new RemoteGraph from a local Graph object.
72
+
52
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.
53
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.
54
80
  """
55
- client = IndexifyClient(service_url=server_url)
81
+ if not client:
82
+ client = IndexifyClient(service_url=server_url)
56
83
  client.register_compute_graph(g, additional_modules)
57
- return cls(name=g.name, server_url=server_url)
84
+ return cls(name=g.name, server_url=server_url, client=client)
58
85
 
59
86
  @classmethod
60
- def by_name(cls, name: str, server_url: Optional[str] = "http://localhost:8900"):
87
+ def by_name(cls, name: str, server_url: Optional[str] = DEFAULT_SERVICE_URL, client: Optional[IndexifyClient] = None):
61
88
  """
62
89
  Create a handle to call a RemoteGraph by name.
90
+
63
91
  :param name: The name of the graph.
64
- :param server_url: The URL of the server where the graph is registered.
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.
65
96
  :return: A RemoteGraph object.
66
97
  """
67
- return cls(name=name, server_url=server_url)
98
+ return cls(name=name, server_url=server_url, client=client)
68
99
 
69
100
  def output(
70
101
  self,
@@ -72,11 +103,14 @@ class RemoteGraph:
72
103
  fn_name: str,
73
104
  ) -> List[Any]:
74
105
  """
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.
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.
80
114
  """
81
115
 
82
116
  return self._client.graph_outputs(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: indexify
3
- Version: 0.2.19
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
@@ -11,7 +11,7 @@ indexify/executor/executor_tasks.py,sha256=gAZ2pvza1YwGlaR1o_tJW4SXtdCgK7sLJgp4W
11
11
  indexify/executor/function_worker.py,sha256=pCGn13rg4dEykzmwYNyCTkewrpyQXQR1cH6n2Hx5Lfc,5813
12
12
  indexify/executor/indexify_executor.py,sha256=2Ut_VX-Su_lm4b4aEROyRJ3gXx-uFHA-V7EN0sWiARE,771
13
13
  indexify/executor/runtime_probes.py,sha256=JY0FoxtlQ9sgsE8gBKWM5h3R1TWkYENhNF0HR2KkV4Q,1704
14
- indexify/executor/task_reporter.py,sha256=kbWoqY5IbAUdCzXDkzfuXEUznQN968ABPCYt-zCGJY4,3718
14
+ indexify/executor/task_reporter.py,sha256=OsF-D88BIY3wzhBjZeKl4O5-BH8Hl6C8s1R8i4MHi8I,3719
15
15
  indexify/executor/task_store.py,sha256=q8s2gImsFffWeXQR0mk1Xlo1Aj_2GfclNPjQ2EA_YBo,3984
16
16
  indexify/functions_sdk/data_objects.py,sha256=CQZMzYiV7l6dyzFkYquWQHqdte6JnC7XA3i2ZyvPvgQ,844
17
17
  indexify/functions_sdk/graph.py,sha256=L8jtuSGaUk05JgT_cQX-n_1H9t84lcPa1v4XXlpuJa0,11143
@@ -23,11 +23,11 @@ indexify/functions_sdk/local_cache.py,sha256=cNWF67zbhbTJe3g86hyLBy3Rqzs6dNvp2Sj
23
23
  indexify/functions_sdk/object_serializer.py,sha256=Zz4GobW3ZamBBtFDF76QxU3TP6oJNdWnhsfKd0OUFoc,1660
24
24
  indexify/functions_sdk/pipeline.py,sha256=7hDatRK-SCHYvttf2Vj5YFyiJEVU0OOXEZBOIQenSmk,847
25
25
  indexify/http_client.py,sha256=MflqHbkkzYWw64nnmZCeJE76Q9p-o5hFnlI3h7kbJFI,13729
26
- indexify/remote_graph.py,sha256=ILg6IY6EFgyvnfz1DSzicBZhqvPkg2-UUwgI6lxp6sA,3094
26
+ indexify/remote_graph.py,sha256=NOotayhw_x4-mAw1c3ooNe7gFE_q3QJ9qaO0t0Sb8sE,4397
27
27
  indexify/remote_pipeline.py,sha256=FW7IAv3r24OOpiqlprw3kuFrpdkqi6Ic4_tT26FThjA,761
28
28
  indexify/settings.py,sha256=LSaWZ0ADIVmUv6o6dHWRC3-Ry5uLbCw2sBSg1e_U7UM,99
29
- indexify-0.2.19.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
- indexify-0.2.19.dist-info/METADATA,sha256=TdRtdNYEXcffmOtFnSvN3FDH631dPxUd-ZLJrZWvNOo,6199
31
- indexify-0.2.19.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
- indexify-0.2.19.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
33
- indexify-0.2.19.dist-info/RECORD,,
29
+ indexify-0.2.20.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
30
+ indexify-0.2.20.dist-info/METADATA,sha256=T8Qbsc59Y_uLGCVlRgUw_N-OblvDCM0g7SscDDVZ6jg,6199
31
+ indexify-0.2.20.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
32
+ indexify-0.2.20.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
33
+ indexify-0.2.20.dist-info/RECORD,,