I was using this query to get ANY entity at ANY depth under a parent with a specific annotation. What is the correct way to do this in version 1.9.0 since the `query` [method is deprecated](https://sagebionetworks.jira.com/browse/SYNPY-729)? ``` synapse query ' SELECT * FROM entity WHERE projectId=="syn1234" AND my_anno != "" ' ```

Created by pstoutdev
Dear @pstoutdev We released the Synapse Python client version 1.9.0 on September 28, 2018. In this version, one can include different types of entity in a View. Please see our documentation for more details: https://python-docs.synapse.org/build/html/Entity.html#entity-view-schema
If someone lands here looking to create a view for Files AND Folders here is how: ``` evs = EntityViewSchema(name=self.SYT_VIEW_NAME, parent=self._project, scopes=[self._project], properties={'viewTypeMask': 9}) # Delete the 'type' property so we can set our own viewTypeMask to Files and Folders. evs.pop('type') # Since we removed 'type' we have to manually add the base columns. evs.addColumn(Column(name='id', columnType='ENTITYID')) evs.addColumn(Column(name='parentId', columnType='ENTITYID')) evs.addColumn(Column(name='projectId', columnType='ENTITYID')) evs.addColumn(Column(name='type', columnType='STRING')) evs.addColumn(Column(name='etag', columnType='STRING')) self._syt_view = self._synapse_client.store(evs) ``` `properties={'viewTypeMask': 9}` and `evs.pop('type')` is the key pieces here.
Thanks @kimyenAdmin! I got it working. ``` evs = EntityViewSchema(name='my_view', parent=self._project, scopes=[self._project], type='file') evs.addColumn(Column(name='field_1', columnType='STRING')) evs.addColumn(Column(name='field_2', columnType='DATE')) entity_view = self._synapse_client.store(evs) ```
Hi @pstoutdev File View performs better than the legacy query system and supports the use cases that the legacy query system was created for. If you have a use case that File View does not support, please let us know. I am tagging our product manager @Meredith so that she can follow up if there is any concern. As for using File View to manipulate the entities annotations, your code are modifying the view's annotations rather than the annotations of files within the view. It looks like our documentation does not cover how to add new annotation columns using File View. To add new annotations, please add new columns to the view: ``` view = syn.get("") new_column1 = syn.store(synapseclient.Column(name="my_anno_field_1", columnType = "STRING") new_column2 = syn.store(synapseclient.Column(name="my_anno_field_1", columnType = "DATE") view.addColumn(new_column1) view.addColumn(new_column2) view = syn.store(view) ``` Then to set default values: ``` queryResults = syn.tableQuery("select * from ") data = queryResults.asDataFrame() data[my_anno_field_1] = ['z'*100 for i in range (1, )] view = Table("", data) view = syn.store(view) ``` A view is a table, so you can manipulate it the same way one would update a table. For more information on Tables, please see: https://docs.synapse.org/articles/tables.html The Synapse Python client current version 1.8.2 only support creating File View with file entities. We will support creating File View with other entity types in future release. Please use the web client to include other types of entities in a view for now.
Removed
I need to create a `EntityViewSchema` that has Annotation columns that do not exists yet on any Project/Folder/File yet. Is this possible? This is what I tried: ``` annos = { "STRING": ('test_anno_field') } entity_view = EntityViewSchema(name='my_view', parent=self._project, scopes=[self._project], type='file', annotations=annos) entity_view = self._synapse_client.store(entity_view) ``` Also how can I create this view on all Files and Folders within the Project? I can do it through the web interface but I don't see a way via the Python library. Thanks.
Thanks for the info @kimyenAdmin. I'll try out the views. Is there a specific reason the query interface is being deprecated? This is a VERY useful feature that I have many uses for. Thanks, Patrick
Hello @pstoutdev , Currently, one could query for any entity under a scope (folder/ project) with a specific annotation via File View and table query. For more information about using File View in the Python client, please see: https://docs.synapse.org/articles/views.html

How to query by annotations in v1.9.0? page is loading…