def getProtocols(self, count=100): """ Retrieve the Protocols attached to this Labstep Experiment. Returns ------- List[:class:`~labstep.entities.experimentProtocol.model.ExperimentProtocol`] List of the Protocols attached to the Experiment. Example ------- :: entity = user.getExperiment(17000) protocols = entity.getProtocols() protocols[0].attributes() """ from labstep.generic.entity.repository import entityRepository return entityRepository.getEntities( self.__user__, ExperimentProtocol, count, { "is_root": 0, "experiment_workflow_id": self.id }, )
def getResourceCategorys(self, user, count=100, search_query=None, tag_id=None, extraParams={}): """ Retrieve a list of a user's ResourceCategorys on Labstep, which can be filtered using the parameters: Parameters ---------- user (obj) The Labstep user. Must have property 'api_key'. See 'login'. count (int) The number of ResourceCategorys to retrieve. search_query (str) Search for ResourceCategorys with this 'name'. tag_id (int) The id of the Tag to retrieve. Returns ------- ResourceCategorys A list of ResourceCategory objects. """ filterParams = {"search_query": search_query, "tag_id": tag_id} params = {**filterParams, **extraParams, "is_template": 1} return entityRepository.getEntities(user, ResourceCategory, count, params)
def getDataFields(self, entity, count=1000, extraParams={}): params = {} if isinstance(entity, ExperimentProtocol): params = {"metadata_thread_id": entity.metadata_thread["id"]} elif isinstance(entity, Resource): params = { "experiment_value_resource_id": entity.id, "has_value": True } elif isinstance(entity, ResourceItem): params = { "experiment_value_resource_item_id": entity.id, "has_value": True } return entityRepository.getEntities(entity.__user__, ExperimentDataField, count=count, filterParams={ **params, **extraParams })
def getExperimentMaterials(self, user, experiment_id, count=100, extraParams={}): params = {'experiment_id': experiment_id, **extraParams} return entityRepository.getEntities(user, ExperimentMaterial, count, params)
def getExperimentSignatureRequests(self, user, experiment_id): params = { "experiment_workflow_id": experiment_id, "search": None, } return entityRepository.getEntities(user, ExperimentSignatureRequest, filterParams=params, count=100)
def getInvitations(self, user, organization_id, extraParams): return entityRepository.getEntities(user, Invitation, count=None, filterParams={ 'organization_id': organization_id, **extraParams })
def getResourceLocations( self, user, count=100, search_query=None, tag_id=None, extraParams={} ): params = { "group_id": user.activeWorkspace, "search_query": search_query, "tag_id": tag_id, **extraParams, } return entityRepository.getEntities(user, ResourceLocation, count, params)
def getCollections( self, user, count=1000, type=None, search_query=None, extraParams={} ): types = { "experiment": "experiment_workflow", "protocol": "protocol_collection", None: None, } params = {"search_query": search_query, "type": types[type], **extraParams} return entityRepository.getEntities(user, Collection, count, params)
def getDataFields(self, entity, count=1000, extraParams={}): if isinstance(entity, ProtocolVersion): params = { "metadata_thread_id": entity.metadata_thread["id"]} return entityRepository.getEntities( entity.__user__, ProtocolDataField, count=count, filterParams={ **params, **extraParams} )
def getMetadata(self, entity, count=1000, extraParams={}): if hasattr(entity, 'metadata_thread') is False: entity.update() params = { "metadata_thread_id": entity.metadata_thread["id"], **extraParams } return entityRepository.getEntities(entity.__user__, Metadata, count=count, filterParams=params)
def getOrganizationUsers(self, organization, count=100, extraParams={}): params = { 'organization_id': organization.id, **extraParams, } return entityRepository.getEntities(organization.__user__, OrganizationUser, count, filterParams=params)
def getComments(self, entity, count=100, extraParams={}): if entity.thread is None: return [] params = { "parent_thread_id": entity.thread["id"], "search": None, **extraParams, } return entityRepository.getEntities(entity.__user__, Comment, count, params)
def getResourceItems(self, user, resource_id=None, count=100, search_query=None, extraParams={}): params = { "search_query": search_query, "resource_id": resource_id, **extraParams, } return entityRepository.getEntities(user, ResourceItem, count, params)
def getFiles(self, user, count=100, search_query=None, file_type=None, extraParams={}): params = { "search_query": search_query, "filetype": file_type, **extraParams } return entityRepository.getEntities(user, File, count, params)
def getOrderRequests( self, user, count=100, search_query=None, tag_id=None, status=None, extraParams={}, ): params = { "group_id": user.activeWorkspace, "search_query": search_query, "tag_id": tag_id, "status": handleKeyword(status), **extraParams, } return entityRepository.getEntities(user, OrderRequest, count, params)
def getAttachedTags(self, entity, count=100): """ Retrieve the Tags attached to a Labstep Entity. Parameters ---------- entity (obj) The entity to retrieve Tags from. Returns ------- tags List of the tags attached. """ key = entity.__entityName__.replace("-", "_") + "_id" filterParams = {key: entity.id} return entityRepository.getEntities(entity.__user__, Tag, count=count, filterParams=filterParams)
def getProtocols( self, user, count=100, search_query=None, created_at_from=None, created_at_to=None, tag_id=None, collection_id=None, extraParams={}, ): params = { "search_query": search_query, "created_at_from": createdAtFrom(created_at_from), "created_at_to": createdAtTo(created_at_to), "tag_id": tag_id, "folder_id": collection_id, **extraParams, } return entityRepository.getEntities(user, Protocol, count, params)
def getData(self, count=100, search_query=None, extraParams={}): """ Retrieve a list of the data sent by an device. Parameters ---------- count (int) The total count of data points to return. search_query (str) Search for data points by name. extraParams (dict) Dictionary of extra filter parameters. Returns ------- DeviceData A list of DeviceData objects. """ from labstep.generic.entity.repository import entityRepository params = {"search_query": search_query, "device_id": self.id, **extraParams} return entityRepository.getEntities(self.__user__, DeviceData, count, params)
def getTags(self, user, count=1000, type=None, search_query=None, extraParams={}): """ Retrieve a list of the user's tags. Parameters ---------- user (obj) The Labstep user. Must have property 'api_key'. See 'login'. count (int) The number of Tags to retrieve. type (str) Return only tags of a certain type. Options are: 'experiment_workflow', 'protocol_collection', 'resource', 'order_request'. search_query (str) Search for Tags with this 'name'. extraParams (dict) Dictionary of extra filter parameters. Returns ------- tags A list of tag objects. """ params = { "search_query": search_query, "type": handleKeyword(type), **extraParams, } return entityRepository.getEntities(user, Tag, count, params)
def getProtocolMaterials(self, user, protocol_id, count=100, extraParams={}): params = { 'protocol_id': protocol_id, **extraParams } return entityRepository.getEntities(user, ProtocolMaterial, count, params)
def getResources( self, user, count=100, search_query=None, tag_id=None, extraParams={} ): params = {"search_query": search_query, "tag_id": tag_id, **extraParams} return entityRepository.getEntities(user, Resource, count, params)
def getAttachedCollections(self, entity, count=100): key = entity.__entityName__.replace("-", "_") + "_id" filterParams = {key: entity.id, "group_id": entity.__user__.activeWorkspace} return entityRepository.getEntities( entity.__user__, Collection, count=count, filterParams=filterParams )
def getWorkspaces(self, user, count=100, search_query=None, extraParams={}): params = {"name": search_query, **extraParams} return entityRepository.getEntities(user, Workspace, count, params)
def getDevices(self, user, count=100, search_query=None, extraParams={}): params = {"search_query": search_query, **extraParams} return entityRepository.getEntities(user, Device, count, params)
def getMembers(self, user, workspace_id, count=100, search_query=None, extraParams={}): params = {"group_id": workspace_id, "search_query_user": search_query, **extraParams} return entityRepository.getEntities(user, WorkspaceMember, count, params)