Skip to content

Commit 42fa95f

Browse files
committed
update docstring for interactive terminal
1 parent f7627e0 commit 42fa95f

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

synapseclient/models/mixins/storage_location_mixin.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""Mixins for entities that can have their storage location and project settings configured."""
22

33
import asyncio
4-
from typing import TYPE_CHECKING, Any, List, Optional, Union
4+
from typing import Any, List, Optional, Union
55

66
from synapseclient import Synapse
77
from synapseclient.core.async_utils import async_to_sync, otel_trace_method
8+
from synapseclient.models.project_setting import ProjectSetting
89
from synapseclient.models.protocols.storage_location_mixin_protocol import (
910
StorageLocationConfigurableSynchronousProtocol,
1011
)
@@ -16,9 +17,6 @@
1617
)
1718
from synapseclient.models.services.migration_types import MigrationResult
1819

19-
if TYPE_CHECKING:
20-
from synapseclient.models.project_setting import ProjectSetting
21-
2220
# Default storage location ID used by Synapse
2321
DEFAULT_STORAGE_LOCATION_ID = 1
2422

@@ -200,22 +198,31 @@ async def migrate_indexed_files_async(
200198
This is the second step in migrating files to a new storage location.
201199
Files must first be indexed using `index_files_for_migration`.
202200
201+
**Interactive confirmation:** When called from an interactive shell and
202+
``force=False`` (the default), this method will print the number of items
203+
queued for migration and prompt for confirmation before proceeding. If
204+
standard output is not connected to an interactive terminal (e.g. a script
205+
or CI environment), migration is aborted unless ``force=True`` is set.
206+
203207
Arguments:
204208
db_path: Path to the SQLite database file created by
205209
`index_files_for_migration`. You can get this from the
206210
MigrationResult.db_path returned by index_files_for_migration.
207211
create_table_snapshots: Whether to create table snapshots before
208212
migrating table files.
209213
continue_on_error: Whether to continue migration if an error occurs.
210-
force: Whether to force migration of files that have already been
211-
migrated. Also bypasses interactive confirmation.
214+
force: Skip the interactive confirmation prompt and proceed with
215+
migration automatically. Set to ``True`` when running
216+
non-interactively (scripts, CI, automated pipelines).
217+
Defaults to False.
212218
synapse_client: If not passed in and caching was not disabled by
213219
`Synapse.allow_client_caching(False)` this will use the last created
214220
instance from the Synapse class constructor.
215221
216222
Returns:
217223
A MigrationResult object containing migration statistics, or None
218-
if the user declined the confirmation prompt.
224+
if migration was aborted (user declined the confirmation prompt, or
225+
the session is non-interactive and force=False).
219226
220227
Example: Migrating indexed files
221228
Migrate previously indexed files:
@@ -338,8 +345,6 @@ async def main():
338345
339346
asyncio.run(main())
340347
"""
341-
from synapseclient.models.project_setting import ProjectSetting
342-
343348
if not self.id:
344349
raise ValueError("The entity must have an id set.")
345350

@@ -404,8 +409,6 @@ async def main():
404409
405410
asyncio.run(main())
406411
"""
407-
from synapseclient.models.project_setting import ProjectSetting
408-
409412
if not self.id:
410413
raise ValueError("The entity must have an id set.")
411414

@@ -452,4 +455,6 @@ async def main():
452455
453456
asyncio.run(main())
454457
"""
458+
if not setting_id:
459+
raise ValueError("The id is required to delete a project setting.")
455460
await ProjectSetting(id=setting_id).delete_async(synapse_client=synapse_client)

0 commit comments

Comments
 (0)