Skip to content

Commit 2673363

Browse files
committed
Respond to review
1 parent ba2dc13 commit 2673363

14 files changed

Lines changed: 160 additions & 160 deletions

File tree

.github/workflows/main.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,10 @@ jobs:
164164
WCS_DUMMY_CI_PW: ${{ secrets.WCS_DUMMY_CI_PW }}
165165
OKTA_DUMMY_CI_PW: ${{ secrets.OKTA_DUMMY_CI_PW }}
166166
# OPENAI_APIKEY: ${{ secrets.OPENAI_APIKEY }} disabled until we have a working key
167-
run: |
168-
pytest -n auto -m "not serial" --dist loadgroup -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
169-
pytest -n0 -m "serial" -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
167+
run: pytest -n auto --dist loadgroup -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
170168
- name: Run integration tests without auth secrets (for forks)
171169
if: ${{ github.event.pull_request.head.repo.fork }}
172-
run: |
173-
pytest -n auto -m "not serial" --dist loadgroup -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
174-
pytest -n0 -m "serial" -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
170+
run: pytest -n auto --dist loadgroup -v --cov --cov-report=term-missing --cov=weaviate --cov-report xml:coverage-integration.xml integration
175171
- name: Archive code coverage results
176172
if: matrix.versions.py == '3.10' && (github.ref_name != 'main')
177173
uses: actions/upload-artifact@v4

integration/test_backup_v4.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import weaviate
99
import weaviate.classes as wvc
10-
from weaviate.backup.executor import (
10+
from weaviate.backup.backup import (
1111
BackupCompressionLevel,
1212
BackupConfigCreate,
1313
BackupConfigRestore,
@@ -117,7 +117,6 @@ def _create_backup_id() -> str:
117117
return str(round(time.time_ns() * 1000))
118118

119119

120-
@pytest.mark.serial
121120
def test_create_and_restore_backup_with_waiting(client: weaviate.WeaviateClient) -> None:
122121
"""Create and restore backup with waiting."""
123122
backup_id = _create_backup_id()
@@ -156,7 +155,6 @@ def test_create_and_restore_backup_with_waiting(client: weaviate.WeaviateClient)
156155
assert restore_status.status == BackupStatus.SUCCESS
157156

158157

159-
@pytest.mark.serial
160158
@pytest.mark.parametrize("include", [["Article"], "Article"])
161159
def test_create_and_restore_backup_without_waiting(
162160
client: weaviate.WeaviateClient, include: Union[str, List[str]]
@@ -212,7 +210,6 @@ def test_create_and_restore_backup_without_waiting(
212210
assert len(client.collections.use("Article")) == len(ARTICLES_IDS)
213211

214212

215-
@pytest.mark.serial
216213
def test_create_and_restore_1_of_2_classes(client: weaviate.WeaviateClient) -> None:
217214
"""Create and restore 1 of 2 classes."""
218215
backup_id = _create_backup_id()
@@ -248,7 +245,6 @@ def test_create_and_restore_1_of_2_classes(client: weaviate.WeaviateClient) -> N
248245
assert restore_status.status == BackupStatus.SUCCESS
249246

250247

251-
@pytest.mark.serial
252248
def test_fail_on_non_existing_class(client: weaviate.WeaviateClient) -> None:
253249
"""Fail backup functions on non-existing class"""
254250
backup_id = _create_backup_id()
@@ -260,7 +256,6 @@ def test_fail_on_non_existing_class(client: weaviate.WeaviateClient) -> None:
260256
assert "422" in str(excinfo.value)
261257

262258

263-
@pytest.mark.serial
264259
def test_fail_restoring_backup_for_existing_class(client: weaviate.WeaviateClient) -> None:
265260
"""Fail restoring backup for existing class."""
266261
backup_id = _create_backup_id()
@@ -285,7 +280,6 @@ def test_fail_restoring_backup_for_existing_class(client: weaviate.WeaviateClien
285280
assert "already exists" in str(excinfo.value)
286281

287282

288-
@pytest.mark.serial
289283
def test_fail_creating_existing_backup(client: weaviate.WeaviateClient) -> None:
290284
"""Fail creating existing backup."""
291285
backup_id = _create_backup_id()
@@ -310,7 +304,6 @@ def test_fail_creating_existing_backup(client: weaviate.WeaviateClient) -> None:
310304
assert "422" in str(excinfo.value)
311305

312306

313-
@pytest.mark.serial
314307
def test_fail_restoring_non_existing_backup(client: weaviate.WeaviateClient) -> None:
315308
"""Fail restoring non-existing backup."""
316309
backup_id = _create_backup_id()
@@ -320,7 +313,6 @@ def test_fail_restoring_non_existing_backup(client: weaviate.WeaviateClient) ->
320313
assert "404" in str(excinfo.value)
321314

322315

323-
@pytest.mark.serial
324316
def test_fail_checking_status_for_non_existing_restore(client: weaviate.WeaviateClient) -> None:
325317
"""Fail checking restore status for non-existing restore."""
326318
backup_id = _create_backup_id()
@@ -334,7 +326,6 @@ def test_fail_checking_status_for_non_existing_restore(client: weaviate.Weaviate
334326
assert "404" in str(excinfo)
335327

336328

337-
@pytest.mark.serial
338329
def test_fail_creating_backup_for_both_include_and_exclude_classes(
339330
client: weaviate.WeaviateClient,
340331
) -> None:
@@ -357,7 +348,6 @@ def test_fail_creating_backup_for_both_include_and_exclude_classes(
357348
)
358349

359350

360-
@pytest.mark.serial
361351
@pytest.mark.parametrize("dynamic_backup_location", [False, True])
362352
def test_backup_and_restore_with_collection(
363353
client: weaviate.WeaviateClient, dynamic_backup_location: bool, tmp_path: pathlib.Path
@@ -414,7 +404,6 @@ def test_backup_and_restore_with_collection(
414404
assert restore_status.status == BackupStatus.SUCCESS
415405

416406

417-
@pytest.mark.serial
418407
def test_backup_and_restore_with_collection_and_config_1_24_x(
419408
client: weaviate.WeaviateClient,
420409
) -> None:
@@ -462,7 +451,6 @@ def test_backup_and_restore_with_collection_and_config_1_24_x(
462451
assert restore_status.status == BackupStatus.SUCCESS
463452

464453

465-
@pytest.mark.serial
466454
def test_backup_and_restore_with_collection_and_config_1_23_x(
467455
client: weaviate.WeaviateClient,
468456
) -> None:
@@ -508,7 +496,6 @@ def test_backup_and_restore_with_collection_and_config_1_23_x(
508496
# assert backup_id in [b.backup_id for b in backups]
509497

510498

511-
@pytest.mark.serial
512499
@pytest.mark.parametrize("dynamic_backup_location", [False, True])
513500
def test_cancel_backup(
514501
client: weaviate.WeaviateClient, dynamic_backup_location, tmp_path: pathlib.Path

integration/test_collection_get.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from integration.conftest import CollectionFactoryGet, CollectionFactory
1010
from weaviate.collections import Collection
11+
from weaviate.collections.data.sync import _DataCollection
1112
from weaviate.exceptions import InvalidDataModelException
1213

1314

@@ -26,16 +27,16 @@ class Right(TypedDict):
2627
assert isinstance(col, Collection)
2728

2829

29-
# def test_data_with_data_model_with_dict_generic(
30-
# collection_factory_get: CollectionFactoryGet, request: SubRequest
31-
# ) -> None:
32-
# class Right(TypedDict):
33-
# name: str
30+
def test_data_with_data_model_with_dict_generic(
31+
collection_factory_get: CollectionFactoryGet, request: SubRequest
32+
) -> None:
33+
class Right(TypedDict):
34+
name: str
3435

35-
# col = collection_factory_get(request.node.name)
36-
# assert isinstance(col, Collection)
37-
# data = col.data.with_data_model(Right)
38-
# assert isinstance(data, _DataCollection)
36+
col = collection_factory_get(request.node.name)
37+
assert isinstance(col, Collection)
38+
data = col.data.with_data_model(Right)
39+
assert isinstance(data, _DataCollection)
3940

4041

4142
WRONG_PROPERTIES_ERROR_MSG = "properties can only be a dict type, e.g. Dict[str, Any], or a class that inherits from TypedDict"

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
addopts = -m 'not profiling' --benchmark-skip -l
33
markers =
44
profiling: marks tests that can be profiled
5-
serial: marks tests that should be run serially
65
asyncio_default_fixture_loop_scope = function

weaviate/backup/backup.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
from enum import Enum
2+
from typing import Any, Dict, List, Optional, cast
3+
from pydantic import BaseModel, Field
4+
from weaviate.backup.backup_location import _BackupLocationConfig
5+
6+
STORAGE_NAMES = {
7+
"filesystem",
8+
"s3",
9+
"gcs",
10+
"azure",
11+
}
12+
13+
14+
class BackupCompressionLevel(str, Enum):
15+
"""Which compression level should be used to compress the backup."""
16+
17+
DEFAULT = "DefaultCompression"
18+
BEST_SPEED = "BestSpeed"
19+
BEST_COMPRESSION = "BestCompression"
20+
21+
22+
class BackupStorage(str, Enum):
23+
"""Which backend should be used to write the backup to."""
24+
25+
FILESYSTEM = "filesystem"
26+
S3 = "s3"
27+
GCS = "gcs"
28+
AZURE = "azure"
29+
30+
31+
class BackupStatus(str, Enum):
32+
"""The status of a backup."""
33+
34+
STARTED = "STARTED"
35+
TRANSFERRING = "TRANSFERRING"
36+
TRANSFERRED = "TRANSFERRED"
37+
SUCCESS = "SUCCESS"
38+
FAILED = "FAILED"
39+
CANCELED = "CANCELED"
40+
41+
42+
class _BackupConfigBase(BaseModel):
43+
CPUPercentage: Optional[int] = Field(default=None, alias="cpu_percentage")
44+
45+
def _to_dict(self) -> Dict[str, Any]:
46+
ret = cast(dict, self.model_dump(exclude_none=True))
47+
48+
for key, val in ret.items():
49+
if isinstance(val, _BackupLocationConfig):
50+
ret[key] = val._to_dict()
51+
52+
return ret
53+
54+
55+
class BackupConfigCreate(_BackupConfigBase):
56+
"""Options to configure the backup when creating a backup."""
57+
58+
ChunkSize: Optional[int] = Field(default=None, alias="chunk_size")
59+
CompressionLevel: Optional[BackupCompressionLevel] = Field(
60+
default=None, alias="compression_level"
61+
)
62+
63+
64+
class BackupConfigRestore(_BackupConfigBase):
65+
"""Options to configure the backup when restoring a backup."""
66+
67+
68+
class BackupStatusReturn(BaseModel):
69+
"""Return type of the backup status methods."""
70+
71+
error: Optional[str] = Field(default=None)
72+
status: BackupStatus
73+
path: str
74+
backup_id: str = Field(alias="id")
75+
76+
77+
class BackupReturn(BackupStatusReturn):
78+
"""Return type of the backup creation and restore methods."""
79+
80+
collections: List[str] = Field(default_factory=list, alias="classes")

weaviate/backup/executor.py

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@
44

55
import asyncio
66
import time
7-
from enum import Enum
8-
from typing import Generic, Optional, Union, List, Tuple, Dict, Any, cast
7+
from typing import Generic, Optional, Union, List, Tuple, Dict
98

109
from httpx import Response
11-
from pydantic import BaseModel, Field
1210

13-
from weaviate.backup.backup_location import _BackupLocationConfig, BackupLocationType
11+
from weaviate.backup.backup import (
12+
BackupStorage,
13+
BackupReturn,
14+
BackupStatusReturn,
15+
STORAGE_NAMES,
16+
BackupConfigCreate,
17+
BackupStatus,
18+
BackupConfigRestore,
19+
)
20+
from weaviate.backup.backup_location import BackupLocationType
1421
from weaviate.connect import executor
1522
from weaviate.connect.v4 import _ExpectedStatusCodes, Connection, ConnectionAsync, ConnectionType
1623
from weaviate.exceptions import (
@@ -25,82 +32,6 @@
2532
_decode_json_response_dict,
2633
)
2734

28-
STORAGE_NAMES = {
29-
"filesystem",
30-
"s3",
31-
"gcs",
32-
"azure",
33-
}
34-
35-
36-
class BackupCompressionLevel(str, Enum):
37-
"""Which compression level should be used to compress the backup."""
38-
39-
DEFAULT = "DefaultCompression"
40-
BEST_SPEED = "BestSpeed"
41-
BEST_COMPRESSION = "BestCompression"
42-
43-
44-
class BackupStorage(str, Enum):
45-
"""Which backend should be used to write the backup to."""
46-
47-
FILESYSTEM = "filesystem"
48-
S3 = "s3"
49-
GCS = "gcs"
50-
AZURE = "azure"
51-
52-
53-
class BackupStatus(str, Enum):
54-
"""The status of a backup."""
55-
56-
STARTED = "STARTED"
57-
TRANSFERRING = "TRANSFERRING"
58-
TRANSFERRED = "TRANSFERRED"
59-
SUCCESS = "SUCCESS"
60-
FAILED = "FAILED"
61-
CANCELED = "CANCELED"
62-
63-
64-
class _BackupConfigBase(BaseModel):
65-
CPUPercentage: Optional[int] = Field(default=None, alias="cpu_percentage")
66-
67-
def _to_dict(self) -> Dict[str, Any]:
68-
ret = cast(dict, self.model_dump(exclude_none=True))
69-
70-
for key, val in ret.items():
71-
if isinstance(val, _BackupLocationConfig):
72-
ret[key] = val._to_dict()
73-
74-
return ret
75-
76-
77-
class BackupConfigCreate(_BackupConfigBase):
78-
"""Options to configure the backup when creating a backup."""
79-
80-
ChunkSize: Optional[int] = Field(default=None, alias="chunk_size")
81-
CompressionLevel: Optional[BackupCompressionLevel] = Field(
82-
default=None, alias="compression_level"
83-
)
84-
85-
86-
class BackupConfigRestore(_BackupConfigBase):
87-
"""Options to configure the backup when restoring a backup."""
88-
89-
90-
class BackupStatusReturn(BaseModel):
91-
"""Return type of the backup status methods."""
92-
93-
error: Optional[str] = Field(default=None)
94-
status: BackupStatus
95-
path: str
96-
backup_id: str = Field(alias="id")
97-
98-
99-
class BackupReturn(BackupStatusReturn):
100-
"""Return type of the backup creation and restore methods."""
101-
102-
collections: List[str] = Field(default_factory=list, alias="classes")
103-
10435

10536
class _BackupExecutor(Generic[ConnectionType]):
10637
def __init__(self, connection: Connection):

weaviate/classes/backup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from weaviate.backup.executor import (
1+
from weaviate.backup.backup import (
22
BackupCompressionLevel,
33
BackupConfigCreate,
44
BackupConfigRestore,
55
BackupStorage,
6-
BackupLocationType,
76
)
8-
from weaviate.backup.backup_location import BackupLocation
7+
from weaviate.backup.backup_location import BackupLocation, BackupLocationType
98

109

1110
__all__ = [

weaviate/client.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ Client class definition.
44

55
from typing import Optional, Tuple, Union, Dict, Any
66

7-
from weaviate.backup.backup import _BackupAsync
8-
from weaviate.backup.sync import _Backup
97
from weaviate.collections.classes.internal import _RawGQLReturn
108
from weaviate.collections.collections.async_ import _CollectionsAsync
119
from weaviate.collections.collections.sync import _Collections
1210

1311
from weaviate.users.async_ import _UsersAsync
1412

1513
from weaviate.users.sync import _Users
14+
from .backup import _Backup, _BackupAsync
1615
from .collections.batch.client import _BatchClientWrapper
1716
from .collections.cluster import _Cluster, _ClusterAsync
1817
from .connect.v4 import ConnectionV4

0 commit comments

Comments
 (0)