indexify 0.3.2__py3-none-any.whl → 0.3.3__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/cli.py CHANGED
@@ -6,6 +6,8 @@ from indexify.utils.logging import (
6
6
 
7
7
  configure_logging_early()
8
8
 
9
+ import importlib.metadata
10
+ import json
9
11
  import os
10
12
  import shutil
11
13
  import signal
@@ -17,6 +19,7 @@ from importlib.metadata import version
17
19
  from pathlib import Path
18
20
  from typing import Annotated, List, Optional, Tuple
19
21
 
22
+ import docker
20
23
  import nanoid
21
24
  import structlog
22
25
  import typer
@@ -294,7 +297,57 @@ def _create_image(image: Image, python_sdk_path):
294
297
 
295
298
 
296
299
  def _build_image(image: Image, python_sdk_path: Optional[str] = None):
297
- built_image, output = image.build(python_sdk_path=python_sdk_path)
298
- for line in output:
299
- print(line)
300
- print(f"built image: {built_image.tags[0]}")
300
+ docker_file = _generate_dockerfile(image, python_sdk_path=python_sdk_path)
301
+ image_name = f"{image._image_name}:{image._tag}"
302
+
303
+ # low_level_client = docker.APIClient(base_url=docker_client.api.base_url)
304
+ docker_host = os.getenv("DOCKER_HOST", "unix:///var/run/docker.sock")
305
+ low_level_client = docker.APIClient(base_url=docker_host)
306
+ docker.api.build.process_dockerfile = lambda dockerfile, path: (
307
+ "Dockerfile",
308
+ dockerfile,
309
+ )
310
+ generator = low_level_client.build(
311
+ dockerfile=docker_file,
312
+ rm=True,
313
+ path=".",
314
+ tag=image_name,
315
+ )
316
+
317
+ for output in generator:
318
+ for line in output.decode().splitlines():
319
+ json_line = json.loads(line)
320
+ if "stream" in json_line:
321
+ print(json_line["stream"], end="")
322
+
323
+ elif "errorDetail" in json_line:
324
+ print(json_line["errorDetail"]["message"])
325
+
326
+
327
+ def _generate_dockerfile(image, python_sdk_path: Optional[str] = None):
328
+ docker_contents = [
329
+ f"FROM {image._base_image}",
330
+ "RUN mkdir -p ~/.indexify",
331
+ f"RUN echo {image._image_name} > ~/.indexify/image_name", # TODO: Do we still use this in executors?
332
+ f"RUN echo {image.hash()} > ~/.indexify/image_hash", # TODO: Do we still use this in executors?
333
+ "WORKDIR /app",
334
+ ]
335
+
336
+ for build_op in image._build_ops:
337
+ docker_contents.append(build_op.render())
338
+
339
+ if python_sdk_path is not None:
340
+ print(f"Building image {image._image_name} with local version of the SDK")
341
+
342
+ if not os.path.exists(python_sdk_path):
343
+ print(f"error: {python_sdk_path} does not exist")
344
+ os.exit(1)
345
+ docker_contents.append(f"COPY {python_sdk_path} /app/python-sdk")
346
+ docker_contents.append("RUN (cd /app/python-sdk && pip install .)")
347
+ else:
348
+ docker_contents.append(
349
+ f"RUN pip install indexify=={importlib.metadata.version('indexify')}"
350
+ )
351
+
352
+ docker_file = "\n".join(docker_contents)
353
+ return docker_file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: indexify
3
- Version: 0.3.2
3
+ Version: 0.3.3
4
4
  Summary: Open Source Indexify components and helper tools
5
5
  Home-page: https://github.com/tensorlakeai/indexify
6
6
  License: Apache 2.0
@@ -1,4 +1,4 @@
1
- indexify/cli/cli.py,sha256=3HU3fz4mcE-yuKij3rRb7gS99SVaMzVN8Z-9Y4UpqT8,9510
1
+ indexify/cli/cli.py,sha256=y6JNaMd5by7_v3jE1iah1krlvfzbN4r5A2WkgGTy1Ts,11427
2
2
  indexify/executor/README.md,sha256=ozC6_hMkhQQNVCMEpBxwiUALz6lwErPQxNxQfQDqnG4,2029
3
3
  indexify/executor/api_objects.py,sha256=k5tKYxaWml0sSECoEDzamCYeJnlD7zO2M7E_qGwyMrg,1032
4
4
  indexify/executor/downloader.py,sha256=Vrq1dAW4BifG62tlqFnImiMxdezIgOZcByTRnhDsnnw,6457
@@ -38,7 +38,7 @@ indexify/function_executor/service.py,sha256=i3bI7RSKSr3cDiNFoZdl4TSY_SMKlXBXPdE
38
38
  indexify/utils/README.md,sha256=2g8-H9GopacOW4YrViZc0QsaJPtK-Fox7GyfX01kcDk,86
39
39
  indexify/utils/http_client.py,sha256=deMlmAu4E_ZXV3blCdWNag3uO_cyD-GsMZjFFmO5r7s,3541
40
40
  indexify/utils/logging.py,sha256=c6NwzY7uVHMRJc8f2w2KF36rNkeZVoQfGdq7suIg9s8,2025
41
- indexify-0.3.2.dist-info/METADATA,sha256=YqG6aAKrJhBV7YQal0ojM9HnpdvuIb0aGbHTTOjePS4,1383
42
- indexify-0.3.2.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
43
- indexify-0.3.2.dist-info/entry_points.txt,sha256=pJG0YRnypesbiNJHuObfHEkjk0p_ZvEDTyyTH0kGVTY,108
44
- indexify-0.3.2.dist-info/RECORD,,
41
+ indexify-0.3.3.dist-info/METADATA,sha256=VLMu3g8ZamLGLCjjqwPrBxqg8ZStvSZooP9ITl-BbHw,1383
42
+ indexify-0.3.3.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
43
+ indexify-0.3.3.dist-info/entry_points.txt,sha256=pJG0YRnypesbiNJHuObfHEkjk0p_ZvEDTyyTH0kGVTY,108
44
+ indexify-0.3.3.dist-info/RECORD,,