SubmissionView¶
Contained within this file are experimental interfaces for working with the Synapse Python Client. Unless otherwise noted these interfaces are subject to change at any time. Use at your own risk.
API reference¶
synapseclient.models.SubmissionView
dataclass
¶
Bases: SubmissionViewSynchronousProtocol
, AccessControllable
, ColumnMixin
, DeleteMixin
, GetMixin
, QueryMixin
, ViewBase
, ViewStoreMixin
, ViewSnapshotMixin
A SubmissionView
object represents the metadata of a Synapse Submission View.
https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/SubmissionView.html
ATTRIBUTE | DESCRIPTION |
---|---|
id |
The unique immutable ID for this entity. A new ID will be generated for new Entities. Once issued, this ID is guaranteed to never change or be re-issued. |
name |
The name of this entity. Must be 256 characters or less. Names may only contain: letters, numbers, spaces, underscores, hyphens, periods, plus signs, apostrophes, and parentheses. |
description |
The description of this entity. Must be 1000 characters or less. |
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date. |
created_on |
The date this entity was created. |
modified_on |
The date this entity was last modified. |
created_by |
The ID of the user that created this entity. |
modified_by |
The ID of the user that last modified this entity. |
parent_id |
The ID of the Entity that is the parent of this Entity. |
version_number |
The version number issued to this version on the object. |
version_label |
The version label for this entity. |
version_comment |
The version comment for this entity. |
is_latest_version |
If this is the latest version of the object. |
columns |
The columns of this submission view. This is an ordered dictionary
where the key is the name of the column and the value is the Column object.
When creating a new instance of a SubmissionView object you may pass any of
the following types as the You may modify the attributes of the Column object to change the column type, name, or other attributes. For example, suppose you'd like to change a column from a INTEGER to a DOUBLE. You can do so by changing the column type attribute of the Column object. The next time you store the view the column will be updated in Synapse with the new type.
TYPE:
|
is_search_enabled |
When creating or updating a table or view, specifies if full-text search should be enabled. Note that enabling full-text search might slow down the indexing of the table or view. |
scope_ids |
The list of container IDs that define the scope of this view. For submission views, this is the list of evaluation queues that the view is associated with. |
view_entity_type |
The API model string for the type of view. This is used to
determine the default columns that are added to the table. Must be defined as
a
TYPE:
|
Create a new SubmissionView.
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
my_submission_view = SubmissionView(
name="My Submission View",
parent_id="syn1234",
scope_ids=["syn5678", "syn6789"], # IDs of evaluation queues
).store()
print(my_submission_view)
Source code in synapseclient/models/submissionview.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 |
|
Functions¶
store_async
async
¶
store_async(dry_run: bool = False, *, job_timeout: int = 600, synapse_client: Optional[Synapse] = None) -> Self
Store information about a SubmissionView including the annotations, columns,
and scope. Updates to the scope_ids
attribute will be cause the rows of the
view to be updated. scope_ids
is a list of evaluation queues that the view is
associated with.
PARAMETER | DESCRIPTION |
---|---|
dry_run
|
If True, will not actually store the table but will log to the console what would have been stored.
TYPE:
|
job_timeout
|
The maximum amount of time to wait for a job to complete.
This is used when updating the table schema. If the timeout
is reached a
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Self
|
The SubmissionView instance stored in synapse. |
Create a new submission view.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
submission_view = SubmissionView(
name="My Submission View",
scope_ids=["syn9876543"], # ID of an evaluation queue
parent_id="syn1234",
)
submission_view = await submission_view.store_async()
print(f"Created Submission View with ID: {submission_view.id}")
asyncio.run(main())
Update the scope of an existing submission view.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
submission_view = await SubmissionView(id="syn1234").get_async()
submission_view.scope_ids = ["syn9876543", "syn8765432"] # Add a second evaluation queue
submission_view = await submission_view.store_async()
print("Updated Submission View scope.")
asyncio.run(main())
Source code in synapseclient/models/submissionview.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
|
get_async
async
¶
get_async(include_columns: bool = True, include_activity: bool = False, *, synapse_client: Optional[Synapse] = None) -> Self
Retrieve a SubmissionView from Synapse.
PARAMETER | DESCRIPTION |
---|---|
include_columns
|
Whether to include the columns in the returned view. Defaults to True. This is useful when updating the columns.
TYPE:
|
include_activity
|
Whether to include the activity in the returned view. Defaults to False. Setting this to True will include the activity record associated with this view.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Self
|
The SubmissionView instance retrieved from Synapse. |
Retrieving a submission view by ID.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
submission_view = await SubmissionView(id="syn1234").get_async()
print(submission_view)
asyncio.run(main())
Getting a submission view with its columns and activity.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
submission_view = await SubmissionView(id="syn1234").get_async(
include_columns=True,
include_activity=True
)
print(submission_view.columns)
print(submission_view.activity)
asyncio.run(main())
Source code in synapseclient/models/submissionview.py
624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 |
|
delete_async
async
¶
Delete a SubmissionView from Synapse.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
Delete a submission view.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
submission_view = SubmissionView(id="syn1234")
await submission_view.delete_async()
print("Deleted Submission View.")
asyncio.run(main())
Source code in synapseclient/models/submissionview.py
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
|
query_async
async
staticmethod
¶
query_async(query: str, include_row_id_and_row_version: bool = True, convert_to_datetime: bool = False, download_location=None, quote_character='"', escape_character='\\', line_end=str(linesep), separator=',', header=True, *, synapse_client: Optional[Synapse] = None, **kwargs) -> DATA_FRAME_TYPE
Query for data on a table stored in Synapse. The results will always be
returned as a Pandas DataFrame unless you specify a download_location
in which
case the results will be downloaded to that location. There are a number of
arguments that you may pass to this function depending on if you are getting
the results back as a DataFrame or downloading the results to a file.
PARAMETER | DESCRIPTION |
---|---|
query
|
The query to run. The query must be valid syntax that Synapse can understand. See this document that describes the expected syntax of the query: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/web/controller/TableExamples.html
TYPE:
|
include_row_id_and_row_version
|
If True the
TYPE:
|
convert_to_datetime
|
(DataFrame only) If set to True, will convert all Synapse DATE columns from UNIX timestamp integers into UTC datetime objects
TYPE:
|
download_location
|
(CSV Only) If set to a path the results will be downloaded to that directory. The results will be downloaded as a CSV file. A path to the downloaded file will be returned instead of a DataFrame.
DEFAULT:
|
quote_character
|
(CSV Only) The character to use to quote fields. The default is a double quote.
DEFAULT:
|
escape_character
|
(CSV Only) The character to use to escape special characters. The default is a backslash.
DEFAULT:
|
line_end
|
(CSV Only) The character to use to end a line. The default is the system's line separator. |
separator
|
(CSV Only) The character to use to separate fields. The default is a comma.
DEFAULT:
|
header
|
(CSV Only) If set to True the first row will be used as the header row. The default is True.
DEFAULT:
|
**kwargs
|
(DataFrame only) Additional keyword arguments to pass to pandas.read_csv. See https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html for complete list of supported arguments. This is exposed as internally the query downloads a CSV from Synapse and then loads it into a dataframe.
DEFAULT:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
DATA_FRAME_TYPE
|
The results of the query as a Pandas DataFrame or a path to the downloaded |
DATA_FRAME_TYPE
|
query results if |
Querying for data
This example shows how you may query for data in a table and print out the results.
import asyncio
from synapseclient import Synapse
from synapseclient.models import query_async
syn = Synapse()
syn.login()
async def main():
results = await query_async(query="SELECT * FROM syn1234")
print(results)
asyncio.run(main())
Source code in synapseclient/models/mixins/table_components.py
2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 |
|
query_part_mask_async
async
staticmethod
¶
query_part_mask_async(query: str, part_mask: int, *, synapse_client: Optional[Synapse] = None) -> QueryResultBundle
Query for data on a table stored in Synapse. This is a more advanced use case
of the query
function that allows you to determine what addiitional metadata
about the table or query should also be returned. If you do not need this
additional information then you are better off using the query
function.
The query for this method uses this Rest API: https://rest-docs.synapse.org/rest/POST/entity/id/table/query/async/start.html
PARAMETER | DESCRIPTION |
---|---|
query
|
The query to run. The query must be valid syntax that Synapse can understand. See this document that describes the expected syntax of the query: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/web/controller/TableExamples.html
TYPE:
|
part_mask
|
The bitwise OR of the part mask values you want to return in the results. The following list of part masks are implemented to be returned in the results:
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
QueryResultBundle
|
The results of the query as a Pandas DataFrame. |
Querying for data with a part mask
This example shows how to use the bitwise OR
of Python to combine the
part mask values and then use that to query for data in a table and print
out the results.
In this case we are getting the results of the query, the count of rows, and the last updated on date of the table.
import asyncio
from synapseclient import Synapse
from synapseclient.models import query_part_mask_async
syn = Synapse()
syn.login()
QUERY_RESULTS = 0x1
QUERY_COUNT = 0x2
LAST_UPDATED_ON = 0x80
# Combine the part mask values using bitwise OR
part_mask = QUERY_RESULTS | QUERY_COUNT | LAST_UPDATED_ON
async def main():
result = await query_part_mask_async(query="SELECT * FROM syn1234", part_mask=part_mask)
print(result)
asyncio.run(main())
Source code in synapseclient/models/mixins/table_components.py
2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 |
|
snapshot_async
async
¶
snapshot_async(*, comment: Optional[str] = None, label: Optional[str] = None, include_activity: bool = True, associate_activity_to_new_version: bool = True, synapse_client: Optional[Synapse] = None) -> TableUpdateTransaction
Creates a snapshot of the SubmissionView
entity.
Synapse handles snapshot creation differently for Table
- and View
-like
entities. View
snapshots are created using the asyncronous job API.
Making a snapshot of a view allows you to create an immutable version of the view at the time of the snapshot. This is useful to create checkpoints in time that you may go back and reference, or use in a publication. Snapshots are immutable and cannot be changed. They may only be deleted.
PARAMETER | DESCRIPTION |
---|---|
comment
|
A unique comment to associate with the snapshot. |
label
|
A unique label to associate with the snapshot. If this is not a unique label an exception will be raised when you store this to Synapse. |
include_activity
|
If True the activity will be included in snapshot if it
exists. In order to include the activity, the activity must have already
been stored in Synapse by using the
TYPE:
|
associate_activity_to_new_version
|
If True the activity will be associated with the new version of the table. If False the activity will not be associated with the new version of the table. Defaults to True.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
TableUpdateTransaction
|
A |
Creating a snapshot of a view with an activity
Create a snapshot of a view and include the activity. The activity must have been stored in
Synapse by using the activity
attribute on the SubmissionView and calling the store_async()
method on the SubmissionView instance. Adding an activity to a snapshot of a view is meant
to capture the provenance of the data at the time of the snapshot.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView, Activity, UsedURL
syn = Synapse()
syn.login()
async def main():
view = await SubmissionView(id="syn4567").get_async()
view.activity = Activity(
name="Activity for snapshot",
used=[UsedURL(name="Data Source", url="https://example.org")]
)
await view.store_async() # Store the activity
snapshot = await view.snapshot_async(
label="Q1 2025",
comment="Submissions reviewed in Lab A",
include_activity=True,
associate_activity_to_new_version=True
)
print(snapshot)
asyncio.run(main())
Creating a snapshot of a view without an activity
Create a snapshot of a view without including the activity. This is used in cases where we do not have any Provenance to associate with the snapshot and we do not want to persist any activity that may be present on the view to the new version of the view.
import asyncio
from synapseclient import Synapse
from synapseclient.models import SubmissionView
syn = Synapse()
syn.login()
async def main():
view = await SubmissionView(id="syn4567").get_async()
snapshot = await view.snapshot_async(
label="Q1 2025",
comment="Submissions reviewed in Lab A",
include_activity=False,
associate_activity_to_new_version=False
)
print(snapshot)
asyncio.run(main())
Source code in synapseclient/models/submissionview.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
|
add_column
¶
Add column(s) to the table. Note that this does not store the column(s) in
Synapse. You must call the .store()
function on this table class instance to
store the column(s) in Synapse. This is a convenience function to eliminate
the need to manually add the column(s) to the dictionary.
This function will add an item to the .columns
attribute of this class
instance. .columns
is a dictionary where the key is the name of the column
and the value is the Column object.
PARAMETER | DESCRIPTION |
---|---|
column
|
The column(s) to add, may be a single Column object or a list of Column objects. |
index
|
The index to insert the column at. If not passed in the column will be added to the end of the list.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Adding a single column
This example shows how you may add a single column to a table and then store the change back in Synapse.
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
table = Table(
id="syn1234"
).get(include_columns=True)
table.add_column(
Column(name="my_column", column_type=ColumnType.STRING)
)
table.store()
Adding multiple columns
This example shows how you may add multiple columns to a table and then store the change back in Synapse.
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
table = Table(
id="syn1234"
).get(include_columns=True)
table.add_column([
Column(name="my_column", column_type=ColumnType.STRING),
Column(name="my_column2", column_type=ColumnType.INTEGER),
])
table.store()
Adding a column at a specific index
This example shows how you may add a column at a specific index to a table and then store the change back in Synapse. If the index is out of bounds the column will be added to the end of the list.
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
table = Table(
id="syn1234"
).get(include_columns=True)
table.add_column(
Column(name="my_column", column_type=ColumnType.STRING),
# Add the column at the beginning of the list
index=0
)
table.store()
Adding a single column (async)
This example shows how you may add a single column to a table and then store the change back in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
async def main():
table = await Table(
id="syn1234"
).get_async(include_columns=True)
table.add_column(
Column(name="my_column", column_type=ColumnType.STRING)
)
await table.store_async()
asyncio.run(main())
Adding multiple columns (async)
This example shows how you may add multiple columns to a table and then store the change back in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
async def main():
table = await Table(
id="syn1234"
).get_async(include_columns=True)
table.add_column([
Column(name="my_column", column_type=ColumnType.STRING),
Column(name="my_column2", column_type=ColumnType.INTEGER),
])
await table.store_async()
asyncio.run(main())
Adding a column at a specific index (async)
This example shows how you may add a column at a specific index to a table and then store the change back in Synapse. If the index is out of bounds the column will be added to the end of the list.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
async def main():
table = await Table(
id="syn1234"
).get_async(include_columns=True)
table.add_column(
Column(name="my_column", column_type=ColumnType.STRING),
# Add the column at the beginning of the list
index=0
)
await table.store_async()
asyncio.run(main())
Source code in synapseclient/models/mixins/table_components.py
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
|
reorder_column
¶
Reorder a column in the table. Note that this does not store the column in
Synapse. You must call the .store()
function on this table class instance to
store the column in Synapse. This is a convenience function to eliminate
the need to manually reorder the .columns
attribute dictionary.
You must ensure that the index is within the bounds of the number of columns in the table. If you pass in an index that is out of bounds the column will be added to the end of the list.
PARAMETER | DESCRIPTION |
---|---|
name
|
The name of the column to reorder.
TYPE:
|
index
|
The index to move the column to starting with 0.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Reordering a column
This example shows how you may reorder a column in a table and then store the change back in Synapse.
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
table = Table(
id="syn1234"
).get(include_columns=True)
# Move the column to the beginning of the list
table.reorder_column(name="my_column", index=0)
table.store()
Reordering a column (async)
This example shows how you may reorder a column in a table and then store the change back in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Column, ColumnType, Table
syn = Synapse()
syn.login()
async def main():
table = await Table(
id="syn1234"
).get_async(include_columns=True)
# Move the column to the beginning of the list
table.reorder_column(name="my_column", index=0)
table.store_async()
asyncio.run(main())
Source code in synapseclient/models/mixins/table_components.py
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
|
delete_column
¶
delete_column(name: str) -> None
Mark a column for deletion. Note that this does not delete the column from
Synapse. You must call the .store()
function on this table class instance to
delete the column from Synapse. This is a convenience function to eliminate
the need to manually delete the column from the dictionary and add it to the
._columns_to_delete
attribute.
PARAMETER | DESCRIPTION |
---|---|
name
|
The name of the column to delete.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Deleting a column
This example shows how you may delete a column from a table and then store the change back in Synapse.
from synapseclient import Synapse
from synapseclient.models import Table
syn = Synapse()
syn.login()
table = Table(
id="syn1234"
).get(include_columns=True)
table.delete_column(name="my_column")
table.store()
Deleting a column (async)
This example shows how you may delete a column from a table and then store the change back in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.models import Table
syn = Synapse()
syn.login()
async def main():
table = await Table(
id="syn1234"
).get_async(include_columns=True)
table.delete_column(name="my_column")
table.store_async()
asyncio.run(main())
Source code in synapseclient/models/mixins/table_components.py
776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
|
get_acl_async
async
¶
Get the ACL that a user or group has on an Entity.
PARAMETER | DESCRIPTION |
---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
get_permissions_async
async
¶
get_permissions_async(*, synapse_client: Optional[Synapse] = None) -> Permissions
Get the permissions that the caller has on an Entity.
PARAMETER | DESCRIPTION |
---|---|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
permissions = await File(id="syn123").get_permissions_async()
asyncio.run(main())
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
set_permissions_async
async
¶
set_permissions_async(principal_id: int = None, access_type: List[str] = None, modify_benefactor: bool = False, warn_if_inherits: bool = True, overwrite: bool = True, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, list]]
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
PARAMETER | DESCRIPTION |
---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD'] |
modify_benefactor
|
Set as True when modifying a benefactor's ACL. The term 'benefactor' is used to indicate which Entity an Entity inherits its ACL from. For example, a newly created Project will be its own benefactor, while a new FileEntity's benefactor will start off as its containing Project. If the entity already has local sharing settings the benefactor would be itself. It may also be the immediate parent, somewhere in the parent tree, or the project itself.
TYPE:
|
warn_if_inherits
|
When
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
RETURNS | DESCRIPTION |
---|---|
Dict[str, Union[str, list]]
|
An Access Control List object |
Setting permissions
Grant all registered users download access
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
asyncio.run(main())
Grant the public view access
import asyncio
from synapseclient import Synapse
from synapseclient.models import File
syn = Synapse()
syn.login()
async def main():
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
asyncio.run(main())
Source code in synapseclient/models/mixins/access_control.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|