Skip to content

Commit 582b666

Browse files
committed
Squashed commit of the following:
commit 77ea757 Author: BryanFauble <[email protected]> Date: Wed Jul 16 09:44:35 2025 -0700 Pre-commit change commit 4aa79e4 Author: BryanFauble <[email protected]> Date: Wed Jul 16 09:35:06 2025 -0700 Add async for column tests commit 660b103 Author: BryanFauble <[email protected]> Date: Mon Jul 14 22:46:09 2025 +0000 More column deprecation notices commit be04138 Author: BryanFauble <[email protected]> Date: Mon Jul 14 22:31:29 2025 +0000 Correction to Column on the mkdocs page commit b3761bc Author: BryanFauble <[email protected]> Date: Mon Jul 14 22:16:01 2025 +0000 Remove cache call commit 3a9b38b Author: BryanFauble <[email protected]> Date: Mon Jul 14 22:14:24 2025 +0000 Deprecate several column related methods from the Synapse class, and Column class. Moving them to API related functions that can be called commit bb3b73e Author: BryanFauble <[email protected]> Date: Mon Jul 14 19:32:54 2025 +0000 Add create_table_snapshot function and update snapshot methods in Table model - Implemented create_table_snapshot in table_services.py for creating table snapshots via the Synapse REST API. - Updated the Table model to use create_table_snapshot instead of the deprecated _create_table_snapshot method. - Added unit tests for snapshot creation in both asynchronous and synchronous test files. commit 6fdebef Author: BryanFauble <[email protected]> Date: Sat Jul 12 00:13:03 2025 +0000 Unit test patching commit af06fd1 Author: BryanFauble <[email protected]> Date: Fri Jul 11 23:33:00 2025 +0000 Remove note commit b41974f Author: BryanFauble <[email protected]> Date: Fri Jul 11 23:29:51 2025 +0000 Enhance Activity Protocol with Parent ID Support and Retrieval Methods - Updated ActivitySynchronousProtocol to accept EntityView and Dataset as valid parent types. - Added support for string IDs as parent entities in store, delete, and disassociate methods. - Introduced a new method `get` to retrieve activities by activity ID or parent entity ID, with version support. - Enhanced integration tests for Activity to cover new retrieval methods and string parent ID functionality. - Improved test cases to ensure proper handling of references and activity properties during storage and retrieval.
1 parent 8d0c1f8 commit 582b666

File tree

11 files changed

+1109
-18
lines changed

11 files changed

+1109
-18
lines changed

docs/reference/experimental/async/table.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ at your own risk.
3737
[](){ #column-reference-async }
3838
::: synapseclient.models.Column
3939
options:
40+
inherited_members: true
4041
members:
42+
- get_async
43+
- list_async
4144

4245
[](){ #schema-storage-strategy-reference-async }
4346
::: synapseclient.models.SchemaStorageStrategy

docs/reference/experimental/sync/table.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ at your own risk.
4848
[](){ #column-reference-sync }
4949
::: synapseclient.models.Column
5050
options:
51+
inherited_members: true
5152
members:
53+
- get
54+
- list
5255

5356
[](){ #schema-storage-strategy-reference-sync }
5457
::: synapseclient.models.SchemaStorageStrategy

synapseclient/api/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@
6969
ViewEntityType,
7070
ViewTypeMask,
7171
create_table_snapshot,
72+
get_column,
7273
get_columns,
7374
get_default_columns,
75+
list_columns,
76+
list_columns_sync,
7477
post_columns,
7578
)
7679
from .team_services import (
@@ -151,6 +154,9 @@
151154
# columns
152155
"get_columns",
153156
"post_columns",
157+
"get_column",
158+
"list_columns",
159+
"list_columns_sync",
154160
"get_default_columns",
155161
"ViewTypeMask",
156162
"ViewEntityType",

synapseclient/api/table_services.py

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import json
77
from enum import Enum
8-
from typing import TYPE_CHECKING, Dict, List, Optional, Union
8+
from typing import TYPE_CHECKING, AsyncGenerator, Dict, Generator, List, Optional, Union
99

1010
from synapseclient.core.utils import delete_none_keys, id_of
1111

@@ -123,6 +123,97 @@ async def get_columns(
123123
return columns
124124

125125

126+
async def get_column(
127+
column_id: str,
128+
*,
129+
synapse_client: Optional["Synapse"] = None,
130+
) -> Dict[str, Union[str, int]]:
131+
"""Get a single column by ID.
132+
133+
Arguments:
134+
column_id: The ID of the column to retrieve.
135+
synapse_client: If not passed in and caching was not disabled by
136+
`Synapse.allow_client_caching(False)` this will use the last created
137+
instance from the Synapse class constructor.
138+
139+
Returns:
140+
The column matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/ColumnModel.html>
141+
"""
142+
from synapseclient import Synapse
143+
144+
return await Synapse.get_client(synapse_client=synapse_client).rest_get_async(
145+
f"/column/{column_id}",
146+
)
147+
148+
149+
async def list_columns(
150+
prefix: Optional[str] = None,
151+
limit: int = 100,
152+
offset: int = 0,
153+
*,
154+
synapse_client: Optional["Synapse"] = None,
155+
) -> AsyncGenerator["Column", None]:
156+
"""List columns with optional prefix filtering.
157+
158+
Arguments:
159+
prefix: Optional prefix to filter columns by name.
160+
limit: Number of columns to retrieve per request to Synapse (pagination parameter).
161+
The function will continue retrieving results until all matching columns are returned.
162+
offset: The index of the first column to return (pagination parameter).
163+
synapse_client: If not passed in and caching was not disabled by
164+
`Synapse.allow_client_caching(False)` this will use the last created
165+
instance from the Synapse class constructor.
166+
167+
Yields: Column instances.
168+
"""
169+
from synapseclient.api.api_client import rest_get_paginated_async
170+
from synapseclient.models import Column
171+
172+
if prefix is None:
173+
uri = "/column"
174+
else:
175+
uri = f"/column?prefix={prefix}"
176+
177+
async for result in rest_get_paginated_async(
178+
uri, limit=limit, offset=offset, synapse_client=synapse_client
179+
):
180+
yield Column().fill_from_dict(synapse_column=result)
181+
182+
183+
def list_columns_sync(
184+
prefix: Optional[str] = None,
185+
limit: int = 100,
186+
offset: int = 0,
187+
*,
188+
synapse_client: Optional["Synapse"] = None,
189+
) -> Generator["Column", None, None]:
190+
"""List columns with optional prefix filtering (synchronous version).
191+
192+
Arguments:
193+
prefix: Optional prefix to filter columns by name.
194+
limit: Number of columns to retrieve per request to Synapse (pagination parameter).
195+
The function will continue retrieving results until all matching columns are returned.
196+
offset: The index of the first column to return (pagination parameter).
197+
synapse_client: If not passed in and caching was not disabled by
198+
`Synapse.allow_client_caching(False)` this will use the last created
199+
instance from the Synapse class constructor.
200+
201+
Yields: Column instances.
202+
"""
203+
from synapseclient import Synapse
204+
from synapseclient.models import Column
205+
206+
client = Synapse.get_client(synapse_client=synapse_client)
207+
208+
if prefix is None:
209+
uri = "/column"
210+
else:
211+
uri = f"/column?prefix={prefix}"
212+
213+
for result in client._GET_paginated(uri, limit=limit, offset=offset):
214+
yield Column().fill_from_dict(synapse_column=result)
215+
216+
126217
async def post_columns(
127218
columns: List["Column"], *, synapse_client: Optional["Synapse"] = None
128219
) -> List["Column"]:

0 commit comments

Comments
 (0)