indexify 0.2.6__py3-none-any.whl → 0.2.7__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 +1 -1
- indexify/executor/function_worker.py +7 -2
- indexify/functions_sdk/graph.py +19 -14
- indexify/functions_sdk/graph_definition.py +5 -0
- indexify/http_client.py +9 -6
- indexify/remote_graph.py +7 -1
- {indexify-0.2.6.dist-info → indexify-0.2.7.dist-info}/METADATA +1 -1
- {indexify-0.2.6.dist-info → indexify-0.2.7.dist-info}/RECORD +11 -11
- {indexify-0.2.6.dist-info → indexify-0.2.7.dist-info}/LICENSE.txt +0 -0
- {indexify-0.2.6.dist-info → indexify-0.2.7.dist-info}/WHEEL +0 -0
- {indexify-0.2.6.dist-info → indexify-0.2.7.dist-info}/entry_points.txt +0 -0
indexify/cli.py
CHANGED
@@ -245,7 +245,7 @@ WORKDIR /app
|
|
245
245
|
console.print(f"{docker_file}", style="magenta")
|
246
246
|
|
247
247
|
client = docker.from_env()
|
248
|
-
image_name =f"{image._image_name}:{image._tag}"
|
248
|
+
image_name = f"{image._image_name}:{image._tag}"
|
249
249
|
client.images.build(
|
250
250
|
fileobj=io.BytesIO(docker_file.encode()),
|
251
251
|
tag=image_name,
|
@@ -21,6 +21,8 @@ import concurrent.futures
|
|
21
21
|
import io
|
22
22
|
from contextlib import redirect_stderr, redirect_stdout
|
23
23
|
|
24
|
+
from .runtime_probes import RuntimeProbes
|
25
|
+
|
24
26
|
|
25
27
|
class FunctionRunException(Exception):
|
26
28
|
def __init__(
|
@@ -51,7 +53,8 @@ def _load_function(
|
|
51
53
|
key = f"{namespace}/{graph_name}/{version}/{fn_name}"
|
52
54
|
if key in function_wrapper_map:
|
53
55
|
return
|
54
|
-
|
56
|
+
image_name = RuntimeProbes().probe().image_name
|
57
|
+
graph = Graph.from_path(code_path, image_name)
|
55
58
|
function_wrapper = graph.get_function(fn_name)
|
56
59
|
function_wrapper_map[key] = function_wrapper
|
57
60
|
graph_key = f"{namespace}/{graph_name}/{version}"
|
@@ -135,7 +138,9 @@ def _run_function(
|
|
135
138
|
fn_output = None
|
136
139
|
has_failed = False
|
137
140
|
exception_msg = None
|
138
|
-
print(
|
141
|
+
print(
|
142
|
+
f"[bold] function_worker: [/bold] invoking function {fn_name} in graph {graph_name}"
|
143
|
+
)
|
139
144
|
with redirect_stdout(stdout_capture), redirect_stderr(stderr_capture):
|
140
145
|
try:
|
141
146
|
key = f"{namespace}/{graph_name}/{version}/{fn_name}"
|
indexify/functions_sdk/graph.py
CHANGED
@@ -132,33 +132,38 @@ class Graph:
|
|
132
132
|
self.add_node(node)
|
133
133
|
self.routers[from_node.name].append(node.name)
|
134
134
|
return self
|
135
|
-
|
136
|
-
|
137
|
-
def _register_cloudpickle(self):
|
135
|
+
|
136
|
+
def serialize(self) -> Dict[str, bytes]:
|
138
137
|
# Get all unique modules from nodes and edges
|
139
|
-
|
138
|
+
modules_by_images = defaultdict(set)
|
140
139
|
for node in self.nodes.values():
|
141
|
-
|
140
|
+
modules_by_images[node.image._image_name].add(node.__module__)
|
141
|
+
|
142
|
+
pickled_nodes_by_image = {}
|
143
|
+
for image_name, modules in modules_by_images.items():
|
144
|
+
for module in modules:
|
145
|
+
print(f"registering module {module} with cloudpickle")
|
146
|
+
cloudpickle.register_pickle_by_value(sys.modules[module])
|
147
|
+
pickled_nodes_by_image[image_name] = cloudpickle.dumps(self)
|
148
|
+
for module in modules:
|
149
|
+
cloudpickle.unregister_pickle_by_value(sys.modules[module])
|
142
150
|
|
143
151
|
# Register each module with cloudpickle
|
144
152
|
for module_name in modules:
|
145
153
|
module = sys.modules[module_name]
|
146
154
|
print(f"registering module {module_name} with cloudpickle")
|
147
155
|
cloudpickle.register_pickle_by_value(module)
|
148
|
-
|
149
|
-
|
150
|
-
def serialize(self):
|
151
|
-
self._register_cloudpickle()
|
152
|
-
return cloudpickle.dumps(self)
|
156
|
+
return pickled_nodes_by_image
|
153
157
|
|
154
158
|
@staticmethod
|
155
|
-
def deserialize(
|
156
|
-
return cloudpickle.loads(
|
159
|
+
def deserialize(serialized_code_by_images: Dict[str, bytes], image: str) -> "Graph":
|
160
|
+
return cloudpickle.loads(serialized_code_by_images[image])
|
157
161
|
|
158
162
|
@staticmethod
|
159
|
-
def from_path(path: str) -> "Graph":
|
163
|
+
def from_path(path: str, image: str) -> "Graph":
|
160
164
|
with open(path, "rb") as f:
|
161
|
-
|
165
|
+
pickled_code_by_images: Dict[str, bytes] = cloudpickle.load(f)
|
166
|
+
return Graph.deserialize(pickled_code_by_images, image)
|
162
167
|
|
163
168
|
def add_edge(
|
164
169
|
self,
|
@@ -27,6 +27,11 @@ class NodeMetadata(BaseModel):
|
|
27
27
|
dynamic_router: Optional[RouterMetadata] = None
|
28
28
|
compute_fn: Optional[FunctionMetadata] = None
|
29
29
|
|
30
|
+
def image_name(self):
|
31
|
+
if self.dynamic_router:
|
32
|
+
return self.dynamic_router.image_name
|
33
|
+
return self.compute_fn.image_name
|
34
|
+
|
30
35
|
|
31
36
|
# RuntimeInformation is a class that holds data about the environment in which the graph should run.
|
32
37
|
class RuntimeInformation(BaseModel):
|
indexify/http_client.py
CHANGED
@@ -99,7 +99,7 @@ class IndexifyClient:
|
|
99
99
|
service_url: str = DEFAULT_SERVICE_URL_HTTPS,
|
100
100
|
*args,
|
101
101
|
**kwargs,
|
102
|
-
) -> "
|
102
|
+
) -> "IndexifyClient":
|
103
103
|
"""
|
104
104
|
Create a client with mutual TLS authentication. Also enables HTTP/2,
|
105
105
|
which is required for mTLS.
|
@@ -127,7 +127,7 @@ class IndexifyClient:
|
|
127
127
|
|
128
128
|
client_certs = (cert_path, key_path)
|
129
129
|
verify_option = ca_bundle_path if ca_bundle_path else True
|
130
|
-
client =
|
130
|
+
client = IndexifyClient(
|
131
131
|
*args,
|
132
132
|
**kwargs,
|
133
133
|
service_url=service_url,
|
@@ -160,7 +160,7 @@ class IndexifyClient:
|
|
160
160
|
|
161
161
|
def register_compute_graph(self, graph: Graph):
|
162
162
|
graph_metadata = graph.definition()
|
163
|
-
serialized_code = graph.serialize()
|
163
|
+
serialized_code = cloudpickle.dumps(graph.serialize())
|
164
164
|
response = self._post(
|
165
165
|
f"namespaces/{self.namespace}/compute_graphs",
|
166
166
|
files={"code": serialized_code},
|
@@ -177,11 +177,14 @@ class IndexifyClient:
|
|
177
177
|
response = self._get(f"namespaces/{self.namespace}/compute_graphs/{name}")
|
178
178
|
return ComputeGraphMetadata(**response.json())
|
179
179
|
|
180
|
-
def load_graph(self, name: str) -> Graph:
|
180
|
+
def load_graph(self, name: str, fn_name: str) -> Graph:
|
181
181
|
response = self._get(
|
182
182
|
f"internal/namespaces/{self.namespace}/compute_graphs/{name}/code"
|
183
183
|
)
|
184
|
-
|
184
|
+
cg_metadata: ComputeGraphMetadata = self.graph(name)
|
185
|
+
fn_metadata = cg_metadata.nodes[fn_name]
|
186
|
+
pickled_bytes_by_image = cloudpickle.loads(response.content)
|
187
|
+
return Graph.deserialize(pickled_bytes_by_image, fn_metadata.image_name())
|
185
188
|
|
186
189
|
def namespaces(self) -> List[str]:
|
187
190
|
response = self._get(f"namespaces")
|
@@ -287,7 +290,7 @@ class IndexifyClient:
|
|
287
290
|
return: Union[Dict[str, List[Any]], List[Any]]: The extracted objects. If the extractor name is provided, the output is a list of extracted objects by the extractor. If the extractor name is not provided, the output is a dictionary with the extractor name as the key and the extracted objects as the value. If no objects are found, an empty list is returned.
|
288
291
|
"""
|
289
292
|
if graph not in self._graphs:
|
290
|
-
self._graphs[graph] = self.load_graph(graph)
|
293
|
+
self._graphs[graph] = self.load_graph(graph, fn_name)
|
291
294
|
response = self._get(
|
292
295
|
f"namespaces/{self.namespace}/compute_graphs/{graph}/invocations/{invocation_id}/outputs",
|
293
296
|
)
|
indexify/remote_graph.py
CHANGED
@@ -34,13 +34,19 @@ class RemoteGraph:
|
|
34
34
|
)
|
35
35
|
|
36
36
|
@classmethod
|
37
|
-
def deploy(
|
37
|
+
def deploy(
|
38
|
+
cls,
|
39
|
+
g: Graph,
|
40
|
+
additional_modules=[],
|
41
|
+
server_url: Optional[str] = "http://localhost:8900",
|
42
|
+
):
|
38
43
|
"""
|
39
44
|
Create a new RemoteGraph from a local Graph object.
|
40
45
|
:param g: The local Graph object.
|
41
46
|
:param server_url: The URL of the server where the graph will be registered.
|
42
47
|
"""
|
43
48
|
import cloudpickle
|
49
|
+
|
44
50
|
for module in additional_modules:
|
45
51
|
cloudpickle.register_pickle_by_value(module)
|
46
52
|
client = IndexifyClient(service_url=server_url)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
indexify/__init__.py,sha256=qgMBKVrM_tI-tFeWpE8ktlC5rcExk05nbWyFqxxqeEU,496
|
2
|
-
indexify/cli.py,sha256=
|
2
|
+
indexify/cli.py,sha256=Hj-FvDzrRhgVuX1X3ReSp6QW4lurRUGHKhU9G7y7tDU,7581
|
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=
|
11
|
+
indexify/executor/function_worker.py,sha256=qUsaZNDRcI0PxOBosL1A7x7YPdaJp_gyq3p7eTottJM,5627
|
12
12
|
indexify/executor/indexify_executor.py,sha256=2Ut_VX-Su_lm4b4aEROyRJ3gXx-uFHA-V7EN0sWiARE,771
|
13
13
|
indexify/executor/runtime_probes.py,sha256=tvi8KCaQTVJqcyBJ4-jzEUAnQ01ZbMmjCxV2KJ96_PI,1449
|
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=2LqAWJ_S2Xkp4OQTmhd3InVIrBs7juV41udnSQFMMfM,840
|
17
|
-
indexify/functions_sdk/graph.py,sha256=
|
18
|
-
indexify/functions_sdk/graph_definition.py,sha256=
|
17
|
+
indexify/functions_sdk/graph.py,sha256=OtXZhYuPoP3KMkQLRHgr4Dx_Kj9YNAjGQxx7a_fMRSo,15945
|
18
|
+
indexify/functions_sdk/graph_definition.py,sha256=ziiXrWXcu5x1zEfLErZyiedK75ufiSWxJBhaeV18ikQ,1329
|
19
19
|
indexify/functions_sdk/graph_validation.py,sha256=XLHiC9PAtZungJLysU3hIUOPNDkO5TXUDZ_jiZ0H4hg,2508
|
20
20
|
indexify/functions_sdk/image.py,sha256=l9DghfPTV1p0nlc1Fm1ZuJe21InJeBHUTULswmLmmx8,727
|
21
21
|
indexify/functions_sdk/indexify_functions.py,sha256=xxgvnw0MQ_csIksunIdero8be0PR4mfwgoHp3UlkMZU,5851
|
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=
|
25
|
-
indexify/remote_graph.py,sha256=
|
24
|
+
indexify/http_client.py,sha256=pe_xE0oTodlEet6XTdl434wvrWN8CWHKyv1pOxOF6Qw,12418
|
25
|
+
indexify/remote_graph.py,sha256=gyrbgrAFxb6XSmAlPYa59TuSDa2VPscuWT6qQ4VnIWA,2988
|
26
26
|
indexify/settings.py,sha256=LSaWZ0ADIVmUv6o6dHWRC3-Ry5uLbCw2sBSg1e_U7UM,99
|
27
|
-
indexify-0.2.
|
28
|
-
indexify-0.2.
|
29
|
-
indexify-0.2.
|
30
|
-
indexify-0.2.
|
31
|
-
indexify-0.2.
|
27
|
+
indexify-0.2.7.dist-info/LICENSE.txt,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
28
|
+
indexify-0.2.7.dist-info/METADATA,sha256=TxMLI-S5x3018FNbhGZBUlPRQ3V2fLEroxrbzuxfkxg,6129
|
29
|
+
indexify-0.2.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
30
|
+
indexify-0.2.7.dist-info/entry_points.txt,sha256=Pih7WV-XMpAzI5dEvROcpLr-ybVhd9Y-AtuzBKUdcDs,49
|
31
|
+
indexify-0.2.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|