|
32 | 32 | from .models import FOLDER_REGEX, NAME_REGEX
|
33 | 33 | from .config.user import SimvueConfiguration
|
34 | 34 | from .api.request import get_json_from_response
|
35 |
| -from .api.objects import Run, Folder, Tag, Artifact, Alert, FileArtifact, ObjectArtifact |
| 35 | +from .api.objects import ( |
| 36 | + Run, |
| 37 | + Folder, |
| 38 | + Tag, |
| 39 | + Artifact, |
| 40 | + Alert, |
| 41 | + FileArtifact, |
| 42 | + ObjectArtifact, |
| 43 | + get_folder_from_path, |
| 44 | +) |
36 | 45 |
|
37 | 46 |
|
38 | 47 | CONCURRENT_DOWNLOADS = 10
|
@@ -429,6 +438,9 @@ def delete_folder(
|
429 | 438 | delete_runs=remove_runs, recursive=recursive, runs_only=False
|
430 | 439 | )
|
431 | 440 |
|
| 441 | + if folder_path not in _response.get("folders", []): |
| 442 | + raise RuntimeError("Deletion of folder failed, server returned mismatch.") |
| 443 | + |
432 | 444 | return _response.get("runs", [])
|
433 | 445 |
|
434 | 446 | @prettify_pydantic
|
@@ -665,17 +677,12 @@ def get_folder(
|
665 | 677 | RuntimeError
|
666 | 678 | if there was a failure when retrieving information from the server
|
667 | 679 | """
|
668 |
| - _folders: typing.Generator[tuple[str, Folder], None, None] = Folder.get( |
669 |
| - filters=json.dumps([f"path == {folder_path}"]) |
670 |
| - ) # type: ignore |
671 |
| - |
672 | 680 | try:
|
673 |
| - _, _folder = next(_folders) |
674 |
| - if not read_only: |
675 |
| - _folder.read_only(read_only) |
676 |
| - return _folder |
677 |
| - except StopIteration: |
| 681 | + _folder = get_folder_from_path(path=folder_path) |
| 682 | + except ObjectNotFoundError: |
678 | 683 | return None
|
| 684 | + _folder.read_only(is_read_only=read_only) |
| 685 | + return _folder |
679 | 686 |
|
680 | 687 | @pydantic.validate_call
|
681 | 688 | def get_folders(
|
|
0 commit comments