Skip to content

Evaluation

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.Evaluation dataclass

Bases: EvaluationSynchronousProtocol

An Evaluation is the core object of the Evaluation API, used to support collaborative data analysis challenges in Synapse.

An Evaluation object represents an evaluation queue in Synapse: https://rest-docs.synapse.org/rest/org/sagebionetworks/evaluation/model/Evaluation.html

ATTRIBUTE DESCRIPTION
id

The unique immutable ID for this Evaluation.

TYPE: Optional[str]

etag

Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. The eTag changes every time an Evaluation is updated; it is used to detect when a client's copy of an Evaluation is out-of-date.

TYPE: Optional[str]

name

The name of this Evaluation.

TYPE: Optional[str]

description

A text description of this Evaluation.

TYPE: Optional[str]

owner_id

The ID of the Synapse user who created this Evaluation.

TYPE: Optional[str]

created_on

The date on which Evaluation was created.

TYPE: Optional[str]

content_source

The Synapse ID of the Entity to which this Evaluation belongs, e.g. a reference to a Synapse project.

TYPE: Optional[str]

submission_instructions_message

Message to display to users detailing acceptable formatting for Submissions to this Evaluation.

TYPE: Optional[str]

submission_receipt_message

Message to display to users upon successful submission to this Evaluation.

TYPE: Optional[str]

Create a new evaluation in a project

  Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised.

from synapseclient.models import Evaluation
from synapseclient import Synapse

syn = Synapse()
syn.login()

evaluation = Evaluation(
    name="My Challenge Evaluation",
    description="Evaluation for my data challenge",
    content_source="syn123456",
    submission_instructions_message="Submit CSV files only",
    submission_receipt_message="Thank you for your submission!",
)
created = evaluation.store()

Update an existing evaluation retrieved from Synapse by ID

  You can use the store method to create and update evaluations.

from synapseclient.models import Evaluation
from synapseclient import Synapse

syn = Synapse()
syn.login()

evaluation = Evaluation(id="9999999").get()
evaluation.description = "Updated description for my evaluation"
updated = evaluation.store()

Retrieve and update the ACL of an evaluation

 

from synapseclient.models import Evaluation
from synapseclient import Synapse

syn = Synapse()
syn.login()

evaluation = Evaluation(id="9999999").get()
acl = evaluation.get_acl()

# Let's grant this team READ and SUBMIT permissions
team_id = "123456"
evaluation.update_acl(principal_id=team_id, access_type=["READ", "SUBMIT"])

# Now let's revoke all permissions from this team
team_to_revoke_from = "654321"
evaluation.update_acl(principal_id=team_to_revoke_from, access_type=[])
Delete an evaluation

 

from synapseclient.models import Evaluation
from synapseclient import Synapse

syn = Synapse()
syn.login()

evaluation = Evaluation(id="9999999").get()
evaluation.delete()
Source code in synapseclient/models/evaluation.py
  22
  23
  24
  25
  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
  75
  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
 103
 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
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 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
 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
1055
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
@dataclass
@async_to_sync
class Evaluation(EvaluationSynchronousProtocol):
    """
    An Evaluation is the core object of the Evaluation API, used to support collaborative data analysis challenges in Synapse.

    An `Evaluation` object represents an evaluation queue in Synapse:
    <https://rest-docs.synapse.org/rest/org/sagebionetworks/evaluation/model/Evaluation.html>

    Attributes:
        id: The unique immutable ID for this Evaluation.
        etag: Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates.
              The eTag changes every time an Evaluation is updated; it is used to detect when a client's copy
              of an Evaluation is out-of-date.
        name: The name of this Evaluation.
        description: A text description of this Evaluation.
        owner_id: The ID of the Synapse user who created this Evaluation.
        created_on: The date on which Evaluation was created.
        content_source: The Synapse ID of the Entity to which this Evaluation belongs,
                        e.g. a reference to a Synapse project.
        submission_instructions_message: Message to display to users detailing acceptable formatting for Submissions to this Evaluation.
        submission_receipt_message: Message to display to users upon successful submission to this Evaluation.

    Example: Create a new evaluation in a project
        &nbsp;
        Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse

        syn = Synapse()
        syn.login()

        evaluation = Evaluation(
            name="My Challenge Evaluation",
            description="Evaluation for my data challenge",
            content_source="syn123456",
            submission_instructions_message="Submit CSV files only",
            submission_receipt_message="Thank you for your submission!",
        )
        created = evaluation.store()
        ```

    Example: Update an existing evaluation retrieved from Synapse by ID
        &nbsp;
        You can use the store method to create and update evaluations.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse

        syn = Synapse()
        syn.login()

        evaluation = Evaluation(id="9999999").get()
        evaluation.description = "Updated description for my evaluation"
        updated = evaluation.store()
        ```

    Example: Retrieve and update the ACL of an evaluation
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse

        syn = Synapse()
        syn.login()

        evaluation = Evaluation(id="9999999").get()
        acl = evaluation.get_acl()

        # Let's grant this team READ and SUBMIT permissions
        team_id = "123456"
        evaluation.update_acl(principal_id=team_id, access_type=["READ", "SUBMIT"])

        # Now let's revoke all permissions from this team
        team_to_revoke_from = "654321"
        evaluation.update_acl(principal_id=team_to_revoke_from, access_type=[])
        ```

    Example: Delete an evaluation
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse

        syn = Synapse()
        syn.login()

        evaluation = Evaluation(id="9999999").get()
        evaluation.delete()
        ```
    """

    id: Optional[str] = None
    """The unique immutable ID for this Evaluation."""

    etag: Optional[str] = None
    """Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates.
    The eTag changes every time an Evaluation is updated; it is used to detect when a client's copy
    of an Evaluation is out-of-date."""

    name: Optional[str] = None
    """The name of this Evaluation."""

    description: Optional[str] = None
    """A text description of this Evaluation."""

    owner_id: Optional[str] = None
    """The ID of the Synapse user who created this Evaluation."""

    created_on: Optional[str] = None
    """The date on which Evaluation was created."""

    content_source: Optional[str] = None
    """The Synapse ID of the Entity to which this Evaluation belongs,
    e.g. a reference to a Synapse project."""

    submission_instructions_message: Optional[str] = None
    """Message to display to users detailing acceptable formatting for Submissions to this Evaluation."""

    submission_receipt_message: Optional[str] = None
    """Message to display to users upon successful submission to this Evaluation."""

    _last_persistent_instance: Optional["Evaluation"] = field(
        default=None, repr=False, compare=False
    )
    """The last persistent instance of this object. This is used to determine if the
    object has been changed and needs to be updated in Synapse."""

    def fill_from_dict(self, evaluation: dict) -> "Evaluation":
        """
        Converts the data coming from the Synapse Evaluation API into this datamodel.

        Arguments:
            evaluation: The data coming from the Synapse Evaluation API

        Returns:
            The Evaluation object instance.
        """
        self.id = evaluation.get("id", None)
        self.etag = evaluation.get("etag", None)
        self.name = evaluation.get("name", None)
        self.description = evaluation.get("description", None)
        self.owner_id = evaluation.get("ownerId", None)
        self.created_on = evaluation.get("createdOn", None)
        self.content_source = evaluation.get("contentSource", None)
        self.submission_instructions_message = evaluation.get(
            "submissionInstructionsMessage", None
        )
        self.submission_receipt_message = evaluation.get(
            "submissionReceiptMessage", None
        )

        return self

    @property
    def has_changed(self) -> bool:
        """Determines if the object has been newly created OR changed since last retrieval, and needs to be updated in Synapse."""
        return (
            not self._last_persistent_instance or self._last_persistent_instance != self
        )

    def _set_last_persistent_instance(self) -> None:
        """Stash the last time this object interacted with Synapse. This is used to
        determine if the object has been changed and needs to be updated in Synapse."""
        self._last_persistent_instance = replace(self)

    def _update_acl_permissions(
        self,
        principal_id: Union[str, int],
        access_type: List[str],
        acl: dict,
        synapse_client: Optional["Synapse"] = None,
    ) -> dict:
        """
        Updates the ACL permissions of this object for the given principal.

        Arguments:
            principal_id: The Synapse user or team ID to update permissions for
            access_type: List of permission strings to grant. If empty, the principal will be removed from the ACL.
            acl: The current ACL dictionary
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            The updated ACL dictionary
        """
        principal_id_int = int(principal_id)

        # If the access_type list is empty, remove the principal from the ACL
        if len(access_type) == 0:
            client = Synapse.get_client(synapse_client=synapse_client)
            client.logger.info(
                f"Principal ID {principal_id_int} will be removed from ACL due to empty access_type"
            )

            acl["resourceAccess"] = [
                permissions
                for permissions in acl["resourceAccess"]
                if int(permissions["principalId"]) != principal_id_int
            ]
            return acl

        # Update existing principal
        for permissions in acl["resourceAccess"]:
            if int(permissions["principalId"]) == principal_id_int:
                permissions["accessType"] = access_type
                return acl

        # Add new principal
        acl["resourceAccess"].append(
            {"principalId": principal_id_int, "accessType": access_type}
        )

        return acl

    def to_synapse_request(self, request_type: RequestType):
        """Creates a request body expected of the Synapse REST API for the Evaluation model.

        Arguments:
            request_type: The type of request to be made, either RequestType.CREATE or RequestType.UPDATE.

        Returns:
            A dictionary containing the request body for the specified request type.

        Raises:
            ValueError: If any required attributes are missing.
        """

        # These attributes are required in our PUT requests for creating or updating an evaluation
        required_attributes = [
            "name",
            "description",
            "content_source",
            "submission_instructions_message",
            "submission_receipt_message",
        ]

        # For "update" requests, add id and etag
        if request_type == RequestType.UPDATE:
            required_attributes.extend(["id", "etag"])

        for attribute in required_attributes:
            if not getattr(self, attribute):
                raise ValueError(
                    f"Your evaluation object is missing the '{attribute}' attribute. This attribute is required to {request_type.value} an evaluation"
                )

        # Build a request body for storing a brand new evaluation
        request_body = {
            "name": self.name,
            "description": self.description,
            "contentSource": self.content_source,
            "submissionInstructionsMessage": self.submission_instructions_message,
            "submissionReceiptMessage": self.submission_receipt_message,
        }

        # For UPDATE request types, add id and etag
        if request_type == RequestType.UPDATE:
            request_body["id"] = self.id
            request_body["etag"] = self.etag

        return request_body

    async def store_async(
        self, *, synapse_client: Optional["Synapse"] = None
    ) -> "Evaluation":
        """
        Create a new Evaluation or update an existing one in Synapse.

        If the Evaluation object has an ID and etag, it will be updated.
        Otherwise, a new Evaluation will be created.

        Arguments:
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            The created or updated Evaluation object.

        Raises:
            ValueError: If required fields are missing.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Creating a new evaluation
            &nbsp;
            Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def create_evaluation():
                evaluation = await Evaluation(
                    name="My Challenge Evaluation",
                    description="Evaluation for my data challenge",
                    content_source="syn123456",
                    submission_instructions_message="Submit CSV files only",
                    submission_receipt_message="Thank you for your submission!"
                ).store_async()

                return evaluation

            created_evaluation = asyncio.run(create_evaluation())
            ```

        Example: Updating an existing evaluation
            &nbsp;
            You can use the store method to create and update evaluations.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def update_evaluation():
                evaluation = await Evaluation(id="9999999").get_async()
                evaluation.description = "Updated description for my evaluation"
                evaluation.submission_instructions_message = "New submission instructions"
                updated_evaluation = await evaluation.store_async()
                return updated_evaluation

            updated_evaluation = asyncio.run(update_evaluation())
            ```
        """

        from synapseclient.api.evaluation_services import create_or_update_evaluation

        # Get the client for logging
        client = Synapse.get_client(synapse_client=synapse_client)
        logger = client.logger

        # Set up OpenTelemetry tracing
        trace.get_current_span().set_attributes(
            {
                "synapse.name": self.name or "",
                "synapse.id": self.id or "",
            }
        )

        # CASE 1: No previous interaction with Synapse, so attempt to make a new evaluation
        if not self._last_persistent_instance:
            request_body = self.to_synapse_request(request_type=RequestType.CREATE)
            result = await create_or_update_evaluation(
                request_body=request_body,
                synapse_client=synapse_client,
            )

        # CASE 2: Previous interaction with Synapse, so attempt to update an existing evaluation
        elif self._last_persistent_instance:
            if self.has_changed:
                merge_dataclass_entities(
                    source=self._last_persistent_instance,
                    destination=self,
                    fields_to_preserve_from_source=[
                        "id",
                        "etag",
                        "content_source",
                        "owner_id",
                        "created_on",
                    ],
                    logger=logger,
                )
                request_body = self.to_synapse_request(request_type=RequestType.UPDATE)
                result = await create_or_update_evaluation(
                    request_body=request_body,
                    synapse_client=synapse_client,
                )
            else:
                logger.warning(
                    f"Evaluation {self.name} (ID: {self.id}) has not changed since last 'store' or 'get' event, so it will not be updated in Synapse. Please get the evaluation again if you want to refresh its state."
                )
                return self

        self.fill_from_dict(result)

        # Save the current state to track future changes
        self._set_last_persistent_instance()

        logger.debug(f"Saved Evaluation {self.name}, id: {self.id}")

        return self

    async def get_async(
        self, *, synapse_client: Optional["Synapse"] = None
    ) -> "Evaluation":
        """
        Get this Evaluation from Synapse by its ID or name.

        Arguments:
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            The retrieved Evaluation object.

        Raises:
            ValueError: If neither id nor name is set.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get an evaluation by ID and by name
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_evaluations():
                # Get an evaluation by ID
                evaluation_by_id = await Evaluation(id="9999999").get_async()

                # Get an evaluation by name
                evaluation_by_name = await Evaluation(name="My Challenge Evaluation").get_async()

                return evaluation_by_id, evaluation_by_name

            evaluation_by_id, evaluation_by_name = asyncio.run(get_evaluations())
            ```
        """
        from synapseclient.api.evaluation_services import get_evaluation

        if not self.id and not self.name:
            raise ValueError("Either id or name must be set to get an evaluation")

        retrieved_evaluation = await get_evaluation(
            evaluation_id=self.id,
            name=self.name,
            synapse_client=synapse_client,
        )

        self.fill_from_dict(retrieved_evaluation)

        # Save the current state to track future changes
        self._set_last_persistent_instance()

        return self

    async def delete_async(self, *, synapse_client: Optional["Synapse"] = None) -> None:
        """
        Delete this Evaluation from Synapse. ID must be set in order to delete the Evaluation.

        Arguments:
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Raises:
            ValueError: If evaluation_id is not set.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Delete an evaluation by ID
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def delete_evaluation():
                await Evaluation(id="9614112").delete_async()

            asyncio.run(delete_evaluation())
            ```

        Example: Get and then delete an evaluation
            &nbsp;
            If you do not have the ID of the evaluation, you can first retrieve it from Synapse by name. That will populate the ID attribute in your Evaluation object, at which point you can delete it.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_and_delete_evaluation():
                # First get the evaluation by name, so the ID attribute is set in your
                # Evaluation object, then delete it.
                evaluation = await Evaluation(name="My Challenge Evaluation").get_async()
                await evaluation.delete_async()

            asyncio.run(get_and_delete_evaluation())
            ```
        """
        from synapseclient.api.evaluation_services import delete_evaluation

        if not self.id:
            raise ValueError("id must be set to delete an evaluation")

        await delete_evaluation(
            evaluation_id=self.id,
            synapse_client=synapse_client,
        )

        # Clear the persistent instance since this object has been deleted
        self._last_persistent_instance = None

    async def get_acl_async(
        self, *, synapse_client: Optional["Synapse"] = None
    ) -> dict:
        """
        Get the access control list (ACL) governing this evaluation.

        Arguments:
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            The AccessControlList response object as a raw JSON dict.

        Raises:
            ValueError: If evaluation_id is not set.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get the ACL for an evaluation
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_evaluation_acl():
                # Get the evaluation first
                evaluation = await Evaluation(id="9999999").get_async()

                # Get the ACL for the evaluation
                acl = await evaluation.get_acl_async()
                return acl

            acl = asyncio.run(get_evaluation_acl())
            ```
        """
        from synapseclient.api.evaluation_services import get_evaluation_acl

        if not self.id:
            raise ValueError("id must be set to get evaluation ACL")

        return await get_evaluation_acl(
            evaluation_id=self.id,
            synapse_client=synapse_client,
        )

    async def update_acl_async(
        self,
        principal_id: Optional[Union[str, int]] = None,
        access_type: Optional[List[str]] = None,
        acl: Optional[dict] = None,
        *,
        synapse_client: Optional["Synapse"] = None,
    ) -> dict:
        """
        Update the access control list (ACL) for this evaluation.

        You can either: <br>
        1. Provide a `principal_id` and `access_type` list to update permissions for a specific user/team <br>
        2. Provide a complete ACL dictionary to update all permissions at once

        To remove a principal from the ACL completely, provide an empty list for access_type.

        The available access types are:

        - 'CREATE'
        - 'SUBMIT'
        - 'READ_PRIVATE_SUBMISSION'
        - 'DELETE_SUBMISSION'
        - 'UPDATE_SUBMISSION'
        - 'CHANGE_PERMISSIONS'
        - 'READ'
        - 'DELETE'
        - 'UPDATE'

        Arguments:
            principal_id: The Synapse user or team ID to update permissions for.
            access_type: List of permission strings to grant to the principal. If empty, the principal will be removed from the ACL.
            acl: A dictionary containing the complete ACL data to update. You can retrieve the current ACL using `get_acl_async()`.
                 If provided, principal_id and access_type are ignored.
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)`
                this will use the last created instance from the Synapse class constructor.

        Returns:
            The updated AccessControlList response object as a raw JSON dict.

        Raises:
            ValueError: If neither (principal_id and access_type) nor acl is provided, or if the ACL object is invalid.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Update permissions for a specific principal (user/team)
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def update_evaluation_permissions():
                # Get the evaluation first
                evaluation = await Evaluation(id="9999999").get_async()

                # Update permissions for user with ID 12345
                updated_acl = await evaluation.update_acl_async(
                    principal_id="12345",
                    access_type=["READ", "SUBMIT"]
                )
                return updated_acl

            updated_acl = asyncio.run(update_evaluation_permissions())
            ```

        Example: Remove a principal (user/team) from the ACL
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def remove_user_from_acl():
                # Get the evaluation first
                evaluation = await Evaluation(id="9999999").get_async()

                # Remove user with ID 12345 from the ACL by providing an empty list
                updated_acl = await evaluation.update_acl_async(
                    principal_id="12345",
                    access_type=[]
                )
                return updated_acl

            updated_acl = asyncio.run(remove_user_from_acl())
            ```

        Example: Update the entire ACL manually
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def update_evaluation_acl():
                # Get the evaluation first
                evaluation = await Evaluation(id="9999999").get_async()

                # Get the current ACL
                acl = await evaluation.get_acl_async()

                # Modify the ACL manually
                acl["resourceAccess"].append({
                    "principalId": 12345,
                    "accessType": ["READ", "SUBMIT"]
                })

                # Update with the modified ACL
                updated_acl = await evaluation.update_acl_async(acl=acl)
                return updated_acl

            updated_acl = asyncio.run(update_evaluation_acl())
            ```
        """
        from synapseclient.api.evaluation_services import update_evaluation_acl

        if not self.id:
            raise ValueError("id must be set to update evaluation ACL")

        # Case 1: Update permissions for specific principal
        if principal_id is not None and access_type is not None:
            access_type = [at.upper() for at in access_type]

            current_acl = await self.get_acl_async(synapse_client=synapse_client)

            updated_acl = self._update_acl_permissions(
                principal_id=principal_id,
                access_type=access_type,
                acl=current_acl,
                synapse_client=synapse_client,
            )

            return await update_evaluation_acl(
                acl=updated_acl,
                synapse_client=synapse_client,
            )

        # Case 2: Update entire ACL dictionary
        elif acl is not None:
            return await update_evaluation_acl(
                acl=acl,
                synapse_client=synapse_client,
            )

        else:
            raise ValueError(
                "Either (principal_id and access_type) or acl must be provided"
            )

    async def get_permissions_async(
        self,
        *,
        synapse_client: Optional["Synapse"] = None,
    ) -> dict:
        """
        Get the user permissions for this evaluation.

        Arguments:
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            dict: The permissions for the specified user.

        Raises:
            ValueError: If evaluation_id is not set.
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get permissions for the current user
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_evaluation_permissions():
                # Get the evaluation first
                evaluation = await Evaluation(id="9999999").get_async()

                # Get the permissions for the current user
                my_permissions = await evaluation.get_permissions_async()
                return my_permissions

            my_permissions = asyncio.run(get_evaluation_permissions())
            ```
        """
        from synapseclient.api.evaluation_services import get_evaluation_permissions

        if not self.id:
            raise ValueError("id must be set to get evaluation permissions")

        return await get_evaluation_permissions(
            evaluation_id=self.id,
            synapse_client=synapse_client,
        )

    @staticmethod
    async def get_all_evaluations_async(
        access_type: Optional[str] = None,
        active_only: Optional[bool] = None,
        evaluation_ids: Optional[List[str]] = None,
        offset: Optional[int] = None,
        limit: Optional[int] = None,
        *,
        synapse_client: Optional["Synapse"] = None,
    ) -> List["Evaluation"]:
        """
        Get a list of all Evaluations, within a given range.

        Arguments:
            access_type: The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.
            active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
            evaluation_ids: An optional list of evaluation IDs to which the response is limited.
            offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
            limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            List[Evaluation]: A list of all evaluations.

        Raises:
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get all evaluations the user has at least READ access to
            &nbsp;
            A default call will return evaluations where the user has read access, without needing to specify access type.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_all_evaluations():
                all_evaluations = await Evaluation.get_all_evaluations_async()
                return all_evaluations

            all_evaluations = asyncio.run(get_all_evaluations())
            ```

        Example: Get only active evaluations with a limit
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_active_evaluations():
                active_evaluations = await Evaluation.get_all_evaluations_async(
                    active_only=True,
                    limit=20
                )
                return active_evaluations

            active_evaluations = asyncio.run(get_active_evaluations())
            ```

        Example: Get specific evaluations by ID
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_specific_evaluations():
                specific_evaluations = await Evaluation.get_all_evaluations_async(
                    evaluation_ids=["9999991", "9999992"]
                )
                return specific_evaluations

            specific_evaluations = asyncio.run(get_specific_evaluations())
            ```
        """
        from synapseclient.api.evaluation_services import get_all_evaluations

        result_dict = await get_all_evaluations(
            access_type=access_type,
            active_only=active_only,
            evaluation_ids=evaluation_ids,
            offset=offset,
            limit=limit,
            synapse_client=synapse_client,
        )
        items = (
            result_dict.get("results") if isinstance(result_dict, dict) else result_dict
        )
        evaluations: List[Evaluation] = []
        for item in items:
            evaluations.append(Evaluation().fill_from_dict(item))

        return evaluations

    @staticmethod
    async def get_available_evaluations_async(
        active_only: Optional[bool] = None,
        evaluation_ids: Optional[List[str]] = None,
        offset: Optional[int] = None,
        limit: Optional[int] = None,
        *,
        synapse_client: Optional["Synapse"] = None,
    ) -> List["Evaluation"]:
        """
        Get a list of Evaluations to which the user has SUBMIT permission, within a given range.

        Arguments:
            active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
            evaluation_ids: An optional list of evaluation IDs to which the response is limited.
            offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
            limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            List[Evaluation]: A list of available evaluations.

        Raises:
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get all evaluations where the current user has SUBMIT permission
            &nbsp;
            A default call will return evaluations where the user has SUBMIT permission, without needing to specify access type.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_available_evaluations():
                available_evaluations = await Evaluation.get_available_evaluations_async()
                return available_evaluations

            available_evaluations = asyncio.run(get_available_evaluations())
            ```

        Example: Get only active evaluations where the current user has SUBMIT permission
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_active_available_evaluations():
                active_available_evaluations = await Evaluation.get_available_evaluations_async(
                    active_only=True
                )
                return active_available_evaluations

            active_available_evaluations = asyncio.run(get_active_available_evaluations())
            ```

        Example: Get the first 5 evaluations where the current user has SUBMIT permission
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_limited_evaluations():
                limited_evaluations = await Evaluation.get_available_evaluations_async(
                    limit=5
                )
                return limited_evaluations

            limited_evaluations = asyncio.run(get_limited_evaluations())
            ```
        """
        from synapseclient.api.evaluation_services import get_available_evaluations

        result_dict = await get_available_evaluations(
            active_only=active_only,
            evaluation_ids=evaluation_ids,
            offset=offset,
            limit=limit,
            synapse_client=synapse_client,
        )
        items = (
            result_dict.get("results") if isinstance(result_dict, dict) else result_dict
        )
        evaluations: List[Evaluation] = []
        for item in items:
            evaluations.append(Evaluation().fill_from_dict(item))

        return evaluations

    @staticmethod
    async def get_evaluations_by_project_async(
        project_id: str,
        access_type: Optional[str] = None,
        active_only: Optional[bool] = None,
        evaluation_ids: Optional[List[str]] = None,
        offset: Optional[int] = None,
        limit: Optional[int] = None,
        *,
        synapse_client: Optional["Synapse"] = None,
    ) -> List["Evaluation"]:
        """
        Get Evaluations tied to a project.

        Arguments:
            project_id: The ID of the project (e.g., "syn123456").
            access_type: The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.
            active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
            evaluation_ids: An optional list of evaluation IDs to which the response is limited.
            offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
            limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
            synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                            instance from the Synapse class constructor.

        Returns:
            List[Evaluation]: A list of Evaluations tied to the project.

        Raises:
            SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

        Example: Get all evaluations for a project
            &nbsp;
            The user must have at least READ access to the evaluations to retrieve the evaluations from a given project.
            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_project_evaluations():
                project_evaluations = await Evaluation.get_evaluations_by_project_async(
                    project_id="syn123456"
                )
                return project_evaluations

            project_evaluations = asyncio.run(get_project_evaluations())
            ```

        Example: Get only active evaluations for a project
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_active_project_evaluations():
                active_project_evaluations = await Evaluation.get_evaluations_by_project_async(
                    project_id="syn123456",
                    active_only=True
                )
                return active_project_evaluations

            active_project_evaluations = asyncio.run(get_active_project_evaluations())
            ```

        Example: Get a limited set of evaluations for a project
            &nbsp;

            ```python
            from synapseclient.models import Evaluation
            from synapseclient import Synapse
            import asyncio

            syn = Synapse()
            syn.login()

            async def get_limited_project_evaluations():
                limited_project_evaluations = await Evaluation.get_evaluations_by_project_async(
                    project_id="syn123456",
                    limit=5
                )
                return limited_project_evaluations

            limited_project_evaluations = asyncio.run(get_limited_project_evaluations())
            ```
        """
        from synapseclient.api.evaluation_services import get_evaluations_by_project

        result_dict = await get_evaluations_by_project(
            project_id=project_id,
            access_type=access_type,
            active_only=active_only,
            evaluation_ids=evaluation_ids,
            offset=offset,
            limit=limit,
            synapse_client=synapse_client,
        )
        items = (
            result_dict.get("results") if isinstance(result_dict, dict) else result_dict
        )
        evaluations: List[Evaluation] = []
        for item in items:
            evaluations.append(Evaluation().fill_from_dict(item))

        return evaluations

Functions

store_async async

store_async(*, synapse_client: Optional[Synapse] = None) -> Evaluation

Create a new Evaluation or update an existing one in Synapse.

If the Evaluation object has an ID and etag, it will be updated. Otherwise, a new Evaluation will be created.

PARAMETER DESCRIPTION
synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
Evaluation

The created or updated Evaluation object.

RAISES DESCRIPTION
ValueError

If required fields are missing.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Creating a new evaluation

  Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def create_evaluation():
    evaluation = await Evaluation(
        name="My Challenge Evaluation",
        description="Evaluation for my data challenge",
        content_source="syn123456",
        submission_instructions_message="Submit CSV files only",
        submission_receipt_message="Thank you for your submission!"
    ).store_async()

    return evaluation

created_evaluation = asyncio.run(create_evaluation())

Updating an existing evaluation

  You can use the store method to create and update evaluations.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def update_evaluation():
    evaluation = await Evaluation(id="9999999").get_async()
    evaluation.description = "Updated description for my evaluation"
    evaluation.submission_instructions_message = "New submission instructions"
    updated_evaluation = await evaluation.store_async()
    return updated_evaluation

updated_evaluation = asyncio.run(update_evaluation())

Source code in synapseclient/models/evaluation.py
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
async def store_async(
    self, *, synapse_client: Optional["Synapse"] = None
) -> "Evaluation":
    """
    Create a new Evaluation or update an existing one in Synapse.

    If the Evaluation object has an ID and etag, it will be updated.
    Otherwise, a new Evaluation will be created.

    Arguments:
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        The created or updated Evaluation object.

    Raises:
        ValueError: If required fields are missing.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Creating a new evaluation
        &nbsp;
        Create a new evaluation on Synapse by storing an evaluation object with the required fields. If there are any fields missing, an error will be raised.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def create_evaluation():
            evaluation = await Evaluation(
                name="My Challenge Evaluation",
                description="Evaluation for my data challenge",
                content_source="syn123456",
                submission_instructions_message="Submit CSV files only",
                submission_receipt_message="Thank you for your submission!"
            ).store_async()

            return evaluation

        created_evaluation = asyncio.run(create_evaluation())
        ```

    Example: Updating an existing evaluation
        &nbsp;
        You can use the store method to create and update evaluations.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def update_evaluation():
            evaluation = await Evaluation(id="9999999").get_async()
            evaluation.description = "Updated description for my evaluation"
            evaluation.submission_instructions_message = "New submission instructions"
            updated_evaluation = await evaluation.store_async()
            return updated_evaluation

        updated_evaluation = asyncio.run(update_evaluation())
        ```
    """

    from synapseclient.api.evaluation_services import create_or_update_evaluation

    # Get the client for logging
    client = Synapse.get_client(synapse_client=synapse_client)
    logger = client.logger

    # Set up OpenTelemetry tracing
    trace.get_current_span().set_attributes(
        {
            "synapse.name": self.name or "",
            "synapse.id": self.id or "",
        }
    )

    # CASE 1: No previous interaction with Synapse, so attempt to make a new evaluation
    if not self._last_persistent_instance:
        request_body = self.to_synapse_request(request_type=RequestType.CREATE)
        result = await create_or_update_evaluation(
            request_body=request_body,
            synapse_client=synapse_client,
        )

    # CASE 2: Previous interaction with Synapse, so attempt to update an existing evaluation
    elif self._last_persistent_instance:
        if self.has_changed:
            merge_dataclass_entities(
                source=self._last_persistent_instance,
                destination=self,
                fields_to_preserve_from_source=[
                    "id",
                    "etag",
                    "content_source",
                    "owner_id",
                    "created_on",
                ],
                logger=logger,
            )
            request_body = self.to_synapse_request(request_type=RequestType.UPDATE)
            result = await create_or_update_evaluation(
                request_body=request_body,
                synapse_client=synapse_client,
            )
        else:
            logger.warning(
                f"Evaluation {self.name} (ID: {self.id}) has not changed since last 'store' or 'get' event, so it will not be updated in Synapse. Please get the evaluation again if you want to refresh its state."
            )
            return self

    self.fill_from_dict(result)

    # Save the current state to track future changes
    self._set_last_persistent_instance()

    logger.debug(f"Saved Evaluation {self.name}, id: {self.id}")

    return self

get_async async

get_async(*, synapse_client: Optional[Synapse] = None) -> Evaluation

Get this Evaluation from Synapse by its ID or name.

PARAMETER DESCRIPTION
synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
Evaluation

The retrieved Evaluation object.

RAISES DESCRIPTION
ValueError

If neither id nor name is set.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get an evaluation by ID and by name

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_evaluations():
    # Get an evaluation by ID
    evaluation_by_id = await Evaluation(id="9999999").get_async()

    # Get an evaluation by name
    evaluation_by_name = await Evaluation(name="My Challenge Evaluation").get_async()

    return evaluation_by_id, evaluation_by_name

evaluation_by_id, evaluation_by_name = asyncio.run(get_evaluations())
Source code in synapseclient/models/evaluation.py
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
async def get_async(
    self, *, synapse_client: Optional["Synapse"] = None
) -> "Evaluation":
    """
    Get this Evaluation from Synapse by its ID or name.

    Arguments:
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        The retrieved Evaluation object.

    Raises:
        ValueError: If neither id nor name is set.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get an evaluation by ID and by name
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_evaluations():
            # Get an evaluation by ID
            evaluation_by_id = await Evaluation(id="9999999").get_async()

            # Get an evaluation by name
            evaluation_by_name = await Evaluation(name="My Challenge Evaluation").get_async()

            return evaluation_by_id, evaluation_by_name

        evaluation_by_id, evaluation_by_name = asyncio.run(get_evaluations())
        ```
    """
    from synapseclient.api.evaluation_services import get_evaluation

    if not self.id and not self.name:
        raise ValueError("Either id or name must be set to get an evaluation")

    retrieved_evaluation = await get_evaluation(
        evaluation_id=self.id,
        name=self.name,
        synapse_client=synapse_client,
    )

    self.fill_from_dict(retrieved_evaluation)

    # Save the current state to track future changes
    self._set_last_persistent_instance()

    return self

delete_async async

delete_async(*, synapse_client: Optional[Synapse] = None) -> None

Delete this Evaluation from Synapse. ID must be set in order to delete the Evaluation.

PARAMETER DESCRIPTION
synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RAISES DESCRIPTION
ValueError

If evaluation_id is not set.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Delete an evaluation by ID

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def delete_evaluation():
    await Evaluation(id="9614112").delete_async()

asyncio.run(delete_evaluation())
Get and then delete an evaluation

  If you do not have the ID of the evaluation, you can first retrieve it from Synapse by name. That will populate the ID attribute in your Evaluation object, at which point you can delete it.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_and_delete_evaluation():
    # First get the evaluation by name, so the ID attribute is set in your
    # Evaluation object, then delete it.
    evaluation = await Evaluation(name="My Challenge Evaluation").get_async()
    await evaluation.delete_async()

asyncio.run(get_and_delete_evaluation())

Source code in synapseclient/models/evaluation.py
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
async def delete_async(self, *, synapse_client: Optional["Synapse"] = None) -> None:
    """
    Delete this Evaluation from Synapse. ID must be set in order to delete the Evaluation.

    Arguments:
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Raises:
        ValueError: If evaluation_id is not set.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Delete an evaluation by ID
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def delete_evaluation():
            await Evaluation(id="9614112").delete_async()

        asyncio.run(delete_evaluation())
        ```

    Example: Get and then delete an evaluation
        &nbsp;
        If you do not have the ID of the evaluation, you can first retrieve it from Synapse by name. That will populate the ID attribute in your Evaluation object, at which point you can delete it.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_and_delete_evaluation():
            # First get the evaluation by name, so the ID attribute is set in your
            # Evaluation object, then delete it.
            evaluation = await Evaluation(name="My Challenge Evaluation").get_async()
            await evaluation.delete_async()

        asyncio.run(get_and_delete_evaluation())
        ```
    """
    from synapseclient.api.evaluation_services import delete_evaluation

    if not self.id:
        raise ValueError("id must be set to delete an evaluation")

    await delete_evaluation(
        evaluation_id=self.id,
        synapse_client=synapse_client,
    )

    # Clear the persistent instance since this object has been deleted
    self._last_persistent_instance = None

get_all_evaluations_async async staticmethod

get_all_evaluations_async(access_type: Optional[str] = None, active_only: Optional[bool] = None, evaluation_ids: Optional[List[str]] = None, offset: Optional[int] = None, limit: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> List[Evaluation]

Get a list of all Evaluations, within a given range.

PARAMETER DESCRIPTION
access_type

The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.

TYPE: Optional[str] DEFAULT: None

active_only

If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.

TYPE: Optional[bool] DEFAULT: None

evaluation_ids

An optional list of evaluation IDs to which the response is limited.

TYPE: Optional[List[str]] DEFAULT: None

offset

The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.

TYPE: Optional[int] DEFAULT: None

limit

Limits the number of entities that will be fetched for this page. When null it will default to 10.

TYPE: Optional[int] DEFAULT: None

synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
List[Evaluation]

List[Evaluation]: A list of all evaluations.

RAISES DESCRIPTION
SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get all evaluations the user has at least READ access to

  A default call will return evaluations where the user has read access, without needing to specify access type.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_all_evaluations():
    all_evaluations = await Evaluation.get_all_evaluations_async()
    return all_evaluations

all_evaluations = asyncio.run(get_all_evaluations())

Get only active evaluations with a limit

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_active_evaluations():
    active_evaluations = await Evaluation.get_all_evaluations_async(
        active_only=True,
        limit=20
    )
    return active_evaluations

active_evaluations = asyncio.run(get_active_evaluations())
Get specific evaluations by ID

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_specific_evaluations():
    specific_evaluations = await Evaluation.get_all_evaluations_async(
        evaluation_ids=["9999991", "9999992"]
    )
    return specific_evaluations

specific_evaluations = asyncio.run(get_specific_evaluations())
Source code in synapseclient/models/evaluation.py
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
@staticmethod
async def get_all_evaluations_async(
    access_type: Optional[str] = None,
    active_only: Optional[bool] = None,
    evaluation_ids: Optional[List[str]] = None,
    offset: Optional[int] = None,
    limit: Optional[int] = None,
    *,
    synapse_client: Optional["Synapse"] = None,
) -> List["Evaluation"]:
    """
    Get a list of all Evaluations, within a given range.

    Arguments:
        access_type: The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.
        active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
        evaluation_ids: An optional list of evaluation IDs to which the response is limited.
        offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
        limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        List[Evaluation]: A list of all evaluations.

    Raises:
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get all evaluations the user has at least READ access to
        &nbsp;
        A default call will return evaluations where the user has read access, without needing to specify access type.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_all_evaluations():
            all_evaluations = await Evaluation.get_all_evaluations_async()
            return all_evaluations

        all_evaluations = asyncio.run(get_all_evaluations())
        ```

    Example: Get only active evaluations with a limit
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_active_evaluations():
            active_evaluations = await Evaluation.get_all_evaluations_async(
                active_only=True,
                limit=20
            )
            return active_evaluations

        active_evaluations = asyncio.run(get_active_evaluations())
        ```

    Example: Get specific evaluations by ID
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_specific_evaluations():
            specific_evaluations = await Evaluation.get_all_evaluations_async(
                evaluation_ids=["9999991", "9999992"]
            )
            return specific_evaluations

        specific_evaluations = asyncio.run(get_specific_evaluations())
        ```
    """
    from synapseclient.api.evaluation_services import get_all_evaluations

    result_dict = await get_all_evaluations(
        access_type=access_type,
        active_only=active_only,
        evaluation_ids=evaluation_ids,
        offset=offset,
        limit=limit,
        synapse_client=synapse_client,
    )
    items = (
        result_dict.get("results") if isinstance(result_dict, dict) else result_dict
    )
    evaluations: List[Evaluation] = []
    for item in items:
        evaluations.append(Evaluation().fill_from_dict(item))

    return evaluations

get_available_evaluations_async async staticmethod

get_available_evaluations_async(active_only: Optional[bool] = None, evaluation_ids: Optional[List[str]] = None, offset: Optional[int] = None, limit: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> List[Evaluation]

Get a list of Evaluations to which the user has SUBMIT permission, within a given range.

PARAMETER DESCRIPTION
active_only

If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.

TYPE: Optional[bool] DEFAULT: None

evaluation_ids

An optional list of evaluation IDs to which the response is limited.

TYPE: Optional[List[str]] DEFAULT: None

offset

The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.

TYPE: Optional[int] DEFAULT: None

limit

Limits the number of entities that will be fetched for this page. When null it will default to 10.

TYPE: Optional[int] DEFAULT: None

synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
List[Evaluation]

List[Evaluation]: A list of available evaluations.

RAISES DESCRIPTION
SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get all evaluations where the current user has SUBMIT permission

  A default call will return evaluations where the user has SUBMIT permission, without needing to specify access type.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_available_evaluations():
    available_evaluations = await Evaluation.get_available_evaluations_async()
    return available_evaluations

available_evaluations = asyncio.run(get_available_evaluations())

Get only active evaluations where the current user has SUBMIT permission

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_active_available_evaluations():
    active_available_evaluations = await Evaluation.get_available_evaluations_async(
        active_only=True
    )
    return active_available_evaluations

active_available_evaluations = asyncio.run(get_active_available_evaluations())
Get the first 5 evaluations where the current user has SUBMIT permission

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_limited_evaluations():
    limited_evaluations = await Evaluation.get_available_evaluations_async(
        limit=5
    )
    return limited_evaluations

limited_evaluations = asyncio.run(get_limited_evaluations())
Source code in synapseclient/models/evaluation.py
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
@staticmethod
async def get_available_evaluations_async(
    active_only: Optional[bool] = None,
    evaluation_ids: Optional[List[str]] = None,
    offset: Optional[int] = None,
    limit: Optional[int] = None,
    *,
    synapse_client: Optional["Synapse"] = None,
) -> List["Evaluation"]:
    """
    Get a list of Evaluations to which the user has SUBMIT permission, within a given range.

    Arguments:
        active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
        evaluation_ids: An optional list of evaluation IDs to which the response is limited.
        offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
        limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        List[Evaluation]: A list of available evaluations.

    Raises:
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get all evaluations where the current user has SUBMIT permission
        &nbsp;
        A default call will return evaluations where the user has SUBMIT permission, without needing to specify access type.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_available_evaluations():
            available_evaluations = await Evaluation.get_available_evaluations_async()
            return available_evaluations

        available_evaluations = asyncio.run(get_available_evaluations())
        ```

    Example: Get only active evaluations where the current user has SUBMIT permission
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_active_available_evaluations():
            active_available_evaluations = await Evaluation.get_available_evaluations_async(
                active_only=True
            )
            return active_available_evaluations

        active_available_evaluations = asyncio.run(get_active_available_evaluations())
        ```

    Example: Get the first 5 evaluations where the current user has SUBMIT permission
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_limited_evaluations():
            limited_evaluations = await Evaluation.get_available_evaluations_async(
                limit=5
            )
            return limited_evaluations

        limited_evaluations = asyncio.run(get_limited_evaluations())
        ```
    """
    from synapseclient.api.evaluation_services import get_available_evaluations

    result_dict = await get_available_evaluations(
        active_only=active_only,
        evaluation_ids=evaluation_ids,
        offset=offset,
        limit=limit,
        synapse_client=synapse_client,
    )
    items = (
        result_dict.get("results") if isinstance(result_dict, dict) else result_dict
    )
    evaluations: List[Evaluation] = []
    for item in items:
        evaluations.append(Evaluation().fill_from_dict(item))

    return evaluations

get_evaluations_by_project_async async staticmethod

get_evaluations_by_project_async(project_id: str, access_type: Optional[str] = None, active_only: Optional[bool] = None, evaluation_ids: Optional[List[str]] = None, offset: Optional[int] = None, limit: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> List[Evaluation]

Get Evaluations tied to a project.

PARAMETER DESCRIPTION
project_id

The ID of the project (e.g., "syn123456").

TYPE: str

access_type

The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.

TYPE: Optional[str] DEFAULT: None

active_only

If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.

TYPE: Optional[bool] DEFAULT: None

evaluation_ids

An optional list of evaluation IDs to which the response is limited.

TYPE: Optional[List[str]] DEFAULT: None

offset

The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.

TYPE: Optional[int] DEFAULT: None

limit

Limits the number of entities that will be fetched for this page. When null it will default to 10.

TYPE: Optional[int] DEFAULT: None

synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
List[Evaluation]

List[Evaluation]: A list of Evaluations tied to the project.

RAISES DESCRIPTION
SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get all evaluations for a project

  The user must have at least READ access to the evaluations to retrieve the evaluations from a given project.

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_project_evaluations():
    project_evaluations = await Evaluation.get_evaluations_by_project_async(
        project_id="syn123456"
    )
    return project_evaluations

project_evaluations = asyncio.run(get_project_evaluations())

Get only active evaluations for a project

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_active_project_evaluations():
    active_project_evaluations = await Evaluation.get_evaluations_by_project_async(
        project_id="syn123456",
        active_only=True
    )
    return active_project_evaluations

active_project_evaluations = asyncio.run(get_active_project_evaluations())
Get a limited set of evaluations for a project

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_limited_project_evaluations():
    limited_project_evaluations = await Evaluation.get_evaluations_by_project_async(
        project_id="syn123456",
        limit=5
    )
    return limited_project_evaluations

limited_project_evaluations = asyncio.run(get_limited_project_evaluations())
Source code in synapseclient/models/evaluation.py
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
1055
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
@staticmethod
async def get_evaluations_by_project_async(
    project_id: str,
    access_type: Optional[str] = None,
    active_only: Optional[bool] = None,
    evaluation_ids: Optional[List[str]] = None,
    offset: Optional[int] = None,
    limit: Optional[int] = None,
    *,
    synapse_client: Optional["Synapse"] = None,
) -> List["Evaluation"]:
    """
    Get Evaluations tied to a project.

    Arguments:
        project_id: The ID of the project (e.g., "syn123456").
        access_type: The type of access for the user to filter for, optional and defaults to ACCESS_TYPE.READ.
        active_only: If True then return only those evaluations with rounds defined and for which the current time is in one of the rounds.
        evaluation_ids: An optional list of evaluation IDs to which the response is limited.
        offset: The offset index determines where this page will start from. An index of 0 is the first entity. When null it will default to 0.
        limit: Limits the number of entities that will be fetched for this page. When null it will default to 10.
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        List[Evaluation]: A list of Evaluations tied to the project.

    Raises:
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get all evaluations for a project
        &nbsp;
        The user must have at least READ access to the evaluations to retrieve the evaluations from a given project.
        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_project_evaluations():
            project_evaluations = await Evaluation.get_evaluations_by_project_async(
                project_id="syn123456"
            )
            return project_evaluations

        project_evaluations = asyncio.run(get_project_evaluations())
        ```

    Example: Get only active evaluations for a project
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_active_project_evaluations():
            active_project_evaluations = await Evaluation.get_evaluations_by_project_async(
                project_id="syn123456",
                active_only=True
            )
            return active_project_evaluations

        active_project_evaluations = asyncio.run(get_active_project_evaluations())
        ```

    Example: Get a limited set of evaluations for a project
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_limited_project_evaluations():
            limited_project_evaluations = await Evaluation.get_evaluations_by_project_async(
                project_id="syn123456",
                limit=5
            )
            return limited_project_evaluations

        limited_project_evaluations = asyncio.run(get_limited_project_evaluations())
        ```
    """
    from synapseclient.api.evaluation_services import get_evaluations_by_project

    result_dict = await get_evaluations_by_project(
        project_id=project_id,
        access_type=access_type,
        active_only=active_only,
        evaluation_ids=evaluation_ids,
        offset=offset,
        limit=limit,
        synapse_client=synapse_client,
    )
    items = (
        result_dict.get("results") if isinstance(result_dict, dict) else result_dict
    )
    evaluations: List[Evaluation] = []
    for item in items:
        evaluations.append(Evaluation().fill_from_dict(item))

    return evaluations

get_acl_async async

get_acl_async(*, synapse_client: Optional[Synapse] = None) -> dict

Get the access control list (ACL) governing this evaluation.

PARAMETER DESCRIPTION
synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
dict

The AccessControlList response object as a raw JSON dict.

RAISES DESCRIPTION
ValueError

If evaluation_id is not set.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get the ACL for an evaluation

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_evaluation_acl():
    # Get the evaluation first
    evaluation = await Evaluation(id="9999999").get_async()

    # Get the ACL for the evaluation
    acl = await evaluation.get_acl_async()
    return acl

acl = asyncio.run(get_evaluation_acl())
Source code in synapseclient/models/evaluation.py
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
async def get_acl_async(
    self, *, synapse_client: Optional["Synapse"] = None
) -> dict:
    """
    Get the access control list (ACL) governing this evaluation.

    Arguments:
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        The AccessControlList response object as a raw JSON dict.

    Raises:
        ValueError: If evaluation_id is not set.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get the ACL for an evaluation
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_evaluation_acl():
            # Get the evaluation first
            evaluation = await Evaluation(id="9999999").get_async()

            # Get the ACL for the evaluation
            acl = await evaluation.get_acl_async()
            return acl

        acl = asyncio.run(get_evaluation_acl())
        ```
    """
    from synapseclient.api.evaluation_services import get_evaluation_acl

    if not self.id:
        raise ValueError("id must be set to get evaluation ACL")

    return await get_evaluation_acl(
        evaluation_id=self.id,
        synapse_client=synapse_client,
    )

update_acl_async async

update_acl_async(principal_id: Optional[Union[str, int]] = None, access_type: Optional[List[str]] = None, acl: Optional[dict] = None, *, synapse_client: Optional[Synapse] = None) -> dict

Update the access control list (ACL) for this evaluation.

You can either:
1. Provide a principal_id and access_type list to update permissions for a specific user/team
2. Provide a complete ACL dictionary to update all permissions at once

To remove a principal from the ACL completely, provide an empty list for access_type.

The available access types are:

  • 'CREATE'
  • 'SUBMIT'
  • 'READ_PRIVATE_SUBMISSION'
  • 'DELETE_SUBMISSION'
  • 'UPDATE_SUBMISSION'
  • 'CHANGE_PERMISSIONS'
  • 'READ'
  • 'DELETE'
  • 'UPDATE'
PARAMETER DESCRIPTION
principal_id

The Synapse user or team ID to update permissions for.

TYPE: Optional[Union[str, int]] DEFAULT: None

access_type

List of permission strings to grant to the principal. If empty, the principal will be removed from the ACL.

TYPE: Optional[List[str]] DEFAULT: None

acl

A dictionary containing the complete ACL data to update. You can retrieve the current ACL using get_acl_async(). If provided, principal_id and access_type are ignored.

TYPE: Optional[dict] DEFAULT: None

synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
dict

The updated AccessControlList response object as a raw JSON dict.

RAISES DESCRIPTION
ValueError

If neither (principal_id and access_type) nor acl is provided, or if the ACL object is invalid.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Update permissions for a specific principal (user/team)

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def update_evaluation_permissions():
    # Get the evaluation first
    evaluation = await Evaluation(id="9999999").get_async()

    # Update permissions for user with ID 12345
    updated_acl = await evaluation.update_acl_async(
        principal_id="12345",
        access_type=["READ", "SUBMIT"]
    )
    return updated_acl

updated_acl = asyncio.run(update_evaluation_permissions())
Remove a principal (user/team) from the ACL

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def remove_user_from_acl():
    # Get the evaluation first
    evaluation = await Evaluation(id="9999999").get_async()

    # Remove user with ID 12345 from the ACL by providing an empty list
    updated_acl = await evaluation.update_acl_async(
        principal_id="12345",
        access_type=[]
    )
    return updated_acl

updated_acl = asyncio.run(remove_user_from_acl())
Update the entire ACL manually

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def update_evaluation_acl():
    # Get the evaluation first
    evaluation = await Evaluation(id="9999999").get_async()

    # Get the current ACL
    acl = await evaluation.get_acl_async()

    # Modify the ACL manually
    acl["resourceAccess"].append({
        "principalId": 12345,
        "accessType": ["READ", "SUBMIT"]
    })

    # Update with the modified ACL
    updated_acl = await evaluation.update_acl_async(acl=acl)
    return updated_acl

updated_acl = asyncio.run(update_evaluation_acl())
Source code in synapseclient/models/evaluation.py
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
async def update_acl_async(
    self,
    principal_id: Optional[Union[str, int]] = None,
    access_type: Optional[List[str]] = None,
    acl: Optional[dict] = None,
    *,
    synapse_client: Optional["Synapse"] = None,
) -> dict:
    """
    Update the access control list (ACL) for this evaluation.

    You can either: <br>
    1. Provide a `principal_id` and `access_type` list to update permissions for a specific user/team <br>
    2. Provide a complete ACL dictionary to update all permissions at once

    To remove a principal from the ACL completely, provide an empty list for access_type.

    The available access types are:

    - 'CREATE'
    - 'SUBMIT'
    - 'READ_PRIVATE_SUBMISSION'
    - 'DELETE_SUBMISSION'
    - 'UPDATE_SUBMISSION'
    - 'CHANGE_PERMISSIONS'
    - 'READ'
    - 'DELETE'
    - 'UPDATE'

    Arguments:
        principal_id: The Synapse user or team ID to update permissions for.
        access_type: List of permission strings to grant to the principal. If empty, the principal will be removed from the ACL.
        acl: A dictionary containing the complete ACL data to update. You can retrieve the current ACL using `get_acl_async()`.
             If provided, principal_id and access_type are ignored.
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)`
            this will use the last created instance from the Synapse class constructor.

    Returns:
        The updated AccessControlList response object as a raw JSON dict.

    Raises:
        ValueError: If neither (principal_id and access_type) nor acl is provided, or if the ACL object is invalid.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Update permissions for a specific principal (user/team)
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def update_evaluation_permissions():
            # Get the evaluation first
            evaluation = await Evaluation(id="9999999").get_async()

            # Update permissions for user with ID 12345
            updated_acl = await evaluation.update_acl_async(
                principal_id="12345",
                access_type=["READ", "SUBMIT"]
            )
            return updated_acl

        updated_acl = asyncio.run(update_evaluation_permissions())
        ```

    Example: Remove a principal (user/team) from the ACL
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def remove_user_from_acl():
            # Get the evaluation first
            evaluation = await Evaluation(id="9999999").get_async()

            # Remove user with ID 12345 from the ACL by providing an empty list
            updated_acl = await evaluation.update_acl_async(
                principal_id="12345",
                access_type=[]
            )
            return updated_acl

        updated_acl = asyncio.run(remove_user_from_acl())
        ```

    Example: Update the entire ACL manually
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def update_evaluation_acl():
            # Get the evaluation first
            evaluation = await Evaluation(id="9999999").get_async()

            # Get the current ACL
            acl = await evaluation.get_acl_async()

            # Modify the ACL manually
            acl["resourceAccess"].append({
                "principalId": 12345,
                "accessType": ["READ", "SUBMIT"]
            })

            # Update with the modified ACL
            updated_acl = await evaluation.update_acl_async(acl=acl)
            return updated_acl

        updated_acl = asyncio.run(update_evaluation_acl())
        ```
    """
    from synapseclient.api.evaluation_services import update_evaluation_acl

    if not self.id:
        raise ValueError("id must be set to update evaluation ACL")

    # Case 1: Update permissions for specific principal
    if principal_id is not None and access_type is not None:
        access_type = [at.upper() for at in access_type]

        current_acl = await self.get_acl_async(synapse_client=synapse_client)

        updated_acl = self._update_acl_permissions(
            principal_id=principal_id,
            access_type=access_type,
            acl=current_acl,
            synapse_client=synapse_client,
        )

        return await update_evaluation_acl(
            acl=updated_acl,
            synapse_client=synapse_client,
        )

    # Case 2: Update entire ACL dictionary
    elif acl is not None:
        return await update_evaluation_acl(
            acl=acl,
            synapse_client=synapse_client,
        )

    else:
        raise ValueError(
            "Either (principal_id and access_type) or acl must be provided"
        )

get_permissions_async async

get_permissions_async(*, synapse_client: Optional[Synapse] = None) -> dict

Get the user permissions for this evaluation.

PARAMETER DESCRIPTION
synapse_client

If not passed in and caching was not disabled by Synapse.allow_client_caching(False) this will use the last created instance from the Synapse class constructor.

TYPE: Optional[Synapse] DEFAULT: None

RETURNS DESCRIPTION
dict

The permissions for the specified user.

TYPE: dict

RAISES DESCRIPTION
ValueError

If evaluation_id is not set.

SynapseHTTPError

If the service rejects the request or an HTTP error occurs.

Get permissions for the current user

 

from synapseclient.models import Evaluation
from synapseclient import Synapse
import asyncio

syn = Synapse()
syn.login()

async def get_evaluation_permissions():
    # Get the evaluation first
    evaluation = await Evaluation(id="9999999").get_async()

    # Get the permissions for the current user
    my_permissions = await evaluation.get_permissions_async()
    return my_permissions

my_permissions = asyncio.run(get_evaluation_permissions())
Source code in synapseclient/models/evaluation.py
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
async def get_permissions_async(
    self,
    *,
    synapse_client: Optional["Synapse"] = None,
) -> dict:
    """
    Get the user permissions for this evaluation.

    Arguments:
        synapse_client: If not passed in and caching was not disabled by `Synapse.allow_client_caching(False)` this will use the last created
                        instance from the Synapse class constructor.

    Returns:
        dict: The permissions for the specified user.

    Raises:
        ValueError: If evaluation_id is not set.
        SynapseHTTPError: If the service rejects the request or an HTTP error occurs.

    Example: Get permissions for the current user
        &nbsp;

        ```python
        from synapseclient.models import Evaluation
        from synapseclient import Synapse
        import asyncio

        syn = Synapse()
        syn.login()

        async def get_evaluation_permissions():
            # Get the evaluation first
            evaluation = await Evaluation(id="9999999").get_async()

            # Get the permissions for the current user
            my_permissions = await evaluation.get_permissions_async()
            return my_permissions

        my_permissions = asyncio.run(get_evaluation_permissions())
        ```
    """
    from synapseclient.api.evaluation_services import get_evaluation_permissions

    if not self.id:
        raise ValueError("id must be set to get evaluation permissions")

    return await get_evaluation_permissions(
        evaluation_id=self.id,
        synapse_client=synapse_client,
    )