mdify-cli 2.11.4__py3-none-any.whl → 2.11.6__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.
mdify/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """mdify - Convert documents to Markdown via Docling container."""
2
2
 
3
- __version__ = "2.11.4"
3
+ __version__ = "2.11.6"
mdify/cli.py CHANGED
@@ -955,7 +955,13 @@ def main() -> int:
955
955
  print(f"Starting docling-serve container...")
956
956
  print()
957
957
 
958
- with DoclingContainer(runtime, image, args.port, timeout=timeout) as container:
958
+ with DoclingContainer(
959
+ runtime,
960
+ image,
961
+ args.port,
962
+ timeout=timeout,
963
+ keep_container=DEBUG,
964
+ ) as container:
959
965
  # Convert files
960
966
  conversion_start = time.time()
961
967
  spinner = Spinner()
@@ -1048,13 +1054,26 @@ def main() -> int:
1048
1054
 
1049
1055
  # Always show logs for connection errors to surface root cause
1050
1056
  print(" Retrieving container logs...", file=sys.stderr)
1051
- logs = container.get_logs(tail=30)
1057
+ logs, log_error = container.get_logs(tail=50)
1052
1058
  if logs:
1053
- print(" Container logs (last 30 lines):", file=sys.stderr)
1059
+ print(" Container logs (last 50 lines):", file=sys.stderr)
1054
1060
  for line in logs.strip().split("\n"):
1055
- print(f" {line}", file=sys.stderr)
1061
+ if line.strip(): # Skip empty lines
1062
+ print(f" {line}", file=sys.stderr)
1063
+ elif log_error:
1064
+ print(f" Error retrieving logs: {log_error}", file=sys.stderr)
1065
+ if not DEBUG:
1066
+ print(
1067
+ " Tip: re-run with MDIFY_DEBUG=1 to preserve container for inspection",
1068
+ file=sys.stderr,
1069
+ )
1056
1070
  else:
1057
- print(" No logs available", file=sys.stderr)
1071
+ print(" No logs available (container may have been removed)", file=sys.stderr)
1072
+ if not DEBUG:
1073
+ print(
1074
+ " Tip: re-run with MDIFY_DEBUG=1 to preserve container logs",
1075
+ file=sys.stderr,
1076
+ )
1058
1077
 
1059
1078
  if not container_alive:
1060
1079
  print(" Stopping remaining conversions", file=sys.stderr)
mdify/container.py CHANGED
@@ -20,7 +20,14 @@ class DoclingContainer:
20
20
  # Container automatically stopped and removed
21
21
  """
22
22
 
23
- def __init__(self, runtime: str, image: str, port: int = 5001, timeout: int = 1200):
23
+ def __init__(
24
+ self,
25
+ runtime: str,
26
+ image: str,
27
+ port: int = 5001,
28
+ timeout: int = 1200,
29
+ keep_container: bool = False,
30
+ ):
24
31
  """Initialize container manager.
25
32
 
26
33
  Args:
@@ -28,11 +35,13 @@ class DoclingContainer:
28
35
  image: Container image to use
29
36
  port: Host port to bind (default: 5001)
30
37
  timeout: Conversion timeout in seconds (default: 1200)
38
+ keep_container: If True, do not auto-remove container (preserve logs)
31
39
  """
32
40
  self.runtime = runtime
33
41
  self.image = image
34
42
  self.port = port
35
43
  self.timeout = timeout
44
+ self.keep_container = keep_container
36
45
  self.container_name = f"mdify-serve-{uuid.uuid4().hex[:8]}"
37
46
  self.container_id: Optional[str] = None
38
47
 
@@ -91,7 +100,6 @@ class DoclingContainer:
91
100
  self.runtime,
92
101
  "run",
93
102
  "-d", # Detached mode
94
- "--rm", # Auto-remove on stop
95
103
  "--name",
96
104
  self.container_name,
97
105
  "-p",
@@ -100,6 +108,8 @@ class DoclingContainer:
100
108
  f"DOCLING_SERVE_MAX_SYNC_WAIT={self.timeout}",
101
109
  self.image,
102
110
  ]
111
+ if not self.keep_container:
112
+ cmd.insert(3, "--rm") # Auto-remove on stop
103
113
 
104
114
  try:
105
115
  result = subprocess.run(cmd, capture_output=True, text=True, check=True)
@@ -125,17 +135,17 @@ class DoclingContainer:
125
135
  check=False,
126
136
  )
127
137
 
128
- def get_logs(self, tail: int = 50) -> str:
138
+ def get_logs(self, tail: int = 50) -> tuple[str, str]:
129
139
  """Get container logs for debugging.
130
140
 
131
141
  Args:
132
142
  tail: Number of lines to retrieve from end of logs
133
143
 
134
144
  Returns:
135
- Container logs as string
145
+ Tuple of (stdout, stderr) from container logs
136
146
  """
137
147
  if not self.container_name:
138
- return ""
148
+ return ("", "No container name set")
139
149
 
140
150
  try:
141
151
  result = subprocess.run(
@@ -144,9 +154,13 @@ class DoclingContainer:
144
154
  text=True,
145
155
  check=False,
146
156
  )
147
- return result.stdout if result.returncode == 0 else ""
148
- except Exception:
149
- return ""
157
+ if result.returncode != 0:
158
+ return ("", f"Failed to get logs (exit {result.returncode}): {result.stderr}")
159
+ # Container logs come from both stdout and stderr
160
+ combined = result.stdout + result.stderr
161
+ return (combined, "")
162
+ except Exception as e:
163
+ return ("", f"Exception getting logs: {e}")
150
164
 
151
165
  def is_running(self) -> bool:
152
166
  """Check if container process is still running.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdify-cli
3
- Version: 2.11.4
3
+ Version: 2.11.6
4
4
  Summary: Convert PDFs and document images into structured Markdown for LLM workflows
5
5
  Author: tiroq
6
6
  License-Expression: MIT
@@ -0,0 +1,12 @@
1
+ assets/mdify.png,sha256=qUj7WXWqNwpI2KNXOW79XJwqFqa-UI0JEkmt1mmy4Rg,1820418
2
+ mdify/__init__.py,sha256=0wE2t03uA9GJS4LLwuLvIGvAiy0KAkUI5uBzNmbwIdU,91
3
+ mdify/__main__.py,sha256=bhpJ00co6MfaVOdH4XLoW04NtLYDa_oJK7ODzfLrn9M,143
4
+ mdify/cli.py,sha256=UxzSHuYQNYKYt-o_-CiMZ0eCovuSLTrjtpaG6Gw0Wzc,37863
5
+ mdify/container.py,sha256=uyruZtNkepjq6KoWYCQM1U6x0Lu2IHffpVRA-D9BlMI,7224
6
+ mdify/docling_client.py,sha256=xuQR6sC1v3EPloOSwExoHCqT4uUxE8myYq-Yeby3C2I,7975
7
+ mdify_cli-2.11.6.dist-info/licenses/LICENSE,sha256=NWM66Uv-XuSMKaU-gaPmvfyk4WgE6zcIPr78wyg6GAo,1065
8
+ mdify_cli-2.11.6.dist-info/METADATA,sha256=lbfKq932Zp5BA0IfQ2pY5kGmdHl4xt-EBBXWuHnZlL0,9623
9
+ mdify_cli-2.11.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ mdify_cli-2.11.6.dist-info/entry_points.txt,sha256=0Xki8f5lADQUtwdt6Eq_FEaieI6Byhk8UE7BuDhChMg,41
11
+ mdify_cli-2.11.6.dist-info/top_level.txt,sha256=qltzf7h8owHq7dxCdfCkSHY8gT21hn1_E8P-VWS_OKM,6
12
+ mdify_cli-2.11.6.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- assets/mdify.png,sha256=qUj7WXWqNwpI2KNXOW79XJwqFqa-UI0JEkmt1mmy4Rg,1820418
2
- mdify/__init__.py,sha256=UnDcze3OmKMoWpn9FyQpxSpGRhBmnmcgyu33vij7Y_0,91
3
- mdify/__main__.py,sha256=bhpJ00co6MfaVOdH4XLoW04NtLYDa_oJK7ODzfLrn9M,143
4
- mdify/cli.py,sha256=wTBs4-xZaRRyr9uyUQNDIPjQD1VTMPL0jU26mCT82Hk,36918
5
- mdify/container.py,sha256=JoN8mUE1hIIVnrxZwdHud70vgNo_1ZIJtmNoPwBWk8I,6647
6
- mdify/docling_client.py,sha256=xuQR6sC1v3EPloOSwExoHCqT4uUxE8myYq-Yeby3C2I,7975
7
- mdify_cli-2.11.4.dist-info/licenses/LICENSE,sha256=NWM66Uv-XuSMKaU-gaPmvfyk4WgE6zcIPr78wyg6GAo,1065
8
- mdify_cli-2.11.4.dist-info/METADATA,sha256=Gajy0D9Ho22mCxNTbWAkc4CdDGACvpmaRij4AVzi_6U,9623
9
- mdify_cli-2.11.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
- mdify_cli-2.11.4.dist-info/entry_points.txt,sha256=0Xki8f5lADQUtwdt6Eq_FEaieI6Byhk8UE7BuDhChMg,41
11
- mdify_cli-2.11.4.dist-info/top_level.txt,sha256=qltzf7h8owHq7dxCdfCkSHY8gT21hn1_E8P-VWS_OKM,6
12
- mdify_cli-2.11.4.dist-info/RECORD,,