Skip to content

Project

v5.0.0 uses the object-oriented models

This page documents the legacy Project entity class. New code should use the object-oriented Project model.

synapseclient.entity.Project

Bases: Entity

Represents a project in Synapse.

WARNING - This class is deprecated and will no longer be maintained. Please use the Project model from synapseclient.models.Project instead.

Projects in Synapse must be uniquely named. Trying to create a project with a name that's already taken, say 'My project', will result in an error

ATTRIBUTE DESCRIPTION
name

The name of the project

alias

The project alias for use in friendly project urls.

properties

A map of Synapse properties

annotations

A map of user defined annotations

local_state

Internal use only

TYPE: dict

Using this class

Creating an instance and storing the project

project = Project('Foobarbat project')
project = syn.store(project)
Migration to the object-oriented model

 

The legacy Project class is created and persisted through the Synapse client. The object-oriented Project model stores itself.

# Old approach (DEPRECATED)
# from synapseclient import Project
# project = syn.store(Project(name="My Project"))

# New approach (RECOMMENDED)
from synapseclient import Synapse
from synapseclient.models import Project

syn = Synapse()
syn.login()

project = Project(name="My Project").store()
print(project.id)
Source code in synapseclient/entity.py
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
@deprecated(
    version="4.14.0",
    reason="To be removed in 5.0.0. "
    "Use the Project model from synapseclient.models.Project instead.",
)
class Project(Entity):
    """
    Represents a project in Synapse.

    WARNING - This class is deprecated and will no longer be maintained. Please use the Project model from synapseclient.models.Project instead.

    Projects in Synapse must be uniquely named. Trying to create a project with a name that's already taken, say
    'My project', will result in an error

    Attributes:
        name: The name of the project
        alias: The project alias for use in friendly project urls.
        properties: A map of Synapse properties
        annotations: A map of user defined annotations
        local_state: Internal use only


    Example: Using this class
        Creating an instance and storing the project

            project = Project('Foobarbat project')
            project = syn.store(project)

    Example: Migration to the object-oriented model
         

        The legacy Project class is created and persisted through the Synapse
        client. The object-oriented Project model stores itself.

        ```python
        # Old approach (DEPRECATED)
        # from synapseclient import Project
        # project = syn.store(Project(name="My Project"))

        # New approach (RECOMMENDED)
        from synapseclient import Synapse
        from synapseclient.models import Project

        syn = Synapse()
        syn.login()

        project = Project(name="My Project").store()
        print(project.id)
        ```
    """

    _synapse_entity_type = "org.sagebionetworks.repo.model.Project"

    _property_keys = Entity._property_keys + ["alias"]

    def __init__(
        self,
        name=None,
        properties=None,
        annotations=None,
        local_state=None,
        alias=None,
        **kwargs,
    ):
        if name:
            kwargs["name"] = name
        if alias:
            kwargs["alias"] = alias
        super(Project, self).__init__(
            concreteType=Project._synapse_entity_type,
            properties=properties,
            annotations=annotations,
            local_state=local_state,
            **kwargs,
        )