Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create property function #786

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions devops/girder/annotation_client/annotation_client/annotations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import girder_client
import json

PATHS = {
"annotation": "/upenn_annotation/",
Expand All @@ -10,6 +11,7 @@
"connection_by_id": "/annotation_connection/{connectionId}",
"connect_to_nearest": "/annotation_connection/connectTo/",
"property_by_id": "/annotation_property/{propertyId}",
"property": "/annotation_property",
"add_property_values": (
"/annotation_property_values"
"?datasetId={datasetId}"
Expand All @@ -35,6 +37,8 @@
"&datasetId={datasetId}"
"&buckets={buckets}"
),
"configurations_by_dataset": "/dataset_view?datasetId={datasetId}",
"properties_by_configuration": "/item/{configurationId}",
}


Expand Down Expand Up @@ -319,6 +323,13 @@ def getPropertyById(self, propertyId):
PATHS["property_by_id"].format(propertyId=propertyId)
)

def createNewProperty(self, property):
"""
Add a property to the database
:param dict property: The property to add
"""
return self.client.post(PATHS["property"], json=property)

# Property values
def addAnnotationPropertyValues(self, datasetId, annotationId, values):
"""
Expand Down Expand Up @@ -403,3 +414,44 @@ def getPropertyValuesForAnnotation(self, datasetId, annotationId):
annotationId=annotationId, datasetId=datasetId
)
)

def setPropertiesByConfigurationId(self, configurationId, propertyIdList):
"""
Set the properties for a configuration
:param str configurationId: The id of the configuration
:param list propertyIdList: The list of property ids to set
"""
metadata = json.dumps({"propertyIds": propertyIdList})

params = {
'metadata': metadata
}

return self.client.put(
PATHS["properties_by_configuration"].format(
configurationId=configurationId
),
parameters=params
)

# Configurations

def getPropertiesByConfigurationId(self, configurationId):
"""
Get the properties for a configuration
:param str configurationId: The id of the configuration
"""
return self.client.get(
PATHS["properties_by_configuration"].format(
configurationId=configurationId
)
)

def getConfigurationsByDatasetId(self, datasetId):
"""
Get the configurations for a dataset
:param str datasetId: The id of the dataset
"""
return self.client.get(
PATHS["configurations_by_dataset"].format(datasetId=datasetId)
)
Loading