Skip to content

Commit d1a13b1

Browse files
committed
Adapt to path removal from python-client.
The Path is now being passed via environment variables, therefore the python client got adapted for it. This commit removes all references to path in the cli code.
1 parent f645a45 commit d1a13b1

11 files changed

Lines changed: 52 additions & 140 deletions

File tree

.claude/skills/operating-weaviate-cli/SKILL.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,13 @@ See [references/backups.md](references/backups.md).
226226
weaviate-cli create export-collection --export_id my-export --backend s3 --file_format parquet --wait --json
227227
weaviate-cli create export-collection --export_id my-export --backend s3 --include "Movies,Books" --json
228228
weaviate-cli create export-collection --export_id my-export --backend s3 --exclude "TempData" --json
229-
weaviate-cli create export-collection --export_id my-export --backend s3 --bucket my-bucket --path /exports --json
230229
weaviate-cli get export-collection --export_id my-export --backend s3 --json
231230
weaviate-cli cancel export-collection --export_id my-export --backend s3 --json
232231
```
233232

234233
Backends: `filesystem`, `s3`, `gcs`, `azure`. File formats: `parquet`.
235234

236-
Options: `--include`, `--exclude` (mutually exclusive), `--wait`, `--bucket`, `--path`
235+
Options: `--include`, `--exclude` (mutually exclusive), `--wait`
237236

238237
**Prerequisite**: The export backend must be configured on the Weaviate cluster (e.g., `ENABLE_BACKUP=true` for S3 via MinIO in local-k8s).
239238

.claude/skills/operating-weaviate-cli/references/exports.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Export collections from Weaviate to external storage backends in Parquet format.
77
weaviate-cli create export-collection --export_id my-export --backend s3 --file_format parquet --wait --json
88
weaviate-cli create export-collection --export_id my-export --backend s3 --include "Movies,Books" --json
99
weaviate-cli create export-collection --export_id my-export --backend gcs --exclude "TempData" --json
10-
weaviate-cli create export-collection --export_id my-export --backend s3 --bucket my-bucket --path /exports --wait --json
1110
```
1211

1312
## Check Export Status
@@ -33,16 +32,12 @@ Only works while the export is in progress. Returns an error if the export has a
3332
- `--include` -- Comma-separated collections to include
3433
- `--exclude` -- Comma-separated collections to exclude
3534
- `--wait` -- Wait for completion
36-
- `--bucket` -- Bucket name for cloud storage backends
37-
- `--path` -- Path within the storage backend
3835

3936
**Get Status:**
4037
- `--export_id`, `--backend` -- Same as create
41-
- `--bucket`, `--path` -- Optional, for locating the export
4238

4339
**Cancel:**
4440
- `--export_id`, `--backend` -- Same as create
45-
- `--bucket`, `--path` -- Optional, for locating the export
4641

4742
## Prerequisites
4843

@@ -56,4 +51,3 @@ Only works while the export is in progress. Returns an error if the export has a
5651
- Without `--wait`, the command returns immediately with status STARTED
5752
- Poll progress with `get export-collection` to monitor shard-level status
5853
- Export uses the same storage backends as backups (S3, GCS, Azure, filesystem)
59-
- The `--bucket` defaults to the cluster's configured backup bucket if not specified

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
weaviate-client @ git+https://github.com/weaviate/weaviate-python-client.git@export_collection
1+
weaviate-client @ git+https://github.com/weaviate/weaviate-python-client.git@dev/1.37
22
click==8.1.7
33
twine
44
pytest

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ classifiers =
3737
include_package_data = True
3838
python_requires = >=3.9
3939
install_requires =
40-
weaviate-client @ git+https://github.com/weaviate/weaviate-python-client.git@export_collection
40+
weaviate-client @ git+https://github.com/weaviate/weaviate-python-client.git@dev/1.37
4141
click==8.1.7
4242
semver>=3.0.2
4343
numpy>=1.24.0

test/integration/test_export_integration.py

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import click
23
import pytest
34
import weaviate
45
from weaviate_cli.managers.collection_manager import CollectionManager
@@ -57,36 +58,31 @@ def test_create_export_and_get_status(
5758
export_manager: ExportManager, setup_collection, capsys
5859
):
5960
"""Test creating an export and getting its status."""
60-
try:
61-
# Create export with wait
62-
export_manager.create_export(
63-
export_id="integration-test-export",
64-
backend="s3",
65-
file_format="parquet",
66-
include=EXPORT_COLLECTION,
67-
wait=True,
68-
json_output=False,
69-
)
61+
export_manager.create_export(
62+
export_id="integration-test-export",
63+
backend="s3",
64+
file_format="parquet",
65+
include=EXPORT_COLLECTION,
66+
wait=True,
67+
json_output=False,
68+
)
7069

71-
out = capsys.readouterr().out
72-
assert "integration-test-export" in out
73-
assert "created successfully" in out
70+
out = capsys.readouterr().out
71+
assert "integration-test-export" in out
72+
assert "created successfully" in out
7473

75-
# Get status
76-
export_manager.get_export_status(
77-
export_id="integration-test-export",
78-
backend="s3",
79-
json_output=True,
80-
)
74+
export_manager.get_export_status(
75+
export_id="integration-test-export",
76+
backend="s3",
77+
json_output=True,
78+
)
8179

82-
out = capsys.readouterr().out
83-
data = json.loads(out)
84-
assert data["export_id"] == "integration-test-export"
85-
assert data["status"] == "SUCCESS"
86-
assert EXPORT_COLLECTION in data["collections"]
87-
assert "shard_status" in data
88-
except Exception:
89-
raise
80+
out = capsys.readouterr().out
81+
data = json.loads(out)
82+
assert data["export_id"] == "integration-test-export"
83+
assert data["status"] == "SUCCESS"
84+
assert EXPORT_COLLECTION in data["collections"]
85+
assert "shard_status" in data
9086

9187

9288
def test_create_export_json_output(
@@ -131,7 +127,7 @@ def test_create_export_include_and_exclude_raises(
131127
export_manager: ExportManager, setup_collection
132128
):
133129
"""Test that specifying both include and exclude raises an error."""
134-
with pytest.raises(Exception) as exc_info:
130+
with pytest.raises(click.ClickException) as exc_info:
135131
export_manager.create_export(
136132
export_id="should-fail",
137133
backend="s3",
@@ -154,16 +150,19 @@ def test_cancel_export(export_manager: ExportManager, setup_collection, capsys):
154150
)
155151
capsys.readouterr() # Clear output
156152

157-
# Try to cancel — may succeed or fail depending on timing
153+
# Try to cancel — may succeed or fail depending on timing. Only tolerate
154+
# the specific "could not be canceled" path (export already finished);
155+
# anything else is a real failure.
158156
try:
159157
export_manager.cancel_export(
160158
export_id="integration-cancel-export",
161159
backend="s3",
162160
json_output=True,
163161
)
164-
out = capsys.readouterr().out
165-
data = json.loads(out)
166-
assert data["status"] == "success"
167-
except Exception:
168-
# Export may have already finished — that's OK
169-
pass
162+
except click.ClickException as e:
163+
assert "could not be canceled" in str(e)
164+
return
165+
166+
out = capsys.readouterr().out
167+
data = json.loads(out)
168+
assert data["status"] == "success"

test/unittests/test_managers/test_export_manager.py

Lines changed: 13 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
2+
import click
23
import pytest
34
from unittest.mock import MagicMock
4-
from datetime import datetime
55

66
from weaviate_cli.managers.export_manager import ExportManager
77

@@ -55,7 +55,7 @@ def test_create_export_include_and_exclude_raises(
5555
export_manager: ExportManager,
5656
) -> None:
5757
"""create_export raises when both include and exclude are specified."""
58-
with pytest.raises(Exception) as exc_info:
58+
with pytest.raises(click.ClickException) as exc_info:
5959
export_manager.create_export(
6060
export_id="test",
6161
backend="filesystem",
@@ -157,35 +157,19 @@ def test_create_export_passes_none_collections_when_not_specified(
157157
assert call_kwargs["exclude_collections"] is None
158158

159159

160-
def test_create_export_passes_config_with_path(
160+
def test_create_export_no_extra_kwargs(
161161
export_manager: ExportManager, mock_client_with_export: MagicMock
162162
) -> None:
163-
"""create_export passes ExportConfig when path is set."""
164-
export_manager.create_export(
165-
export_id="my-export",
166-
backend="s3",
167-
file_format="parquet",
168-
path="/my/path",
169-
)
170-
171-
call_kwargs = mock_client_with_export.export.create.call_args.kwargs
172-
config = call_kwargs["config"]
173-
assert config is not None
174-
assert config.path == "/my/path"
175-
176-
177-
def test_create_export_no_config_when_path_none(
178-
export_manager: ExportManager, mock_client_with_export: MagicMock
179-
) -> None:
180-
"""create_export passes config=None when path is not set."""
163+
"""create_export does not pass config or path to the client."""
181164
export_manager.create_export(
182165
export_id="my-export",
183166
backend="filesystem",
184167
file_format="parquet",
185168
)
186169

187170
call_kwargs = mock_client_with_export.export.create.call_args.kwargs
188-
assert call_kwargs["config"] is None
171+
assert "config" not in call_kwargs
172+
assert "path" not in call_kwargs
189173

190174

191175
def test_create_export_with_wait(
@@ -240,31 +224,17 @@ def test_get_export_status_json_output(export_manager: ExportManager, capsys) ->
240224
def test_get_export_status_passes_correct_args(
241225
export_manager: ExportManager, mock_client_with_export: MagicMock
242226
) -> None:
243-
"""get_export_status passes correct args to client, wrapping path in ExportConfig."""
227+
"""get_export_status passes only export_id and backend to client."""
244228
export_manager.get_export_status(
245229
export_id="my-export",
246230
backend="s3",
247-
path="/my/path",
248231
)
249232

250233
mock_client_with_export.export.get_status.assert_called_once()
251234
call_kwargs = mock_client_with_export.export.get_status.call_args.kwargs
252235
assert call_kwargs["export_id"] == "my-export"
253-
assert call_kwargs["config"] is not None
254-
assert call_kwargs["config"].path == "/my/path"
255-
256-
257-
def test_get_export_status_no_config_when_path_none(
258-
export_manager: ExportManager, mock_client_with_export: MagicMock
259-
) -> None:
260-
"""get_export_status passes config=None when path is not set."""
261-
export_manager.get_export_status(
262-
export_id="my-export",
263-
backend="filesystem",
264-
)
265-
266-
call_kwargs = mock_client_with_export.export.get_status.call_args.kwargs
267-
assert call_kwargs["config"] is None
236+
assert "config" not in call_kwargs
237+
assert "path" not in call_kwargs
268238

269239

270240
def test_get_export_status_with_shard_status_json(
@@ -352,31 +322,17 @@ def test_cancel_export_success_json_output(
352322
def test_cancel_export_passes_correct_args(
353323
export_manager: ExportManager, mock_client_with_export: MagicMock
354324
) -> None:
355-
"""cancel_export passes correct args to client, wrapping path in ExportConfig."""
325+
"""cancel_export passes only export_id and backend to client."""
356326
export_manager.cancel_export(
357327
export_id="my-export",
358328
backend="gcs",
359-
path="/my/path",
360329
)
361330

362331
mock_client_with_export.export.cancel.assert_called_once()
363332
call_kwargs = mock_client_with_export.export.cancel.call_args.kwargs
364333
assert call_kwargs["export_id"] == "my-export"
365-
assert call_kwargs["config"] is not None
366-
assert call_kwargs["config"].path == "/my/path"
367-
368-
369-
def test_cancel_export_no_config_when_path_none(
370-
export_manager: ExportManager, mock_client_with_export: MagicMock
371-
) -> None:
372-
"""cancel_export passes config=None when path is not set."""
373-
export_manager.cancel_export(
374-
export_id="my-export",
375-
backend="filesystem",
376-
)
377-
378-
call_kwargs = mock_client_with_export.export.cancel.call_args.kwargs
379-
assert call_kwargs["config"] is None
334+
assert "config" not in call_kwargs
335+
assert "path" not in call_kwargs
380336

381337

382338
# ---------------------------------------------------------------------------
@@ -390,7 +346,7 @@ def test_cancel_export_failure_raises(
390346
"""cancel_export when client returns False raises an exception."""
391347
mock_client_with_export.export.cancel.return_value = False
392348

393-
with pytest.raises(Exception) as exc_info:
349+
with pytest.raises(click.ClickException) as exc_info:
394350
export_manager.cancel_export(
395351
export_id="my-export",
396352
backend="filesystem",

weaviate_cli/commands/cancel.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22
import click
33
import sys
4-
from typing import Optional
54
from weaviate_cli.utils import get_client_from_context
65
from weaviate_cli.managers.backup_manager import BackupManager
76
from weaviate_cli.managers.cluster_manager import ClusterManager
@@ -101,11 +100,6 @@ def cancel_replication_cli(ctx: click.Context, op_id: str, json_output: bool) ->
101100
type=click.Choice(["filesystem", "s3", "gcs", "azure"]),
102101
help=f"The backend used for storing the export (default: {CancelExportCollectionDefaults.backend}).",
103102
)
104-
@click.option(
105-
"--path",
106-
default=CancelExportCollectionDefaults.path,
107-
help="Path within the storage backend.",
108-
)
109103
@click.option(
110104
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
111105
)
@@ -114,7 +108,6 @@ def cancel_export_collection_cli(
114108
ctx: click.Context,
115109
export_id: str,
116110
backend: str,
117-
path: Optional[str],
118111
json_output: bool,
119112
) -> None:
120113
"""Cancel a collection export in Weaviate."""
@@ -125,7 +118,6 @@ def cancel_export_collection_cli(
125118
export_manager.cancel_export(
126119
export_id=export_id,
127120
backend=backend,
128-
path=path,
129121
json_output=json_output,
130122
)
131123
except Exception as e:

weaviate_cli/commands/create.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -922,11 +922,6 @@ def create_replication_cli(
922922
is_flag=True,
923923
help="Wait for the export to complete before returning.",
924924
)
925-
@click.option(
926-
"--path",
927-
default=CreateExportCollectionDefaults.path,
928-
help="Path within the storage backend.",
929-
)
930925
@click.option(
931926
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
932927
)
@@ -939,7 +934,6 @@ def create_export_collection_cli(
939934
include: Optional[str],
940935
exclude: Optional[str],
941936
wait: bool,
942-
path: Optional[str],
943937
json_output: bool,
944938
) -> None:
945939
"""Create a collection export in Weaviate."""
@@ -954,7 +948,6 @@ def create_export_collection_cli(
954948
include=include,
955949
exclude=exclude,
956950
wait=wait,
957-
path=path,
958951
json_output=json_output,
959952
)
960953
except Exception as e:

weaviate_cli/commands/get.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,6 @@ def get_replications_cli(ctx: click.Context, json_output: bool) -> None:
581581
type=click.Choice(["filesystem", "s3", "gcs", "azure"]),
582582
help=f"The backend used for storing the export (default: {GetExportCollectionDefaults.backend}).",
583583
)
584-
@click.option(
585-
"--path",
586-
default=GetExportCollectionDefaults.path,
587-
help="Path within the storage backend.",
588-
)
589584
@click.option(
590585
"--json", "json_output", is_flag=True, default=False, help="Output in JSON format."
591586
)
@@ -594,7 +589,6 @@ def get_export_collection_cli(
594589
ctx: click.Context,
595590
export_id: str,
596591
backend: str,
597-
path: Optional[str],
598592
json_output: bool,
599593
) -> None:
600594
"""Get the status of a collection export in Weaviate."""
@@ -605,7 +599,6 @@ def get_export_collection_cli(
605599
export_manager.get_export_status(
606600
export_id=export_id,
607601
backend=backend,
608-
path=path,
609602
json_output=json_output,
610603
)
611604
except Exception as e:

0 commit comments

Comments
 (0)