Skip to content

Commit f15f3c7

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 f15f3c7

8 files changed

Lines changed: 12 additions & 92 deletions

File tree

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/unittests/test_managers/test_export_manager.py

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -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
# ---------------------------------------------------------------------------

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:

weaviate_cli/defaults.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,15 @@ class CreateExportCollectionDefaults:
321321
include: Optional[str] = None
322322
exclude: Optional[str] = None
323323
wait: bool = False
324-
path: Optional[str] = None
325324

326325

327326
@dataclass
328327
class GetExportCollectionDefaults:
329328
export_id: str = "test-export"
330329
backend: str = "filesystem"
331-
path: Optional[str] = None
332330

333331

334332
@dataclass
335333
class CancelExportCollectionDefaults:
336334
export_id: str = "test-export"
337335
backend: str = "filesystem"
338-
path: Optional[str] = None

weaviate_cli/managers/export_manager.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import Optional
44
from weaviate.client import WeaviateClient
55
from weaviate.export.export import (
6-
ExportConfig,
76
ExportFileFormat,
87
ExportStorage,
98
ExportStatusReturn,
@@ -39,7 +38,6 @@ def create_export(
3938
include: Optional[str] = CreateExportCollectionDefaults.include,
4039
exclude: Optional[str] = CreateExportCollectionDefaults.exclude,
4140
wait: bool = CreateExportCollectionDefaults.wait,
42-
path: Optional[str] = CreateExportCollectionDefaults.path,
4341
json_output: bool = False,
4442
) -> None:
4543
if include and exclude:
@@ -50,8 +48,6 @@ def create_export(
5048
backend_enum = BACKEND_MAP[backend]
5149
file_format_enum = FILE_FORMAT_MAP[file_format]
5250

53-
config = ExportConfig(path=path) if path else None
54-
5551
include_collections = (
5652
[c.strip() for c in include.split(",") if c.strip()] if include else None
5753
)
@@ -66,7 +62,6 @@ def create_export(
6662
include_collections=include_collections,
6763
exclude_collections=exclude_collections,
6864
wait_for_completion=wait,
69-
config=config,
7065
)
7166

7267
if json_output:
@@ -92,16 +87,13 @@ def get_export_status(
9287
self,
9388
export_id: str = GetExportCollectionDefaults.export_id,
9489
backend: str = GetExportCollectionDefaults.backend,
95-
path: Optional[str] = GetExportCollectionDefaults.path,
9690
json_output: bool = False,
9791
) -> None:
9892
backend_enum = BACKEND_MAP[backend]
9993

100-
config = ExportConfig(path=path) if path else None
10194
result = self.client.export.get_status(
10295
export_id=export_id,
10396
backend=backend_enum,
104-
config=config,
10597
)
10698

10799
self._print_export_status(result, json_output=json_output)
@@ -110,16 +102,13 @@ def cancel_export(
110102
self,
111103
export_id: str = CancelExportCollectionDefaults.export_id,
112104
backend: str = CancelExportCollectionDefaults.backend,
113-
path: Optional[str] = CancelExportCollectionDefaults.path,
114105
json_output: bool = False,
115106
) -> None:
116107
backend_enum = BACKEND_MAP[backend]
117108

118-
config = ExportConfig(path=path) if path else None
119109
success = self.client.export.cancel(
120110
export_id=export_id,
121111
backend=backend_enum,
122-
config=config,
123112
)
124113

125114
if success:

0 commit comments

Comments
 (0)