labstep 3.34.0__tar.gz → 3.35.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (177) hide show
  1. {labstep-3.34.0 → labstep-3.35.0}/PKG-INFO +1 -1
  2. labstep-3.35.0/labstep/constants/version.py +1 -0
  3. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocol/model.py +1 -1
  4. labstep-3.35.0/labstep/entities/protocolTemplate/model.py +549 -0
  5. labstep-3.35.0/labstep/entities/protocolTemplate/repository.py +64 -0
  6. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/user/model.py +98 -0
  7. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/helpers.py +2 -2
  8. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/PKG-INFO +1 -1
  9. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/SOURCES.txt +2 -0
  10. labstep-3.34.0/labstep/constants/version.py +0 -1
  11. {labstep-3.34.0 → labstep-3.35.0}/README.rst +0 -0
  12. {labstep-3.34.0 → labstep-3.35.0}/labstep/__init__.py +0 -0
  13. {labstep-3.34.0 → labstep-3.35.0}/labstep/config/export.py +0 -0
  14. {labstep-3.34.0 → labstep-3.35.0}/labstep/constants/__init__.py +0 -0
  15. {labstep-3.34.0 → labstep-3.35.0}/labstep/constants/unspecified.py +0 -0
  16. {labstep-3.34.0 → labstep-3.35.0}/labstep/converter/__init__.py +0 -0
  17. {labstep-3.34.0 → labstep-3.35.0}/labstep/converter/htmlToProseMirror.py +0 -0
  18. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/apiKey/model.py +0 -0
  19. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/apiKey/repository.py +0 -0
  20. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/autoshare/model.py +0 -0
  21. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/autoshare/repository.py +0 -0
  22. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/chemical/model.py +0 -0
  23. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/chemical/repository.py +0 -0
  24. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/chemicalReaction/model.py +0 -0
  25. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/chemicalReaction/repository.py +0 -0
  26. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaborator/model.py +0 -0
  27. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaborator/repository.py +0 -0
  28. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaboratorRole/model.py +0 -0
  29. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaboratorRole/repository.py +0 -0
  30. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaboratorRoleRequirement/model.py +0 -0
  31. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collaboratorRoleRequirement/repository.py +0 -0
  32. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collection/model.py +0 -0
  33. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/collection/repository.py +0 -0
  34. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/comment/model.py +0 -0
  35. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/comment/repository.py +0 -0
  36. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/customIdentifierSet/model.py +0 -0
  37. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/customIdentifierSet/repository.py +0 -0
  38. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/device/model.py +0 -0
  39. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/device/repository.py +0 -0
  40. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceBooking/model.py +0 -0
  41. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceBooking/repository.py +0 -0
  42. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceCategory/model.py +0 -0
  43. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceCategory/repository.py +0 -0
  44. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceData/model.py +0 -0
  45. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceData/repository.py +0 -0
  46. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceTemplate/model.py +0 -0
  47. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/deviceTemplate/repository.py +0 -0
  48. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityImport/model.py +0 -0
  49. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityImport/repository.py +0 -0
  50. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityState/model.py +0 -0
  51. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityState/repository.py +0 -0
  52. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityStateWorkflow/model.py +0 -0
  53. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/entityStateWorkflow/repository.py +0 -0
  54. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experiment/model.py +0 -0
  55. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experiment/repository.py +0 -0
  56. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentCondition/model.py +0 -0
  57. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentCondition/repository.py +0 -0
  58. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentDataField/model.py +0 -0
  59. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentDataField/repository.py +0 -0
  60. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentInventoryField/model.py +0 -0
  61. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentInventoryField/repository.py +0 -0
  62. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentLink/model.py +0 -0
  63. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentLink/repository.py +0 -0
  64. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentProtocol/model.py +0 -0
  65. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentProtocol/repository.py +0 -0
  66. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentSignature/model.py +0 -0
  67. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentSignature/repository.py +0 -0
  68. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentSignatureRequest/model.py +0 -0
  69. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentSignatureRequest/repository.py +0 -0
  70. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentStep/model.py +0 -0
  71. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentStep/repository.py +0 -0
  72. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTable/model.py +0 -0
  73. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTable/repository.py +0 -0
  74. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTemplate/model.py +0 -0
  75. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTemplate/repository.py +0 -0
  76. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTimer/model.py +0 -0
  77. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/experimentTimer/repository.py +0 -0
  78. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/export/model.py +0 -0
  79. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/export/repository.py +0 -0
  80. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/file/model.py +0 -0
  81. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/file/repository.py +0 -0
  82. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/invitation/model.py +0 -0
  83. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/invitation/repository.py +0 -0
  84. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterInstance/model.py +0 -0
  85. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterInstance/repository.py +0 -0
  86. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterNotebook/model.py +0 -0
  87. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterNotebook/repository.py +0 -0
  88. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterSchedule/model.py +0 -0
  89. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/jupyterSchedule/repository.py +0 -0
  90. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/metadata/model.py +0 -0
  91. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/metadata/repository.py +0 -0
  92. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/molecule/model.py +0 -0
  93. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/molecule/repository.py +0 -0
  94. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/notification/model.py +0 -0
  95. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/notification/repository.py +0 -0
  96. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/notificationAlert/model.py +0 -0
  97. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/notificationAlert/repository.py +0 -0
  98. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/orderRequest/model.py +0 -0
  99. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/orderRequest/repository.py +0 -0
  100. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/organization/model.py +0 -0
  101. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/organization/repository.py +0 -0
  102. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/organizationUser/model.py +0 -0
  103. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/organizationUser/repository.py +0 -0
  104. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/permission/model.py +0 -0
  105. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/permission/repository.py +0 -0
  106. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocol/repository.py +0 -0
  107. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolCondition/model.py +0 -0
  108. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolCondition/repository.py +0 -0
  109. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolDataField/model.py +0 -0
  110. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolDataField/repository.py +0 -0
  111. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolDevice/model.py +0 -0
  112. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolDevice/repository.py +0 -0
  113. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolInventoryField/model.py +0 -0
  114. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolInventoryField/repository.py +0 -0
  115. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolStep/model.py +0 -0
  116. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolStep/repository.py +0 -0
  117. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolTable/model.py +0 -0
  118. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolTable/repository.py +0 -0
  119. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolTimer/model.py +0 -0
  120. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolTimer/repository.py +0 -0
  121. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolVersion/model.py +0 -0
  122. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/protocolVersion/repository.py +0 -0
  123. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/purchaseOrder/model.py +0 -0
  124. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/purchaseOrder/repository.py +0 -0
  125. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resource/model.py +0 -0
  126. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resource/repository.py +0 -0
  127. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceCategory/model.py +0 -0
  128. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceCategory/repository.py +0 -0
  129. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceItem/model.py +0 -0
  130. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceItem/repository.py +0 -0
  131. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceLocation/model.py +0 -0
  132. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceLocation/repository.py +0 -0
  133. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceTemplate/model.py +0 -0
  134. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/resourceTemplate/repository.py +0 -0
  135. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/sequence/model.py +0 -0
  136. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/sequence/repository.py +0 -0
  137. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/sharelink/model.py +0 -0
  138. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/sharelink/repository.py +0 -0
  139. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/signatureRequirement/model.py +0 -0
  140. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/signatureRequirement/repository.py +0 -0
  141. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/tag/model.py +0 -0
  142. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/tag/repository.py +0 -0
  143. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/user/facade.py +0 -0
  144. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/user/repository.py +0 -0
  145. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspace/model.py +0 -0
  146. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspace/repository.py +0 -0
  147. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceMember/model.py +0 -0
  148. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceMember/repository.py +0 -0
  149. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceRole/model.py +0 -0
  150. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceRole/repository.py +0 -0
  151. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceRolePermission/model.py +0 -0
  152. {labstep-3.34.0 → labstep-3.35.0}/labstep/entities/workspaceRolePermission/repository.py +0 -0
  153. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entity/model.py +0 -0
  154. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entity/repository.py +0 -0
  155. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityList/model.py +0 -0
  156. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityPrimary/model.py +0 -0
  157. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithAssign/model.py +0 -0
  158. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithComments/model.py +0 -0
  159. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithMetadata/model.py +0 -0
  160. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithMetadata/repository.py +0 -0
  161. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithSharing/model.py +0 -0
  162. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithTags/model.py +0 -0
  163. {labstep-3.34.0 → labstep-3.35.0}/labstep/generic/entityWithTags/repository.py +0 -0
  164. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/__init__.py +0 -0
  165. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/config.py +0 -0
  166. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/htmlExport.py +0 -0
  167. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/htmlToPDF.py +0 -0
  168. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/htmlToProseMirror.py +0 -0
  169. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/jupyter.py +0 -0
  170. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/ping.py +0 -0
  171. {labstep-3.34.0 → labstep-3.35.0}/labstep/service/request.py +0 -0
  172. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/dependency_links.txt +0 -0
  173. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/not-zip-safe +0 -0
  174. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/requires.txt +0 -0
  175. {labstep-3.34.0 → labstep-3.35.0}/labstep.egg-info/top_level.txt +0 -0
  176. {labstep-3.34.0 → labstep-3.35.0}/setup.cfg +0 -0
  177. {labstep-3.34.0 → labstep-3.35.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: labstep
3
- Version: 3.34.0
3
+ Version: 3.35.0
4
4
  Summary: Python SDK for working with the Labstep API
5
5
  Home-page: http://github.com/Labstep/labstepPy
6
6
  Author: Labstep
@@ -0,0 +1 @@
1
+ VERSION = "3.35.0"
@@ -218,7 +218,7 @@ class Protocol(EntityPrimary):
218
218
  The name of the field.
219
219
  fieldType (str)
220
220
  The field type. Options are: "default", "date",
221
- "quantity", or "number". The "default" type is "Text".
221
+ "datetime", "numeric", "options" or "file". The "default" type is "Text".
222
222
  value (str)
223
223
  The value accompanying the fieldName entry.
224
224
  date (str)
@@ -0,0 +1,549 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # Author: Labstep <dev@labstep.com>
4
+ from labstep.constants import UNSPECIFIED
5
+ from labstep.entities.protocolVersion.model import ProtocolVersion
6
+ from labstep.generic.entity.repository import getEntityProperty
7
+ from labstep.generic.entityPrimary.model import EntityPrimary
8
+ from labstep.service.helpers import getTime
9
+
10
+ class ProtocolTemplate(EntityPrimary):
11
+ """
12
+ Represents a Protocol Template on Labstep.
13
+
14
+ To see all attributes of a protocol template run
15
+ ::
16
+ print(my_protocol_template)
17
+
18
+ Specific attributes can be accessed via dot notation like so...
19
+ ::
20
+ print(my_protocol_template.name)
21
+ print(my_protocol_template.id)
22
+ """
23
+
24
+ __entityName__ = "protocol-collection"
25
+ __searchKey__ = 'label'
26
+
27
+ @property
28
+ def draft_version(self):
29
+ return getEntityProperty(self, 'draft_version', ProtocolVersion)
30
+
31
+ @property
32
+ def last_version(self):
33
+ return getEntityProperty(self, 'last_version', ProtocolVersion)
34
+
35
+ def getCurrentVersion(self):
36
+ """
37
+ Returns the current version of the protocol template.
38
+
39
+ Returns
40
+ -------
41
+ :class:`~labstep.entities.protocolVersion.model.ProtocolVersion`
42
+ The current version of the protocol template.
43
+ """
44
+ if self.draft_version:
45
+ return self.draft_version
46
+ return self.last_version
47
+
48
+ def edit(self, name=UNSPECIFIED, body=UNSPECIFIED, extraParams={}):
49
+ """
50
+ Edit an existing Protocol Template.
51
+
52
+ Parameters
53
+ ----------
54
+ name (str)
55
+ The name of the Protocol Template.
56
+ body (dict):
57
+ JSON representing the the protocol template document.
58
+
59
+ Returns
60
+ -------
61
+ :class:`~labstep.entities.protocolTemplate.model.ProtocolTemplate`
62
+ An object representing the edited Protocol Template.
63
+
64
+ Example
65
+ -------
66
+ ::
67
+
68
+ my_protocol_template = user.getProtocolTemplate(17000)
69
+ my_protocol_template.edit(name='A New Protocol Template Name')
70
+ """
71
+ import labstep.entities.protocolTemplate.repository as protocolTemplateRepository
72
+ return protocolTemplateRepository.editProtocolTemplate(
73
+ self, name=name, body=body, extraParams=extraParams
74
+ )
75
+
76
+ def delete(self):
77
+ """
78
+ Delete an existing Protocol Template.
79
+
80
+ Example
81
+ -------
82
+ ::
83
+
84
+ my_protocol_template = user.getProtocolTemplate(17000)
85
+ my_protocol_template.delete()
86
+ """
87
+ import labstep.entities.protocolTemplate.repository as protocolTemplateRepository
88
+ return protocolTemplateRepository.editProtocolTemplate(self, deleted_at=getTime())
89
+
90
+ def newVersion(self):
91
+ """
92
+ Start a new version of the Protocol Template.
93
+
94
+ Example
95
+ -------
96
+ ::
97
+
98
+ my_protocol_template = user.getProtocolTemplate(17000)
99
+ new_version = my_protocol_template.newVersion()
100
+ """
101
+ import labstep.generic.entity.repository as entityRepository
102
+ entityRepository.newEntity(
103
+ self.__user__, ProtocolVersion, {"protocol_collection_id": self.id}
104
+ )
105
+ return self.update()
106
+
107
+ def getBody(self):
108
+ """
109
+ Returns the body of the protocol template as a JSON document
110
+
111
+ Example
112
+ -------
113
+ ::
114
+
115
+ my_protocol_template = user.newProtocolTemplate('My API Protocol Template')
116
+
117
+ my_protocol_template.edit(body={
118
+ "type": "doc",
119
+ "content": [
120
+ {
121
+ "type": "paragraph",
122
+ "attrs": {"align": None},
123
+ "content": [
124
+ {
125
+ "type": "text",
126
+ "text": "This is the the body of my protocol template"
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ "type": "paragraph",
132
+ "attrs": {"align": None}
133
+ }
134
+ ]
135
+ })
136
+
137
+ my_protocol_template.getBody()
138
+ """
139
+ return self.getCurrentVersion().getBody()
140
+
141
+
142
+ def getSteps(self):
143
+ """
144
+ Returns a list of the steps in a Protocol Template.
145
+
146
+ Returns
147
+ -------
148
+ List[:class:`~labstep.entities.protocolStep.model.ProtocolStep`]
149
+ List of the steps in Protocol Template.
150
+
151
+ Example
152
+ -------
153
+ ::
154
+
155
+ protocol_template = user.getProtocolTemplate(17000)
156
+ protocol_template_steps = protocol_template.getSteps()
157
+ """
158
+ return self.getCurrentVersion().getSteps()
159
+
160
+ def getDataFields(self):
161
+ """
162
+ Retrieve the Data Fields of a Protocol Template.
163
+
164
+ Returns
165
+ -------
166
+ :class:`~labstep.entities.metadata.model.Metadata`
167
+ An array of objects representing the Labstep Data Fields
168
+ on a Protocol Template.
169
+
170
+ Example
171
+ -------
172
+ ::
173
+
174
+ protocol_template = user.getProtocolTemplate(17000)
175
+ metadata = protocol_template.getDataFields()
176
+ """
177
+ return self.getCurrentVersion().getDataFields()
178
+
179
+ def addDataField(
180
+ self,
181
+ fieldName,
182
+ fieldType="default",
183
+ value=UNSPECIFIED,
184
+ date=UNSPECIFIED,
185
+ number=UNSPECIFIED,
186
+ unit=UNSPECIFIED,
187
+ filepath=UNSPECIFIED,
188
+ extraParams={},
189
+ ):
190
+ """
191
+ Add a Data Field to a Protocol Template.
192
+
193
+ Parameters
194
+ ----------
195
+ fieldName (str)
196
+ The name of the field.
197
+ fieldType (str)
198
+ The field type. Options are: "default", "date",
199
+ "datetime", or "numeric". The "default" type is "Text".
200
+ value (str)
201
+ The value accompanying the fieldName entry.
202
+ date (str)
203
+ The date and time accompanying the fieldName entry. Must be
204
+ in the format of "YYYY-MM-DD HH:MM".
205
+ number (float)
206
+ The quantity.
207
+ unit (str)
208
+ The unit accompanying the numeric entry.
209
+
210
+ Returns
211
+ -------
212
+ :class:`~labstep.entities.metadata.model.Metadata`
213
+ An object representing the new Labstep Data Field.
214
+
215
+ Example
216
+ -------
217
+ ::
218
+
219
+ protocol_template = user.getProtocolTemplate(17000)
220
+ dataField = protocol_template.addDataField("Refractive Index",
221
+ value="1.73")
222
+ """
223
+ return self.getCurrentVersion().addDataField(
224
+ fieldName=fieldName,
225
+ fieldType=fieldType,
226
+ value=value,
227
+ date=date,
228
+ number=number,
229
+ unit=unit,
230
+ filepath=filepath,
231
+ extraParams=extraParams
232
+ )
233
+
234
+ def addInventoryField(
235
+ self, name=UNSPECIFIED, amount=UNSPECIFIED, units=UNSPECIFIED, resource_id=UNSPECIFIED, category_id=UNSPECIFIED,extraParams={}
236
+ ):
237
+ """
238
+ Add a new inventory field to the Protocol Template.
239
+
240
+ Parameters
241
+ ----------
242
+ name (str)
243
+ The name of the inventory field to add.
244
+ amount (str)
245
+ The amount required by the protocol template.
246
+ units (str)
247
+ The units for the amount.
248
+ resource_id (int)
249
+ The id of the :class:`~labstep.entities.resource.model.Resource`. Items must be from this resource.
250
+ category_id (int)
251
+ The id of the :class:`~labstep.entities.resourceCategory.model.ResourceCategory`.
252
+ Items must be from this resource category.
253
+
254
+ Returns
255
+ -------
256
+ :class:`~labstep.entities.protocolInventoryField.model.ProtocolInventoryField`
257
+ The newly added inventory field entity.
258
+
259
+ Example
260
+ -------
261
+ ::
262
+
263
+ protocol_template = user.getProtocolTemplate(17000)
264
+ resource = user.getResources(search_query='Sample A')[0]
265
+ protocol_template.addInventoryField(name='Sample A', amount='2', units='ml',
266
+ resource_id=resource.id)
267
+ """
268
+ return self.getCurrentVersion().addInventoryField(
269
+ resource_id=resource_id, name=name,
270
+ amount=amount,
271
+ units=units,
272
+ category_id=category_id,
273
+ extraParams=extraParams)
274
+
275
+ def getInventoryFields(self, count=100, extraParams={}):
276
+ """
277
+ Returns a list of the inventory fields in a Protocol Template.
278
+
279
+ Returns
280
+ -------
281
+ List[:class:`~labstep.entities.protocolInventoryField.model.ProtocolInventoryField`]
282
+ List of the inventory fields in a Protocol Template.
283
+
284
+ Example
285
+ -------
286
+ ::
287
+
288
+ protocol_template = user.getProtocolTemplate(17000)
289
+ protocol_template_inventoryFields = protocol_template.getInventoryFields()
290
+ protocol_template_inventory_fields[0]
291
+ """
292
+ return self.getCurrentVersion().getInventoryFields(count=count, extraParams=extraParams)
293
+
294
+ def addTimer(self, name=UNSPECIFIED, hours=UNSPECIFIED, minutes=UNSPECIFIED, seconds=UNSPECIFIED):
295
+ """
296
+ Add a new timer to the Protocol Template.
297
+
298
+ Parameters
299
+ ----------
300
+ name (str)
301
+ The name of the timer.
302
+ hours (int)
303
+ The hours of the timer.
304
+ minutes (int)
305
+ The minutes of the timer.
306
+ seconds (int)
307
+ The seconds of the timer.
308
+
309
+ Returns
310
+ -------
311
+ :class:`~labstep.entities.protocolTimer.model.ProtocolTimer`
312
+ The newly added timer entity.
313
+
314
+ Example
315
+ -------
316
+ ::
317
+
318
+ protocol_template = user.getProtocolTemplate(17000)
319
+ protocol_template.addTimer(name='Refluxing', hours='4', minutes='30')
320
+ """
321
+ return self.getCurrentVersion().addTimer(name=name, hours=hours, minutes=minutes, seconds=seconds)
322
+
323
+ def getTimers(self):
324
+ """
325
+ Returns a list of the timers in a Protocol Template.
326
+
327
+ Returns
328
+ -------
329
+ List[:class:`~labstep.entities.protocolTimer.model.ProtocolTimer`]
330
+ List of the timers in a Protocol Template.
331
+
332
+ Example
333
+ -------
334
+ ::
335
+
336
+ protocol_template = user.getProtocolTemplate(17000)
337
+ protocol_template_timers = protocol_template.getTimers()
338
+ """
339
+ return self.getCurrentVersion().getTimers()
340
+
341
+ def addTable(self, name=UNSPECIFIED, data=UNSPECIFIED):
342
+ """
343
+ Add a new table to the Protocol Template.
344
+
345
+ Parameters
346
+ ----------
347
+ name (str)
348
+ The name of the table.
349
+ data (json)
350
+ The data of the table in json format.
351
+
352
+ Returns
353
+ -------
354
+ :class:`~labstep.entities.protocolTable.model.ProtocolTable`
355
+ The newly added table entity.
356
+
357
+ Example
358
+ -------
359
+ ::
360
+
361
+ data = {
362
+ "rowCount": 12,
363
+ "columnCount": 12,
364
+ "colHeaderData": {},
365
+ "data": {
366
+ "dataTable": {
367
+ 0: {
368
+ 0: {
369
+ "value": 'Cell A1'
370
+ },
371
+ 1: {
372
+ "value": 'Cell B1'
373
+ }
374
+ }
375
+ }
376
+ }
377
+ }
378
+
379
+ protocol_template = user.getProtocolTemplate(17000)
380
+ protocol_template.addTable(name='Calibration', data=data)
381
+ """
382
+ return self.getCurrentVersion().addTable(name=name, data=data)
383
+
384
+ def getTables(self):
385
+ """
386
+ Returns a list of the tables in a Protocol Template.
387
+
388
+ Returns
389
+ -------
390
+ List[:class:`~labstep.entities.protocolTable.model.ProtocolTable`]
391
+ List of the tables in a Protocol Template.
392
+
393
+ Example
394
+ -------
395
+ ::
396
+
397
+ protocol_template = user.getProtocolTemplate(17000)
398
+ protocol_template_tables = protocol_template.getTables()
399
+ """
400
+ return self.getCurrentVersion().getTables()
401
+
402
+ def addFile(self, filepath=UNSPECIFIED, rawData=UNSPECIFIED):
403
+ """
404
+ Add a file to a Protocol Template.
405
+
406
+ Parameters
407
+ ----------
408
+ filepath (str)
409
+ The path to the file to upload.
410
+
411
+ Returns
412
+ -------
413
+ :class:`~labstep.file.File`
414
+ The newly added file entity.
415
+
416
+ Example
417
+ -------
418
+ ::
419
+
420
+ protocol_template = user.getProtocolTemplate(17000)
421
+ protocol_template.addFile(filepath='./my_file.csv')
422
+ """
423
+ return self.getCurrentVersion().addFile(filepath=filepath, rawData=rawData)
424
+
425
+ def getFiles(self):
426
+ """
427
+ Returns a list of the files in a Protocol Template.
428
+
429
+ Returns
430
+ -------
431
+ List[:class:`~labstep.file.File`]
432
+ List of the files in a Protocol Template.
433
+
434
+ Example
435
+ -------
436
+ ::
437
+
438
+ protocol_template = user.getProtocolTemplate(17000)
439
+ protocol_template_files = protocol_template.getFiles()
440
+ """
441
+ return self.getCurrentVersion().getFiles()
442
+
443
+ def export(self, path):
444
+ """
445
+ Export the protocol template to the directory specified.
446
+
447
+ Parameters
448
+ -------
449
+ path (str)
450
+ The path to the directory to save the protocol template.
451
+
452
+ Example
453
+ -------
454
+ ::
455
+
456
+ protocol_template = user.getProtocolTemplate(17000)
457
+ protocol_template.export('/my_folder')
458
+ """
459
+ import labstep.entities.protocolTemplate.repository as protocolTemplateRepository
460
+
461
+ return protocolTemplateRepository.exportProtocolTemplate(self, path)
462
+
463
+ def getJupyterNotebooks(self, count=100):
464
+ """
465
+ Retrieve the Jupyter Notebooks attached to this Labstep Entity.
466
+
467
+ Returns
468
+ -------
469
+ List[:class:`~labstep.entities.jupyterNotebook.model.JupyterNotebook`]
470
+ List of the Jupyter Notebooks attached.
471
+
472
+ Example
473
+ -------
474
+ ::
475
+
476
+ protocol_template = user.getProtocolTemplate(17000)
477
+ jupyter_notebooks = protocol_template.getJupyterNotebooks()
478
+ print(jupyter_notebooks[0])
479
+ """
480
+ return self.getCurrentVersion().getJupyterNotebooks()
481
+
482
+ def addJupyterNotebook(self, name=UNSPECIFIED, data=UNSPECIFIED):
483
+ """
484
+ Add a Jupyter Notebook to a protocol template entry.
485
+
486
+ Parameters
487
+ ----------
488
+ name (str)
489
+ Name of Jupyter Notebook
490
+ data (JSON)
491
+ JSON Jupyter Notebook structure
492
+
493
+ Returns
494
+ -------
495
+ :class:`~labstep.entities.jupyterNotebook.model.JupyterNotebook`
496
+ The newly added file entity.
497
+
498
+ Example
499
+ -------
500
+ ::
501
+
502
+ protocol_template = user.getProtocolTemplate(17000)
503
+ protocol_template.addJupyterNotebook()
504
+ """
505
+ return self.getCurrentVersion().addJupyterNotebook(name=name, data=data)
506
+
507
+ def addConditions(self, number_of_conditions):
508
+ """
509
+ Add conditions to the protocol template
510
+ Parameters
511
+ ----------
512
+ number_of_conditions (int)
513
+ The number of conditions to add
514
+ Returns
515
+ -------
516
+ List[:class:`~labstep.entities.protocolCondition.model.ProtocolCondition`]
517
+ A list of the protocol conditions added to the protocol template.
518
+ Example
519
+ -------
520
+ ::
521
+
522
+ protocol_template = user.getProtocolTemplate(17000)
523
+ conditions = protocol_template.addConditions(5)
524
+ """
525
+ if not self.draft_version:
526
+ raise ValueError("Cannot add conditions to a protocol template that is not in draft state. Please create a new version first.")
527
+
528
+ return self.draft_version.addConditions(number_of_conditions)
529
+
530
+
531
+ def getVersions(self):
532
+ """
533
+ Retrieve a list of the different versions associated with this protocol template.
534
+ Returns
535
+ -------
536
+ List[:class:`~labstep.entities.protocolVersion.model.ProtocolVersion`]
537
+ A list of the protocol versions associated with the protocol template.
538
+ Example
539
+ -------
540
+ ::
541
+
542
+ protocol_template = user.getProtocolTemplate(17000)
543
+ versions = protocol_template.getVersions()
544
+ """
545
+ from labstep.generic.entity.repository import getEntities
546
+
547
+
548
+ return getEntities(self.__user__, ProtocolVersion, UNSPECIFIED,filterParams={"protocol_collection_id": self.id})
549
+
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # Author: Labstep <dev@labstep.com>
4
+
5
+ import labstep.generic.entity.repository as entityRepository
6
+ from labstep.constants import UNSPECIFIED
7
+ from labstep.entities.protocolTemplate.model import ProtocolTemplate
8
+ from labstep.entities.protocolVersion.model import ProtocolVersion
9
+ from labstep.service.helpers import handleDate
10
+
11
+ def getProtocolTemplate(user, protocol_template_id):
12
+ return entityRepository.getEntity(user, ProtocolTemplate, id=protocol_template_id)
13
+
14
+
15
+ def getProtocolTemplates(
16
+ user,
17
+ count=UNSPECIFIED,
18
+ search_query=UNSPECIFIED,
19
+ created_at_from=UNSPECIFIED,
20
+ created_at_to=UNSPECIFIED,
21
+ extraParams={},
22
+ ):
23
+ params = {
24
+ "search_query": search_query,
25
+ "created_at_from": handleDate(created_at_from),
26
+ "created_at_to": handleDate(created_at_to),
27
+ "is_template": True, # Filter to only get protocol templates
28
+ **extraParams,
29
+ }
30
+ return entityRepository.getEntities(user, ProtocolTemplate, count, params)
31
+
32
+
33
+ def newProtocolTemplate(user, name, extraParams={}):
34
+ params = {"name": name, **extraParams, "is_template": True}
35
+ return entityRepository.newEntity(user, ProtocolTemplate, params)
36
+
37
+
38
+ def editProtocolTemplate(
39
+ protocol_template, name=UNSPECIFIED, body=UNSPECIFIED, deleted_at=UNSPECIFIED, extraParams={}
40
+ ):
41
+ params = {"name": name, "deleted_at": deleted_at, **extraParams}
42
+
43
+ if body is not UNSPECIFIED:
44
+ entityRepository.editEntity(protocol_template.getCurrentVersion(), {"state": body})
45
+ protocol_template.update()
46
+
47
+ return entityRepository.editEntity(protocol_template, params)
48
+
49
+
50
+ def exportProtocolTemplate(protocol_template, root_path):
51
+
52
+ protocol_template.update()
53
+
54
+ expDir = entityRepository.exportEntity(protocol_template, root_path)
55
+
56
+ # export latest version
57
+ protocol_template.last_version.export(expDir)
58
+
59
+ # export notes
60
+ notesDir = expDir.joinpath('notes')
61
+ notes = protocol_template.getComments(count=UNSPECIFIED)
62
+
63
+ for note in notes:
64
+ note.export(notesDir)