Resource
- class labstep.entities.resource.model.Resource(data, user)
Represents a Resource on Labstep.
To see all attributes of the resource run
print(my_resource)
Specific attributes can be accessed via dot notation like so…
print(my_resource.name) print(my_resource.id)
- edit(name=OPTIONAL, extraParams={})
Edit an existing Resource.
- Parameters:
name (str) – The new name of the Resource.
- Returns:
An object representing the edited Resource.
- Return type:
Example
my_resource = user.getResource(17000) my_resource.edit(name='A New Resource Name')
- delete()
Delete an existing Resource.
Example
my_resource = user.getResource(17000) my_resource.delete()
- getResourceCategory()
Get the ResourceCategory of the Resource.
- Returns:
An object representing the Resource Category on Labstep.
- Return type:
Example
# Get a Resource resource = user.getResource(170) # Get the Resource Category of the resource resourceCategory = resource.getResourceCategory()
- setResourceCategory(resource_category_id, extraParams={})
Add a Labstep ResourceCategory to a Resource.
- Parameters:
resource_category_id (int) – The id of
ResourceCategory
to set for the Resource.- Returns:
An object representing the Resource on Labstep.
- Return type:
Example
# Get a ResourceCategory resource_category = user.getResourceCategory(170) # Set the Resource Category my_resource = my_resource.setResourceCategory(resource_category.id)
- newOrderRequest(quantity=1, extraParams={})
Create a new Labstep OrderRequest.
- Parameters:
quantity (int) – The quantity of the new OrderRequest.
- Returns:
An object representing the new OrderRequest on Labstep.
- Return type:
Example
my_resource = user.getResource(17000) order_request = my_resource.newOrderRequest(quantity=2)
- getItems(count=OPTIONAL, search_query=OPTIONAL, extraParams={})
Returns the items of this Resource.
- Parameters:
count (int) – The number of ResourceItems to retrieve.
search_query (str) – Search for ResourceItems with this ‘name’.
extraParams (dict) – Dictionary of extra filter parameters.
- Returns:
A list of ResourceItem objects.
- Return type:
List[
ResourceItem
]
Example
my_resource = user.getResource(17000) items = my_resource.getItems()
- newItem(name=OPTIONAL, availability='available', amount=OPTIONAL, unit=OPTIONAL, resource_location_guid=OPTIONAL, extraParams={}, **kwargs)
Create a new Labstep ResourceItem.
- Parameters:
name (str) – The new name of the ResourceItem.
availability (str) – The status of the ResourceItem. Options are: “available” and “unavailable”.
amount (float) – The quantity of the ResourceItem.
unit (str) – The unit of the quantity.
resource_location_guid (str) – The guid of the ResourceLocation of the ResourceItem.
- Returns:
An object representing a ResourceItem on Labstep.
- Return type:
Example
my_resource = user.getResource(17000) item = my_resource.newItem(name='Test Item')
- getItemTemplate()
Get the template used for initialising new items of the resource.
- Returns:
An object representing a ResourceItem on Labstep.
- Return type:
Example
my_resource = user.getResource(17000) itemTemplate = my_resource.getItemTemplate() itemTemplate.addMetadata('Expiry Date')
- enableCustomItemTemplate()
Enable a custom item template for this resource. If disabled the template for the Resource Category will be used.
- Return type:
None
Example
my_resource = user.getResource(17000) my_resource.enableCustomItemTemplate() itemTemplate = my_resource.getItemTemplate() itemTemplate.addMetadata('Expiry Date')
- disableCustomItemTemplate()
Disable custom item template for this resource. If disabled the template for the Resource Category will be used.
- Return type:
None
Example
my_resource = user.getResource(17000) my_resource.disableCustomItemTemplate()
- getData()
Returns data linked to this resource via experiments.
- Return type:
List[
ExperimentDataField
]
Example
my_resource = user.getResource(17000) my_resource.getData()
- addChemicalMetadata(structure=OPTIONAL, iupac_name=OPTIONAL, cas=OPTIONAL, density=OPTIONAL, inchi=OPTIONAL, molecular_formula=OPTIONAL, molecular_weight=OPTIONAL, smiles=OPTIONAL, safety={}, svg=OPTIONAL)
Add chemical metadata to a Resource.
- Parameters:
structure (str) – The chemical structure as SMILES or MOL
iupac_name (str) – The IUPAC Name
cas (str) – The CAS Number
denstity (str) – The density of the chemicals
inchi (str) – The InChI of the chemical
molecular_formula (str) – The Molecular Formula
molecular_weight (str) – The Molecular Weight
smiles (str) – The SMILES string describing the chemical
svg (str) – An SVG preview of the chemical structure
- Return type:
Example
my_resource = user.getResource(17000) my_resource.addChemicalMetadata( structure='C1=CC=CC=C1', iupac_name="benzene", cas="71-43-2", density="0.879 at 68 °F (USCG, 1999)", inchi="InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H", molecular_formula="C6H6", molecular_weight="78.11", smiles='C1=CC=CC=C1', safety={ "precautionary": { "General": [], "Prevention": [ "P203", ], "Storage": [ "P403+P235", ], "Disposal": [ "P501" ] }, "ghs_hazard_statements": [ "H372" ], "pictograms": [ "GHS02", ] } )
- getChemicalMetadata()
Returns the chemical metadata associated with the resource
- Returns:
{ – “Structure”: string, “IUPACName”: string, “InChI”: string , “MolecularFormula”: string, “CAS”: string, “Density”: string, “SMILES”: string, “MolecularWeight”: string, “Safety”: {
- ”precautionary”: {
“General”: [string], “Prevention”: [string], “Response”: [string], “Storage”: [string], “Disposal”: [string]
}, “ghs_hazard_statements”: [string], “pictograms”: [string]
} “SVG”: string
}
Example
my_resource = user.getResource(17000) my_resource.getChemicalMetadata()
- addComment(body, filepath=OPTIONAL, extraParams={})
Add a comment and/or file to a Labstep Entity.
- Parameters:
body (str) – The body of the comment.
filepath (str) – A Labstep File entity to attach to the comment, including the filepath.
- Returns:
The comment added.
- Return type:
Example
my_experiment = user.getExperiment(17000) my_experiment.addComment(body='I am commenting!', filepath='pwd/file_to_upload.dat')
- addMetadata(fieldName, fieldType='default', value=OPTIONAL, date=OPTIONAL, number=OPTIONAL, unit=OPTIONAL, filepath=OPTIONAL, extraParams={})
Add Metadata to a Labstep Entity.
- Parameters:
fieldName (str) – The name of the field.
fieldType (str) – The Metadata field type. Options are: “default”, “date”, “numeric”, or “file”. The “default” type is “Text”.
value (str) – The value accompanying the fieldName entry.
date (str) – The date accompanying the fieldName entry. Must be in the format of “YYYY-MM-DD HH:MM”.
number (float) – The numeric value.
unit (str) – The unit accompanying the number entry.
filepath (str) – Local path to the file to upload for type ‘file’
- Returns:
An object representing the new Labstep Metadata.
- Return type:
Example
resource = user.getResource(17000) metadata = resource.addMetadata("Refractive Index", value="1.73")
- addTag(name)
Add a tag to the Entity (creates a new tag if none exists).
- Parameters:
name (str) – The name of the tag to create.
- Returns:
The Experiment that was tagged.
- Return type:
Example
my_experiment = user.getExperiment(17000) my_experiment.addTag(name='My Tag')
- assign(user_id, extraParams={})
Assign a user to a Labstep Entity as a Collaborator.
- Parameters:
user_id (int) – User to be assigned.
- Returns:
The collaborator added.
- Return type:
Collaborator
Example
- ::
user_id = 120 experiment= getExperiment(10000) collaborator = experiment.assign(user_id)
- export(rootPath, folderName=OPTIONAL)
Export the entity to the directory specified.
- Parameters:
path (str) – The path to the directory to save the experiment.
Example
experiment = user.getExperiment(17000) experiment.export('/my_folder')
- getCollaborators(count=OPTIONAL, extraParams={})
Get Collaborators assigned into a Labstep Entity.
- Parameters:
count (int) – Number of collaborators to fetch.
- Returns:
List of the collaborators assigned.
- Return type:
List[
Collaborator
]
Example
- ::
experiment= getExperiment(10000) collaborators = experiment.getCollaborators()
- getComments(count=OPTIONAL)
Retrieve the Comments attached to this Labstep Entity.
- Returns:
List of the comments attached.
- Return type:
List[
Comment
]
Example
entity = user.getExperiment(17000) comments = entity.getComments() comments[0].attributes()
- getMetadata()
Retrieve the Metadata of a Labstep Entity.
- Returns:
An array of Metadata objects for the Entity.
- Return type:
Example
my_resource = user.getResource(17000) metadatas = my_resource.getMetadata()
- getPermissions()
Returns the sharing permissions for the Entity.
- Return type:
List[
Permission
]
Returns a sharelink for the Entity.
- Returns:
The sharelink for the entity
- Return type:
- getTags()
Retrieve the Tags attached to a this Labstep Entity.
- Returns:
List of the tags attached.
- Return type:
List[
Tag
]
Example
entity = user.getExperiment(17000) tags = entity.getTags() tags[0].attributes()
Shares the Entity with another Workspace.
- Parameters:
workspace_id (int) – The id of the workspace to share with
permission (str) – Permission to share with. Can be ‘view’ or ‘edit’
- Return type:
None
- transferOwnership(workspace_id)
Transfer ownership of the Entity to a different Workspace
- Parameters:
workspace_id (int) – The id of the workspace to transfer ownership to
- update()
Fetches the most up-to-date version of the entity from Labstep.
ResourceCategory
- class labstep.entities.resourceCategory.model.ResourceCategory(data, user)
Represents a Resource Category on Labstep.
To see all attributes of the resource category run
print(my_resource_category)
Specific attributes can be accessed via dot notation like so…
print(my_resource_category.name) print(my_resource_category.id)
- edit(name=OPTIONAL, extraParams={})
Edit an existing ResourceCategory.
- Parameters:
name (str) – The new name of the ResourceCategory.
- Returns:
An object representing the edited ResourceCategory.
- Return type:
Example
my_resource_category = user.getResourceCategory(17000) my_resource_category.edit(name='A New ResourceCategory Name')
- delete()
Delete an existing ResourceCategory.
Example
my_resource_category = user.getResourceCategory(17000) my_resource_category.delete()
- getResourceTemplate()
Returns the metadata template for resources of this category.
Example
my_resource_category = user.getResourceCategory(17000) resourceTemplate = my_resource_category.getResourceTemplate() resourceTemplate.getMetadata() resourceTemplate.addMetadata('Vendor')
- getItemTemplate()
Returns the item template for resources of this category.
Example
my_resource_category = user.getResourceCategory(17000) itemTemplate = my_resource_category.getItemTemplate() itemTemplate.getMetadata() itemTemplate.addMetadata('Vendor')
- enableItemTemplate()
Enable an item template for this resource category. This template will be used to initialise new items for resources in this category, unless the resource has it’s own custom template.
- Return type:
None
Example
my_resource = user.getResource(17000) my_resource.enableCustomItemTemplate() itemTemplate = my_resource.getItemTemplate() itemTemplate.addMetadata('Expiry Date')
- disableItemTemplate()
Disable the item template for this resource category.
Example
my_resource = user.getResource(17000) my_resource.disableCustomItemTemplate()
- assign(user_id, extraParams={})
Assign a user to a Labstep Entity as a Collaborator.
- Parameters:
user_id (int) – User to be assigned.
- Returns:
The collaborator added.
- Return type:
Collaborator
Example
- ::
user_id = 120 experiment= getExperiment(10000) collaborator = experiment.assign(user_id)
- export(rootPath, folderName=OPTIONAL)
Export the entity to the directory specified.
- Parameters:
path (str) – The path to the directory to save the experiment.
Example
experiment = user.getExperiment(17000) experiment.export('/my_folder')
- getCollaborators(count=OPTIONAL, extraParams={})
Get Collaborators assigned into a Labstep Entity.
- Parameters:
count (int) – Number of collaborators to fetch.
- Returns:
List of the collaborators assigned.
- Return type:
List[
Collaborator
]
Example
- ::
experiment= getExperiment(10000) collaborators = experiment.getCollaborators()
- getPermissions()
Returns the sharing permissions for the Entity.
- Return type:
List[
Permission
]
Returns a sharelink for the Entity.
- Returns:
The sharelink for the entity
- Return type:
Shares the Entity with another Workspace.
- Parameters:
workspace_id (int) – The id of the workspace to share with
permission (str) – Permission to share with. Can be ‘view’ or ‘edit’
- Return type:
None
- transferOwnership(workspace_id)
Transfer ownership of the Entity to a different Workspace
- Parameters:
workspace_id (int) – The id of the workspace to transfer ownership to
- update()
Fetches the most up-to-date version of the entity from Labstep.
ResourceItem
- class labstep.entities.resourceItem.model.ResourceItem(data, user)
Represents a Resource Item on Labstep.
To see all attributes of the resource item run
print(my_resource_item)
Specific attributes can be accessed via dot notation like so…
print(my_resource_item.name) print(my_resource_item.id)
- edit(name=OPTIONAL, availability=OPTIONAL, amount=OPTIONAL, unit=OPTIONAL, resource_location_guid=OPTIONAL, extraParams={}, **kwargs)
Edit an existing ResourceItem.
- Parameters:
name (str) – The new name of the ResourceItem.
availability (str) – The availability of the ResourceItem. Options are: “available” and “unavailable”.
amount (float) – The quantity of the ResourceItem.
unit (str) – The unit of the quantity.
resource_location_guid (str) – The guid of the
ResourceLocation
of the ResourceItem.
- Returns:
An object representing the edited ResourceItem.
- Return type:
Example
my_resource_item = user.getResourceItem(17000) my_resource_item.edit(name='A New ResourceItem Name')
- delete()
Delete an existing ResourceItem.
Example
my_resource_item = user.getResourceItem(17000) my_resource_item.delete()
- getData()
Returns data linked to this resource via experiments.
- Return type:
List[
ExperimentDataField
]
Example
my_resource = user.getResource(17000) my_resource.getData()
- setLocation(resource_location_guid, position=None, size=[1, 1])
Set the location of the item and the position within the location.
- Parameters:
resource_location_guid (str) – The guid of location to put the item
position ([x (int,y: int])) – Optional: The position within the location to set as [x,y] coordinates
size ([w (int,h: int])) – Optional: Specify the width / height the item takes up in the location (defaults to [1,1])
Example
item = user.getResourceItem(17000) location = user.getResourceLocation(12434) item.setLocation(location,[1,3])
- getLocation()
Returns details on the location of the item as a dictionary of the form:
- {
‘resource_location’:
ResourceLocation
, ‘position’: [x (int),y (int)], ‘size’: [w (int),h (int)]
}
ResourceLocation
- class labstep.entities.resourceLocation.model.ResourceLocation(data, user)
Represents a Resource Location on Labstep.
To see all attributes of the resource location run
print(my_resource_location)
Specific attributes can be accessed via dot notation like so…
print(my_resource_location.name) print(my_resource_location.id)
- edit(name=OPTIONAL, extraParams={})
Edit an existing ResourceLocation.
- Parameters:
name (str) – The new name of the ResourceLocation.
- Returns:
An object representing the edited ResourceLocation.
- Return type:
Example
resource_location = user.getResourceLocation(123) resource_location.edit(name='A New ResourceLocation Name')
- delete()
Delete an existing ResourceLocation.
- Returns:
An object representing the deleted ResourceLocation.
- Return type:
Example
resource_location = user.getResourceLocation(123) resource_location.delete()
- getItems(count=OPTIONAL, extraParams={})
Get a list of items in this location.
- Returns:
An array of items in the ResourceLocation.
- Return type:
List[
ResourceItem
]
Example
resource_location = user.getResourceLocation(123) items = resource_location.getItems()
- getInnerLocations(extraParams={})
Returns a list of the sub-locations within this location.
- Returns:
An array of locations in the ResourceLocation.
- Return type:
List[
ResourceLocation
]
Example
resource_location = user.getResourceLocation(123) inner_locations = resource_location.getInnerLocations()
- addInnerLocation(name, position=None, size=[1, 1], extraParams={})
Adds a new inner location within this location.
- Parameters:
name (str) – The name of the new inner location.
position ([x (int,y: int])) – Optional: The position within the outer location to set as [x,y] coordinates
size ([w (int,h: int])) – Optional: Specify the width / height the item takes up in the outer location (defaults to [1,1])
- Returns:
An object representing the new inner location.
- Return type:
Example
resource_location = user.getResourceLocation(123) resource_location.edit(name='A New ResourceLocation Name')
- setOuterLocation(outer_location_guid, position=None, size=[1, 1])
Set the outer location for the location and the position within the outer location.
- Parameters:
outer_location_guid (str) – The guid of outer location for this location
position ([x (int,y: int])) – Optional: The position within the outer location to set as [x,y] coordinates
size ([w (int,h: int])) – Optional: Specify the width / height the item takes up in the outer location (defaults to [1,1])
Example
inner_location = user.getResourceLocation(1) outer_location = user.getResourceLocation(2) inner_location.setOuterLocation(outer_location_guid,position=[1,3],size=[1,1])
- createPositionMap(rowCount, columnCount, data={})
Creates a map of the location to specify the position of items / sub-locations within it.
- Parameters:
rowCount (int) – The number of rows in the map
columnCount (int) – The number of columns in the map
data (dict) – Optional: Dictionary specifying the position of the items / sub-locations within the location
Example
location = user.getResourceLocation(1) location.createPositionMap(n_rows=10,n_col=10)