idmtools 0.0.0.dev0__py3-none-any.whl → 0.0.3__py3-none-any.whl

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 (118) hide show
  1. idmtools/__init__.py +27 -8
  2. idmtools/analysis/__init__.py +5 -0
  3. idmtools/analysis/add_analyzer.py +89 -0
  4. idmtools/analysis/analyze_manager.py +490 -0
  5. idmtools/analysis/csv_analyzer.py +103 -0
  6. idmtools/analysis/download_analyzer.py +96 -0
  7. idmtools/analysis/map_worker_entry.py +100 -0
  8. idmtools/analysis/platform_analysis_bootstrap.py +94 -0
  9. idmtools/analysis/platform_anaylsis.py +291 -0
  10. idmtools/analysis/tags_analyzer.py +93 -0
  11. idmtools/assets/__init__.py +9 -0
  12. idmtools/assets/asset.py +453 -0
  13. idmtools/assets/asset_collection.py +514 -0
  14. idmtools/assets/content_handlers.py +19 -0
  15. idmtools/assets/errors.py +23 -0
  16. idmtools/assets/file_list.py +191 -0
  17. idmtools/builders/__init__.py +11 -0
  18. idmtools/builders/arm_simulation_builder.py +152 -0
  19. idmtools/builders/csv_simulation_builder.py +76 -0
  20. idmtools/builders/simulation_builder.py +348 -0
  21. idmtools/builders/sweep_arm.py +109 -0
  22. idmtools/builders/yaml_simulation_builder.py +82 -0
  23. idmtools/config/__init__.py +7 -0
  24. idmtools/config/idm_config_parser.py +486 -0
  25. idmtools/core/__init__.py +10 -0
  26. idmtools/core/cache_enabled.py +114 -0
  27. idmtools/core/context.py +68 -0
  28. idmtools/core/docker_task.py +207 -0
  29. idmtools/core/enums.py +51 -0
  30. idmtools/core/exceptions.py +91 -0
  31. idmtools/core/experiment_factory.py +71 -0
  32. idmtools/core/id_file.py +70 -0
  33. idmtools/core/interfaces/__init__.py +5 -0
  34. idmtools/core/interfaces/entity_container.py +64 -0
  35. idmtools/core/interfaces/iassets_enabled.py +58 -0
  36. idmtools/core/interfaces/ientity.py +331 -0
  37. idmtools/core/interfaces/iitem.py +206 -0
  38. idmtools/core/interfaces/imetadata_operations.py +89 -0
  39. idmtools/core/interfaces/inamed_entity.py +17 -0
  40. idmtools/core/interfaces/irunnable_entity.py +159 -0
  41. idmtools/core/logging.py +387 -0
  42. idmtools/core/platform_factory.py +316 -0
  43. idmtools/core/system_information.py +104 -0
  44. idmtools/core/task_factory.py +145 -0
  45. idmtools/entities/__init__.py +10 -0
  46. idmtools/entities/command_line.py +229 -0
  47. idmtools/entities/command_task.py +155 -0
  48. idmtools/entities/experiment.py +787 -0
  49. idmtools/entities/generic_workitem.py +43 -0
  50. idmtools/entities/ianalyzer.py +163 -0
  51. idmtools/entities/iplatform.py +1106 -0
  52. idmtools/entities/iplatform_default.py +39 -0
  53. idmtools/entities/iplatform_ops/__init__.py +5 -0
  54. idmtools/entities/iplatform_ops/iplatform_asset_collection_operations.py +148 -0
  55. idmtools/entities/iplatform_ops/iplatform_experiment_operations.py +415 -0
  56. idmtools/entities/iplatform_ops/iplatform_simulation_operations.py +315 -0
  57. idmtools/entities/iplatform_ops/iplatform_suite_operations.py +322 -0
  58. idmtools/entities/iplatform_ops/iplatform_workflowitem_operations.py +301 -0
  59. idmtools/entities/iplatform_ops/utils.py +185 -0
  60. idmtools/entities/itask.py +316 -0
  61. idmtools/entities/iworkflow_item.py +167 -0
  62. idmtools/entities/platform_requirements.py +20 -0
  63. idmtools/entities/relation_type.py +14 -0
  64. idmtools/entities/simulation.py +255 -0
  65. idmtools/entities/suite.py +188 -0
  66. idmtools/entities/task_proxy.py +37 -0
  67. idmtools/entities/templated_simulation.py +325 -0
  68. idmtools/frozen/frozen_dict.py +71 -0
  69. idmtools/frozen/frozen_list.py +66 -0
  70. idmtools/frozen/frozen_set.py +86 -0
  71. idmtools/frozen/frozen_tuple.py +18 -0
  72. idmtools/frozen/frozen_utils.py +179 -0
  73. idmtools/frozen/ifrozen.py +66 -0
  74. idmtools/plugins/__init__.py +5 -0
  75. idmtools/plugins/git_commit.py +117 -0
  76. idmtools/registry/__init__.py +4 -0
  77. idmtools/registry/experiment_specification.py +105 -0
  78. idmtools/registry/functions.py +28 -0
  79. idmtools/registry/hook_specs.py +132 -0
  80. idmtools/registry/master_plugin_registry.py +51 -0
  81. idmtools/registry/platform_specification.py +138 -0
  82. idmtools/registry/plugin_specification.py +129 -0
  83. idmtools/registry/task_specification.py +104 -0
  84. idmtools/registry/utils.py +119 -0
  85. idmtools/services/__init__.py +5 -0
  86. idmtools/services/ipersistance_service.py +135 -0
  87. idmtools/services/platforms.py +13 -0
  88. idmtools/utils/__init__.py +5 -0
  89. idmtools/utils/caller.py +24 -0
  90. idmtools/utils/collections.py +246 -0
  91. idmtools/utils/command_line.py +45 -0
  92. idmtools/utils/decorators.py +300 -0
  93. idmtools/utils/display/__init__.py +22 -0
  94. idmtools/utils/display/displays.py +181 -0
  95. idmtools/utils/display/settings.py +25 -0
  96. idmtools/utils/dropbox_location.py +30 -0
  97. idmtools/utils/entities.py +127 -0
  98. idmtools/utils/file.py +72 -0
  99. idmtools/utils/file_parser.py +151 -0
  100. idmtools/utils/filter_simulations.py +182 -0
  101. idmtools/utils/filters/__init__.py +5 -0
  102. idmtools/utils/filters/asset_filters.py +88 -0
  103. idmtools/utils/general.py +286 -0
  104. idmtools/utils/gitrepo.py +336 -0
  105. idmtools/utils/hashing.py +239 -0
  106. idmtools/utils/info.py +124 -0
  107. idmtools/utils/json.py +82 -0
  108. idmtools/utils/language.py +107 -0
  109. idmtools/utils/local_os.py +40 -0
  110. idmtools/utils/time.py +22 -0
  111. idmtools-0.0.3.dist-info/METADATA +120 -0
  112. idmtools-0.0.3.dist-info/RECORD +116 -0
  113. idmtools-0.0.3.dist-info/entry_points.txt +9 -0
  114. idmtools-0.0.3.dist-info/licenses/LICENSE.TXT +3 -0
  115. idmtools-0.0.0.dev0.dist-info/METADATA +0 -41
  116. idmtools-0.0.0.dev0.dist-info/RECORD +0 -5
  117. {idmtools-0.0.0.dev0.dist-info → idmtools-0.0.3.dist-info}/WHEEL +0 -0
  118. {idmtools-0.0.0.dev0.dist-info → idmtools-0.0.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,39 @@
1
+ """
2
+
3
+ Here we define platform default interface.
4
+
5
+ Currently we use this for defaults in analyzer manager, but later we can extend to other default that need to be used lazily
6
+
7
+ Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
8
+ """
9
+ import os
10
+ from dataclasses import dataclass, field
11
+
12
+
13
+ @dataclass
14
+ class IPlatformDefault:
15
+ """
16
+
17
+ Represents default configuration for different types.
18
+ """
19
+ pass
20
+
21
+
22
+ def default_cpu_count():
23
+ """
24
+
25
+ Default value for cpu count. We have to wrap this so it doesn't load during plugin init.
26
+
27
+ Returns:
28
+ Default cpu count
29
+ """
30
+ from idmtools import IdmConfigParser
31
+ return int(IdmConfigParser().get_option('COMMON', 'max_workers', os.cpu_count()))
32
+
33
+
34
+ @dataclass
35
+ class AnalyzerManagerPlatformDefault(IPlatformDefault):
36
+ """
37
+ Represents defaults for the AnalyzerManager.
38
+ """
39
+ max_workers: int = field(default_factory=default_cpu_count)
@@ -0,0 +1,5 @@
1
+ """
2
+ Defines all the platform operation interfaces.
3
+
4
+ Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
5
+ """
@@ -0,0 +1,148 @@
1
+ """
2
+ IPlatformAssetCollectionOperations defines asset collection operations interface.
3
+
4
+ Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
5
+ """
6
+ from abc import ABC, abstractmethod
7
+ from dataclasses import dataclass
8
+ from logging import DEBUG, getLogger
9
+ from typing import Any, List, Type, NoReturn, TYPE_CHECKING
10
+ from idmtools.assets import AssetCollection
11
+ from idmtools.core import CacheEnabled
12
+ from idmtools.entities.iplatform_ops.utils import batch_create_items
13
+ from idmtools.registry.functions import FunctionPluginManager
14
+
15
+ if TYPE_CHECKING: # pragma: no cover
16
+ from idmtools.entities.iplatform import IPlatform
17
+ logger = getLogger(__name__)
18
+
19
+
20
+ @dataclass
21
+ class IPlatformAssetCollectionOperations(CacheEnabled, ABC):
22
+ """
23
+ IPlatformAssetCollectionOperations defines asset collection operations interface.
24
+ """
25
+ platform: 'IPlatform' # noqa: F821
26
+ platform_type: Type
27
+
28
+ def pre_create(self, asset_collection: AssetCollection, **kwargs) -> NoReturn:
29
+ """
30
+ Run the platform/AssetCollection post creation events.
31
+
32
+ Args:
33
+ asset_collection: AssetCollection to run post-creation events
34
+ **kwargs: Optional arguments mainly for extensibility
35
+
36
+ Returns:
37
+ NoReturn
38
+ """
39
+ if logger.isEnabledFor(DEBUG):
40
+ logger.debug("Calling idmtools_platform_pre_create_item")
41
+ FunctionPluginManager.instance().hook.idmtools_platform_pre_create_item(item=asset_collection, kwargs=kwargs)
42
+ if logger.isEnabledFor(DEBUG):
43
+ logger.debug("Calling pre_creation")
44
+ asset_collection.pre_creation(self.platform)
45
+
46
+ def post_create(self, asset_collection: AssetCollection, **kwargs) -> NoReturn:
47
+ """
48
+ Run the platform/AssetCollection post creation events.
49
+
50
+ Args:
51
+ asset_collection: AssetCollection to run post-creation events
52
+ **kwargs: Optional arguments mainly for extensibility
53
+
54
+ Returns:
55
+ NoReturn
56
+ """
57
+ if logger.isEnabledFor(DEBUG):
58
+ logger.debug("Calling idmtools_platform_post_create_item hooks")
59
+ FunctionPluginManager.instance().hook.idmtools_platform_post_create_item(item=asset_collection, kwargs=kwargs)
60
+ if logger.isEnabledFor(DEBUG):
61
+ logger.debug("Calling post_creation")
62
+ asset_collection.post_creation(self.platform)
63
+
64
+ def create(self, asset_collection: AssetCollection, do_pre: bool = True, do_post: bool = True, **kwargs) -> Any:
65
+ """
66
+ Creates an AssetCollection from an IDMTools AssetCollection object.
67
+
68
+ Also performs pre-creation and post-creation locally and on platform.
69
+
70
+ Args:
71
+ asset_collection: AssetCollection to create
72
+ do_pre: Perform Pre creation events for item
73
+ do_post: Perform Post creation events for item
74
+ **kwargs: Optional arguments mainly for extensibility
75
+
76
+ Returns:
77
+ Created platform item and the id of said item
78
+ """
79
+ if asset_collection.status is not None:
80
+ return asset_collection._platform_object
81
+ if do_pre:
82
+ if logger.isEnabledFor(DEBUG):
83
+ logger.debug("Calling pre_create")
84
+ self.pre_create(asset_collection, **kwargs)
85
+ if logger.isEnabledFor(DEBUG):
86
+ logger.debug("Calling platform_create")
87
+ ret = self.platform_create(asset_collection, **kwargs)
88
+ if do_post:
89
+ if logger.isEnabledFor(DEBUG):
90
+ logger.debug("Calling post_create")
91
+ self.post_create(asset_collection, **kwargs)
92
+ return ret
93
+
94
+ @abstractmethod
95
+ def platform_create(self, asset_collection: AssetCollection, **kwargs) -> Any:
96
+ """
97
+ Creates an workflow_item from an IDMTools AssetCollection object.
98
+
99
+ Args:
100
+ asset_collection: AssetCollection to create
101
+ **kwargs: Optional arguments mainly for extensibility
102
+
103
+ Returns:
104
+ Created platform item and the id of said item
105
+ """
106
+ pass
107
+
108
+ def batch_create(self, asset_collections: List[AssetCollection], display_progress: bool = True, **kwargs) -> \
109
+ List[AssetCollection]:
110
+ """
111
+ Provides a method to batch create asset collections items.
112
+
113
+ Args:
114
+ asset_collections: List of asset collection items to create
115
+ display_progress: Show progress bar
116
+ **kwargs:
117
+
118
+ Returns:
119
+ List of tuples containing the create object and id of item that was created
120
+ """
121
+ return batch_create_items(asset_collections, create_func=self.create, display_progress=display_progress,
122
+ progress_description="Uploading Assets", unit="asset collection", **kwargs)
123
+
124
+ @abstractmethod
125
+ def get(self, asset_collection_id: str, **kwargs) -> Any:
126
+ """
127
+ Returns the platform representation of an AssetCollection.
128
+
129
+ Args:
130
+ asset_collection_id: Item id of AssetCollection
131
+ **kwargs:
132
+
133
+ Returns:
134
+ Platform Representation of an AssetCollection
135
+ """
136
+ pass
137
+
138
+ def to_entity(self, asset_collection: Any, **kwargs) -> AssetCollection:
139
+ """
140
+ Converts the platform representation of AssetCollection to idmtools representation.
141
+
142
+ Args:
143
+ asset_collection: Platform AssetCollection object
144
+
145
+ Returns:
146
+ IDMTools suite object
147
+ """
148
+ return asset_collection
@@ -0,0 +1,415 @@
1
+ """
2
+ IPlatformExperimentOperations defines experiment item operations interface.
3
+
4
+ Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
5
+ """
6
+ from abc import ABC, abstractmethod
7
+ from concurrent.futures import as_completed
8
+ from concurrent.futures.thread import ThreadPoolExecutor
9
+ from dataclasses import dataclass
10
+ from logging import getLogger, DEBUG
11
+ from types import GeneratorType
12
+ from typing import Type, Any, NoReturn, Tuple, List, Dict, Iterator, Union, TYPE_CHECKING
13
+
14
+ from idmtools.assets import Asset
15
+ from idmtools.core.enums import EntityStatus, ItemType
16
+ from idmtools.entities.experiment import Experiment
17
+ from idmtools.entities.iplatform_ops.utils import batch_create_items
18
+ from idmtools.registry.functions import FunctionPluginManager
19
+
20
+ logger = getLogger(__name__)
21
+ if TYPE_CHECKING: # pragma: no cover
22
+ from idmtools.entities.iplatform import IPlatform
23
+
24
+
25
+ @dataclass
26
+ class IPlatformExperimentOperations(ABC):
27
+ """
28
+ IPlatformExperimentOperations defines experiments item operations interface.
29
+ """
30
+ platform: 'IPlatform' # noqa: F821
31
+ platform_type: Type
32
+
33
+ @abstractmethod
34
+ def get(self, experiment_id: str, **kwargs) -> Any:
35
+ """
36
+ Returns the platform representation of an Experiment.
37
+
38
+ Args:
39
+ experiment_id: Item id of Experiments
40
+ **kwargs:
41
+
42
+ Returns:
43
+ Platform Representation of an experiment
44
+ """
45
+ pass
46
+
47
+ def pre_create(self, experiment: Experiment, **kwargs) -> NoReturn:
48
+ """
49
+ Run the platform/experiment post creation events.
50
+
51
+ Args:
52
+ experiment: Experiment to run post-creation events
53
+ **kwargs: Optional arguments mainly for extensibility
54
+
55
+ Returns:
56
+ NoReturn
57
+ """
58
+ if logger.isEnabledFor(DEBUG):
59
+ logger.debug("Calling idmtools_platform_pre_create_item hooks")
60
+ FunctionPluginManager.instance().hook.idmtools_platform_pre_create_item(item=experiment, kwargs=kwargs)
61
+ if logger.isEnabledFor(DEBUG):
62
+ logger.debug("Calling experiment pre_creation")
63
+ experiment.pre_creation(self.platform)
64
+
65
+ def post_create(self, experiment: Experiment, **kwargs) -> NoReturn:
66
+ """
67
+ Run the platform/experiment post creation events.
68
+
69
+ Args:
70
+ experiment: Experiment to run post-creation events
71
+ **kwargs: Optional arguments mainly for extensibility
72
+
73
+ Returns:
74
+ NoReturn
75
+ """
76
+ if logger.isEnabledFor(DEBUG):
77
+ logger.debug("Calling idmtools_platform_post_create_item hooks")
78
+ FunctionPluginManager.instance().hook.idmtools_platform_post_create_item(item=experiment, kwargs=kwargs)
79
+ if logger.isEnabledFor(DEBUG):
80
+ logger.debug("Calling experiment post_creation")
81
+ experiment.post_creation(self.platform)
82
+
83
+ def create(self, experiment: Experiment, do_pre: bool = True, do_post: bool = True, **kwargs) -> Union[Experiment]:
84
+ """
85
+ Creates an experiment from an IDMTools simulation object.
86
+
87
+ Also performs local/platform pre and post creation events.
88
+
89
+ Args:
90
+ experiment: Experiment to create
91
+ do_pre: Perform Pre creation events for item
92
+ do_post: Perform Post creation events for item
93
+ **kwargs: Optional arguments mainly for extensibility
94
+
95
+ Returns:
96
+ Created platform item and the id of said item
97
+ """
98
+ if experiment.status is not None:
99
+ if logger.isEnabledFor(DEBUG):
100
+ logger.debug("Calling experiment platform_modify_experiment")
101
+ experiment = self.platform_modify_experiment(experiment, **kwargs)
102
+ if logger.isEnabledFor(DEBUG):
103
+ logger.debug("Finished platform_modify_experiment")
104
+ return experiment
105
+ if do_pre:
106
+ self.pre_create(experiment, **kwargs)
107
+ if logger.isEnabledFor(DEBUG):
108
+ logger.debug("Finished pre_create")
109
+ if logger.isEnabledFor(DEBUG):
110
+ logger.debug("Calling platform_create")
111
+ experiment._platform_object = self.platform_create(experiment, **kwargs)
112
+ if logger.isEnabledFor(DEBUG):
113
+ logger.debug("Finished platform_create")
114
+ experiment.platform = self.platform
115
+ if do_post:
116
+ self.post_create(experiment, **kwargs)
117
+ if logger.isEnabledFor(DEBUG):
118
+ logger.debug("Finished post_create")
119
+ return experiment
120
+
121
+ @abstractmethod
122
+ def platform_create(self, experiment: Experiment, **kwargs) -> Any:
123
+ """
124
+ Creates an experiment from an IDMTools experiment object.
125
+
126
+ Args:
127
+ experiment: Experiment to create
128
+ **kwargs: Optional arguments mainly for extensibility
129
+
130
+ Returns:
131
+ Created platform item and the id of said item
132
+ """
133
+ pass
134
+
135
+ def batch_create(self, experiments: List[Experiment], display_progress: bool = True, **kwargs) -> List[Tuple[Experiment]]:
136
+ """
137
+ Provides a method to batch create experiments.
138
+
139
+ Args:
140
+ experiments: List of experiments to create
141
+ display_progress: Show progress bar
142
+ **kwargs: Keyword arguments to pass to the batch
143
+
144
+ Returns:
145
+ List of tuples containing the create object and id of item that was created
146
+ """
147
+ return batch_create_items(experiments, create_func=self.create, display_progress=display_progress,
148
+ progress_description="Creating Experiments", unit="experiment",
149
+ **kwargs)
150
+
151
+ @abstractmethod
152
+ def get_children(self, experiment: Any, **kwargs) -> List[Any]:
153
+ """
154
+ Returns the children of an experiment object.
155
+
156
+ Args:
157
+ experiment: Experiment object
158
+ **kwargs: Optional arguments mainly for extensibility
159
+
160
+ Returns:
161
+ Children of experiment object
162
+ """
163
+ pass
164
+
165
+ @abstractmethod
166
+ def get_parent(self, experiment: Any, **kwargs) -> Any:
167
+ """
168
+ Returns the parent of item. If the platform doesn't support parents, you should throw a TopLevelItem error.
169
+
170
+ Args:
171
+ experiment: Experiment to get parent from
172
+ **kwargs:
173
+
174
+ Returns:
175
+ Parent of Experiment(Suite)
176
+
177
+ Raise:
178
+ TopLevelItem
179
+ """
180
+ pass
181
+
182
+ def to_entity(self, experiment: Any, **kwargs) -> Experiment:
183
+ """
184
+ Converts the platform representation of experiment to idmtools representation.
185
+
186
+ Args:
187
+ experiment:Platform experiment object
188
+
189
+ Returns:
190
+ IDMTools experiment object
191
+ """
192
+ return experiment
193
+
194
+ def pre_run_item(self, experiment: Experiment, **kwargs):
195
+ """
196
+ Trigger right before commissioning experiment on platform.
197
+
198
+ This ensures that the item is created. It also ensures that the children(simulations) have also been created.
199
+
200
+ Args:
201
+ experiment: Experiment to commission
202
+
203
+ Returns:
204
+ None
205
+
206
+ Raises:
207
+ ValueError - If there are no simulations
208
+ """
209
+ if logger.isEnabledFor(DEBUG):
210
+ logger.debug("Calling pre_run")
211
+ experiment.pre_run(self.platform)
212
+ # ensure the item is created before running
213
+ if experiment.status is None:
214
+ if logger.isEnabledFor(DEBUG):
215
+ logger.debug("Calling create")
216
+ self.create(experiment, **kwargs)
217
+ else:
218
+ if logger.isEnabledFor(DEBUG):
219
+ logger.debug("Calling platform_modify_experiment")
220
+ experiment = self.platform_modify_experiment(experiment, **kwargs)
221
+
222
+ # check sims
223
+ if logger.isEnabledFor(DEBUG):
224
+ logger.debug("Ensuring simulations exist")
225
+ if isinstance(experiment.simulations, (GeneratorType, Iterator)):
226
+ if logger.isEnabledFor(DEBUG):
227
+ logger.debug("Calling _create_items_of_type for sims")
228
+ experiment.simulations = self.platform._create_items_of_type(experiment.simulations, ItemType.SIMULATION,
229
+ **kwargs)
230
+ elif len(experiment.simulations) == 0:
231
+ raise ValueError("You cannot have an experiment with no simulations")
232
+ else:
233
+ if logger.isEnabledFor(DEBUG):
234
+ logger.debug("Calling _create_items_of_type for sims")
235
+ experiment.simulations = self.platform._create_items_of_type(experiment.simulations, ItemType.SIMULATION,
236
+ **kwargs)
237
+ if logger.isEnabledFor(DEBUG):
238
+ logger.debug("Finished checking simulations")
239
+
240
+ def post_run_item(self, experiment: Experiment, **kwargs):
241
+ """
242
+ Trigger right after commissioning experiment on platform.
243
+
244
+ Args:
245
+ experiment: Experiment just commissioned
246
+
247
+ Returns:
248
+ None
249
+ """
250
+ if logger.isEnabledFor(DEBUG):
251
+ logger.debug("Calling idmtools_platform_post_run hooks")
252
+ FunctionPluginManager.instance().hook.idmtools_platform_post_run(item=experiment, kwargs=kwargs)
253
+ experiment.post_run(self.platform)
254
+
255
+ def run_item(self, experiment: Experiment, **kwargs):
256
+ """
257
+ Called during commissioning of an item. This should create the remote resource.
258
+
259
+ Args:
260
+ experiment:Experiment
261
+ **kwargs: Keyword arguments to pass to pre_run_item, platform_run_item, post_run_item
262
+
263
+ Returns:
264
+ None
265
+ """
266
+ if logger.isEnabledFor(DEBUG):
267
+ logger.debug("Calling pre_run_item")
268
+ self.pre_run_item(experiment, **kwargs)
269
+ if experiment.status not in [EntityStatus.FAILED, EntityStatus.SUCCEEDED]:
270
+ if logger.isEnabledFor(DEBUG):
271
+ logger.debug("Calling platform_run_item")
272
+ self.platform_run_item(experiment, **kwargs)
273
+ if logger.isEnabledFor(DEBUG):
274
+ logger.debug("Calling post_run_item")
275
+ self.post_run_item(experiment, **kwargs)
276
+
277
+ @abstractmethod
278
+ def platform_run_item(self, experiment: Experiment, **kwargs):
279
+ """
280
+ Called during commissioning of an item. This should perform what is needed to commission job on platform.
281
+
282
+ Args:
283
+ experiment:
284
+
285
+ Returns:
286
+ None
287
+ """
288
+ pass
289
+
290
+ @abstractmethod
291
+ def send_assets(self, experiment: Any, **kwargs):
292
+ """
293
+ Transfer Experiment assets to the platform.
294
+
295
+ Args:
296
+ experiment: Experiment to send assets for
297
+
298
+ Returns:
299
+ None
300
+ """
301
+ pass
302
+
303
+ @abstractmethod
304
+ def refresh_status(self, experiment: Experiment, **kwargs):
305
+ """
306
+ Refresh status for experiment object.
307
+
308
+ This should update the object directly. For experiments it is best if all simulation states are updated as well.
309
+
310
+ Args:
311
+ experiment: Experiment to get status for
312
+
313
+ Returns:
314
+ None
315
+ """
316
+ pass
317
+
318
+ def get_assets(self, experiment: Experiment, files: List[str], **kwargs) -> Dict[str, Dict[str, bytearray]]:
319
+ """
320
+ Get files from experiment.
321
+
322
+ Args:
323
+ experiment: Experiment to get files from
324
+ files: List files
325
+ **kwargs:
326
+
327
+ Returns:
328
+ Dict with each sim id and the files contents matching specified list
329
+ """
330
+ ret = dict()
331
+ for sim in experiment.simulations:
332
+ ret[sim.uid] = self.platform._simulations.get_assets(sim, files, **kwargs)
333
+ return ret
334
+
335
+ def list_assets(self, experiment: Experiment, children: bool = False, **kwargs) -> List[Asset]:
336
+ """
337
+ List available assets for a experiment.
338
+
339
+ Args:
340
+ experiment: Experiment to list files for
341
+ children: Should we load assets from children as well?
342
+
343
+ Returns:
344
+ List of Assets
345
+ """
346
+ ret = self.platform_list_asset(experiment, **kwargs)
347
+ if children:
348
+ with ThreadPoolExecutor() as pool:
349
+ futures = dict()
350
+ for sim in experiment.simulations:
351
+ future = pool.submit(self.platform._simulations.list_assets, sim, **kwargs)
352
+ futures[future] = sim
353
+
354
+ for future in as_completed(futures):
355
+ result = future.result()
356
+ ret.extend(result)
357
+ return ret
358
+
359
+ def platform_list_asset(self, experiment: Experiment, **kwargs) -> List[Asset]:
360
+ """
361
+ List the assets on an experiment.
362
+
363
+ Args:
364
+ experiment: Experiment to list.
365
+ **kwargs: Extra Arguments
366
+
367
+ Returns:
368
+ List of Assets
369
+ """
370
+ return []
371
+
372
+ def platform_modify_experiment(self, experiment: Experiment, regather_common_assets: bool = False,
373
+ **kwargs) -> Experiment:
374
+ """
375
+ API to allow detection of experiments already created.
376
+
377
+ Args:
378
+ experiment:
379
+ regather_common_assets: When modifying, should we gather assets from template/simulations. It is important to note that when using this feature, ensure the previous simulations have finished provisioning. Failure to do so can lead to unexpected behaviour
380
+
381
+ Returns:
382
+ Experiment updated
383
+ """
384
+ return experiment
385
+
386
+ def create_sim_directory_map(self, experiment_id: str) -> Dict:
387
+ """
388
+ Build simulation working directory mapping.
389
+ Args:
390
+ experiment_id: experiment id
391
+
392
+ Returns:
393
+ Dict
394
+ """
395
+ return {}
396
+
397
+ def platform_delete(self, experiment_id: str) -> None:
398
+ """
399
+ Delete platform experiment.
400
+ Args:
401
+ experiment_id: experiment id
402
+ Returns:
403
+ None
404
+ """
405
+ pass
406
+
407
+ def platform_cancel(self, experiment_id: str) -> None:
408
+ """
409
+ Cancel platform experiment.
410
+ Args:
411
+ experiment_id: experiment id
412
+ Returns:
413
+ None
414
+ """
415
+ pass