idmtools 0.0.0.dev0__py3-none-any.whl → 0.0.2__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.
- idmtools/__init__.py +27 -8
- idmtools/analysis/__init__.py +5 -0
- idmtools/analysis/add_analyzer.py +89 -0
- idmtools/analysis/analyze_manager.py +490 -0
- idmtools/analysis/csv_analyzer.py +103 -0
- idmtools/analysis/download_analyzer.py +96 -0
- idmtools/analysis/map_worker_entry.py +100 -0
- idmtools/analysis/platform_analysis_bootstrap.py +94 -0
- idmtools/analysis/platform_anaylsis.py +291 -0
- idmtools/analysis/tags_analyzer.py +93 -0
- idmtools/assets/__init__.py +9 -0
- idmtools/assets/asset.py +453 -0
- idmtools/assets/asset_collection.py +514 -0
- idmtools/assets/content_handlers.py +19 -0
- idmtools/assets/errors.py +23 -0
- idmtools/assets/file_list.py +191 -0
- idmtools/builders/__init__.py +11 -0
- idmtools/builders/arm_simulation_builder.py +152 -0
- idmtools/builders/csv_simulation_builder.py +76 -0
- idmtools/builders/simulation_builder.py +348 -0
- idmtools/builders/sweep_arm.py +109 -0
- idmtools/builders/yaml_simulation_builder.py +82 -0
- idmtools/config/__init__.py +7 -0
- idmtools/config/idm_config_parser.py +486 -0
- idmtools/core/__init__.py +10 -0
- idmtools/core/cache_enabled.py +114 -0
- idmtools/core/context.py +68 -0
- idmtools/core/docker_task.py +207 -0
- idmtools/core/enums.py +51 -0
- idmtools/core/exceptions.py +91 -0
- idmtools/core/experiment_factory.py +71 -0
- idmtools/core/id_file.py +70 -0
- idmtools/core/interfaces/__init__.py +5 -0
- idmtools/core/interfaces/entity_container.py +64 -0
- idmtools/core/interfaces/iassets_enabled.py +58 -0
- idmtools/core/interfaces/ientity.py +331 -0
- idmtools/core/interfaces/iitem.py +206 -0
- idmtools/core/interfaces/imetadata_operations.py +89 -0
- idmtools/core/interfaces/inamed_entity.py +17 -0
- idmtools/core/interfaces/irunnable_entity.py +159 -0
- idmtools/core/logging.py +387 -0
- idmtools/core/platform_factory.py +316 -0
- idmtools/core/system_information.py +104 -0
- idmtools/core/task_factory.py +145 -0
- idmtools/entities/__init__.py +10 -0
- idmtools/entities/command_line.py +229 -0
- idmtools/entities/command_task.py +155 -0
- idmtools/entities/experiment.py +787 -0
- idmtools/entities/generic_workitem.py +43 -0
- idmtools/entities/ianalyzer.py +163 -0
- idmtools/entities/iplatform.py +1106 -0
- idmtools/entities/iplatform_default.py +39 -0
- idmtools/entities/iplatform_ops/__init__.py +5 -0
- idmtools/entities/iplatform_ops/iplatform_asset_collection_operations.py +148 -0
- idmtools/entities/iplatform_ops/iplatform_experiment_operations.py +415 -0
- idmtools/entities/iplatform_ops/iplatform_simulation_operations.py +315 -0
- idmtools/entities/iplatform_ops/iplatform_suite_operations.py +322 -0
- idmtools/entities/iplatform_ops/iplatform_workflowitem_operations.py +301 -0
- idmtools/entities/iplatform_ops/utils.py +185 -0
- idmtools/entities/itask.py +316 -0
- idmtools/entities/iworkflow_item.py +167 -0
- idmtools/entities/platform_requirements.py +20 -0
- idmtools/entities/relation_type.py +14 -0
- idmtools/entities/simulation.py +255 -0
- idmtools/entities/suite.py +188 -0
- idmtools/entities/task_proxy.py +37 -0
- idmtools/entities/templated_simulation.py +325 -0
- idmtools/frozen/frozen_dict.py +71 -0
- idmtools/frozen/frozen_list.py +66 -0
- idmtools/frozen/frozen_set.py +86 -0
- idmtools/frozen/frozen_tuple.py +18 -0
- idmtools/frozen/frozen_utils.py +179 -0
- idmtools/frozen/ifrozen.py +66 -0
- idmtools/plugins/__init__.py +5 -0
- idmtools/plugins/git_commit.py +117 -0
- idmtools/registry/__init__.py +4 -0
- idmtools/registry/experiment_specification.py +105 -0
- idmtools/registry/functions.py +28 -0
- idmtools/registry/hook_specs.py +132 -0
- idmtools/registry/master_plugin_registry.py +51 -0
- idmtools/registry/platform_specification.py +138 -0
- idmtools/registry/plugin_specification.py +129 -0
- idmtools/registry/task_specification.py +104 -0
- idmtools/registry/utils.py +119 -0
- idmtools/services/__init__.py +5 -0
- idmtools/services/ipersistance_service.py +135 -0
- idmtools/services/platforms.py +13 -0
- idmtools/utils/__init__.py +5 -0
- idmtools/utils/caller.py +24 -0
- idmtools/utils/collections.py +246 -0
- idmtools/utils/command_line.py +45 -0
- idmtools/utils/decorators.py +300 -0
- idmtools/utils/display/__init__.py +22 -0
- idmtools/utils/display/displays.py +181 -0
- idmtools/utils/display/settings.py +25 -0
- idmtools/utils/dropbox_location.py +30 -0
- idmtools/utils/entities.py +127 -0
- idmtools/utils/file.py +72 -0
- idmtools/utils/file_parser.py +151 -0
- idmtools/utils/filter_simulations.py +182 -0
- idmtools/utils/filters/__init__.py +5 -0
- idmtools/utils/filters/asset_filters.py +88 -0
- idmtools/utils/general.py +286 -0
- idmtools/utils/gitrepo.py +336 -0
- idmtools/utils/hashing.py +239 -0
- idmtools/utils/info.py +124 -0
- idmtools/utils/json.py +82 -0
- idmtools/utils/language.py +107 -0
- idmtools/utils/local_os.py +40 -0
- idmtools/utils/time.py +22 -0
- idmtools-0.0.2.dist-info/METADATA +120 -0
- idmtools-0.0.2.dist-info/RECORD +116 -0
- idmtools-0.0.2.dist-info/entry_points.txt +9 -0
- idmtools-0.0.2.dist-info/licenses/LICENSE.TXT +3 -0
- idmtools-0.0.0.dev0.dist-info/METADATA +0 -41
- idmtools-0.0.0.dev0.dist-info/RECORD +0 -5
- {idmtools-0.0.0.dev0.dist-info → idmtools-0.0.2.dist-info}/WHEEL +0 -0
- {idmtools-0.0.0.dev0.dist-info → idmtools-0.0.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"""
|
|
2
|
+
IPlatformSimulationOperations defines simulation item 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 getLogger, DEBUG
|
|
9
|
+
from typing import Type, Any, List, Dict, NoReturn, Optional
|
|
10
|
+
from idmtools.assets import Asset
|
|
11
|
+
from idmtools.core.cache_enabled import CacheEnabled
|
|
12
|
+
from idmtools.entities.experiment import Experiment
|
|
13
|
+
from idmtools.entities.iplatform_ops.utils import batch_create_items
|
|
14
|
+
from idmtools.entities.simulation import Simulation
|
|
15
|
+
from idmtools.registry.functions import FunctionPluginManager
|
|
16
|
+
|
|
17
|
+
logger = getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class IPlatformSimulationOperations(CacheEnabled, ABC):
|
|
22
|
+
"""
|
|
23
|
+
IPlatformSimulationOperations defines simulation item operations interface.
|
|
24
|
+
"""
|
|
25
|
+
platform: 'IPlatform' # noqa: F821
|
|
26
|
+
platform_type: Type
|
|
27
|
+
|
|
28
|
+
@abstractmethod
|
|
29
|
+
def get(self, simulation_id: str, **kwargs) -> Any:
|
|
30
|
+
"""
|
|
31
|
+
Returns the platform representation of an Simulation.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
simulation_id: Item id of Simulations
|
|
35
|
+
**kwargs:
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Platform Representation of an simulation
|
|
39
|
+
"""
|
|
40
|
+
pass
|
|
41
|
+
|
|
42
|
+
def pre_create(self, simulation: Simulation, **kwargs) -> NoReturn:
|
|
43
|
+
"""
|
|
44
|
+
Run the platform/simulation post creation events.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
simulation: simulation to run post-creation events
|
|
48
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
NoReturn
|
|
52
|
+
"""
|
|
53
|
+
if logger.isEnabledFor(DEBUG):
|
|
54
|
+
logger.debug("Calling idmtools_platform_pre_create_item")
|
|
55
|
+
FunctionPluginManager.instance().hook.idmtools_platform_pre_create_item(item=simulation, kwargs=kwargs)
|
|
56
|
+
if logger.isEnabledFor(DEBUG):
|
|
57
|
+
logger.debug("Calling pre_creation")
|
|
58
|
+
simulation.pre_creation(self.platform)
|
|
59
|
+
|
|
60
|
+
def post_create(self, simulation: Simulation, **kwargs) -> NoReturn:
|
|
61
|
+
"""
|
|
62
|
+
Run the platform/simulation post creation events.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
simulation: simulation to run post-creation events
|
|
66
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
NoReturn
|
|
70
|
+
"""
|
|
71
|
+
if logger.isEnabledFor(DEBUG):
|
|
72
|
+
logger.debug("Calling idmtools_platform_post_create_item hooks")
|
|
73
|
+
FunctionPluginManager.instance().hook.idmtools_platform_post_create_item(item=simulation, kwargs=kwargs)
|
|
74
|
+
if logger.isEnabledFor(DEBUG):
|
|
75
|
+
logger.debug("Calling post_creation")
|
|
76
|
+
simulation.post_creation(self.platform)
|
|
77
|
+
|
|
78
|
+
def create(self, simulation: Simulation, do_pre: bool = True, do_post: bool = True, **kwargs) -> Any:
|
|
79
|
+
"""
|
|
80
|
+
Creates an simulation from an IDMTools simulation object.
|
|
81
|
+
|
|
82
|
+
Also performs pre-creation and post-creation locally and on platform.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
simulation: Simulation to create
|
|
86
|
+
do_pre: Perform Pre creation events for item
|
|
87
|
+
do_post: Perform Post creation events for item
|
|
88
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
Created platform item and the id of said item
|
|
92
|
+
"""
|
|
93
|
+
if simulation.status is not None:
|
|
94
|
+
return simulation
|
|
95
|
+
if do_pre:
|
|
96
|
+
self.pre_create(simulation, **kwargs)
|
|
97
|
+
if logger.isEnabledFor(DEBUG):
|
|
98
|
+
logger.debug("Finished pre_create")
|
|
99
|
+
if logger.isEnabledFor(DEBUG):
|
|
100
|
+
logger.debug("Calling platform_create")
|
|
101
|
+
simulation._platform_object = self.platform_create(simulation, **kwargs)
|
|
102
|
+
if logger.isEnabledFor(DEBUG):
|
|
103
|
+
logger.debug("Finished platform_create")
|
|
104
|
+
if do_post:
|
|
105
|
+
self.post_create(simulation, **kwargs)
|
|
106
|
+
if logger.isEnabledFor(DEBUG):
|
|
107
|
+
logger.debug("Finished post_create")
|
|
108
|
+
return simulation
|
|
109
|
+
|
|
110
|
+
@abstractmethod
|
|
111
|
+
def platform_create(self, simulation: Simulation, **kwargs) -> Any:
|
|
112
|
+
"""
|
|
113
|
+
Creates an simulation on Platform from an IDMTools Simulation Object.
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
simulation: Simulation to create
|
|
117
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Created platform item and the id of said item
|
|
121
|
+
"""
|
|
122
|
+
pass
|
|
123
|
+
|
|
124
|
+
def batch_create(self, sims: List[Simulation], display_progress: bool = True, **kwargs) -> List[Simulation]:
|
|
125
|
+
"""
|
|
126
|
+
Provides a method to batch create simulations.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
sims: List of simulations to create
|
|
130
|
+
display_progress: Show progress bar
|
|
131
|
+
**kwargs:
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
List of tuples containing the create object and id of item that was created
|
|
135
|
+
"""
|
|
136
|
+
return batch_create_items(sims, create_func=self.create, display_progress=display_progress,
|
|
137
|
+
progress_description="Commissioning Simulations", unit="simulation",
|
|
138
|
+
**kwargs)
|
|
139
|
+
|
|
140
|
+
@abstractmethod
|
|
141
|
+
def get_parent(self, simulation: Any, **kwargs) -> Any:
|
|
142
|
+
"""
|
|
143
|
+
Returns the parent of item. If the platform doesn't support parents, you should throw a TopLevelItem error.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
simulation:
|
|
147
|
+
**kwargs:
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
Parent of simulation
|
|
151
|
+
|
|
152
|
+
Raise:
|
|
153
|
+
TopLevelItem
|
|
154
|
+
"""
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
def to_entity(self, simulation: Any, load_task: bool = False, parent: Optional[Experiment] = None,
|
|
158
|
+
**kwargs) -> Simulation:
|
|
159
|
+
"""
|
|
160
|
+
Converts the platform representation of simulation to idmtools representation.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
simulation:Platform simulation object
|
|
164
|
+
load_task: Load Task Object as well. Can take much longer and have more data on platform
|
|
165
|
+
parent: Optional parent object
|
|
166
|
+
Returns:
|
|
167
|
+
IDMTools simulation object
|
|
168
|
+
"""
|
|
169
|
+
if parent:
|
|
170
|
+
simulation.parent = parent
|
|
171
|
+
return simulation
|
|
172
|
+
|
|
173
|
+
def pre_run_item(self, simulation: Simulation, **kwargs):
|
|
174
|
+
"""
|
|
175
|
+
Trigger right before commissioning experiment on platform.
|
|
176
|
+
|
|
177
|
+
This ensures that the item is created. It also ensures that the children(simulations) have also been created.
|
|
178
|
+
|
|
179
|
+
Args:
|
|
180
|
+
simulation: Experiment to commission
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
None
|
|
184
|
+
"""
|
|
185
|
+
# ensure the item is created before running
|
|
186
|
+
# TODO what status are valid here? Create only?
|
|
187
|
+
if simulation.status is None:
|
|
188
|
+
self.create(simulation, **kwargs)
|
|
189
|
+
|
|
190
|
+
def post_run_item(self, simulation: Simulation, **kwargs):
|
|
191
|
+
"""
|
|
192
|
+
Trigger right after commissioning experiment on platform.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
simulation: Experiment just commissioned
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
None
|
|
199
|
+
"""
|
|
200
|
+
if logger.isEnabledFor(DEBUG):
|
|
201
|
+
logger.debug("Calling idmtools_platform_post_run hooks")
|
|
202
|
+
FunctionPluginManager.instance().hook.idmtools_platform_post_run(item=simulation, kwargs=kwargs)
|
|
203
|
+
|
|
204
|
+
def run_item(self, simulation: Simulation, **kwargs):
|
|
205
|
+
"""
|
|
206
|
+
Called during commissioning of an item. This should create the remote resource.
|
|
207
|
+
|
|
208
|
+
Args:
|
|
209
|
+
simulation:
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
None
|
|
213
|
+
"""
|
|
214
|
+
self.pre_run_item(simulation, **kwargs)
|
|
215
|
+
self.platform_run_item(simulation, **kwargs)
|
|
216
|
+
self.post_run_item(simulation, **kwargs)
|
|
217
|
+
|
|
218
|
+
@abstractmethod
|
|
219
|
+
def platform_run_item(self, simulation: Simulation, **kwargs):
|
|
220
|
+
"""
|
|
221
|
+
Called during commissioning of an item. This should create the remote resource but not upload assets.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
simulation: Simulation to run
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
None
|
|
228
|
+
"""
|
|
229
|
+
pass
|
|
230
|
+
|
|
231
|
+
@abstractmethod
|
|
232
|
+
def send_assets(self, simulation: Any, **kwargs):
|
|
233
|
+
"""
|
|
234
|
+
Send simulations assets to server.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
simulation: Simulation to upload assets for
|
|
238
|
+
**kwargs: Keyword arguments for the op
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
None
|
|
242
|
+
"""
|
|
243
|
+
pass
|
|
244
|
+
|
|
245
|
+
@abstractmethod
|
|
246
|
+
def refresh_status(self, simulation: Simulation, **kwargs):
|
|
247
|
+
"""
|
|
248
|
+
Refresh status for simulation object.
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
simulation: Experiment to get status for
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
None
|
|
255
|
+
"""
|
|
256
|
+
pass
|
|
257
|
+
|
|
258
|
+
@abstractmethod
|
|
259
|
+
def get_assets(self, simulation: Simulation, files: List[str], **kwargs) -> Dict[str, bytearray]:
|
|
260
|
+
"""
|
|
261
|
+
Get files from simulation.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
simulation: Simulation to fetch files from
|
|
265
|
+
files: Files to get
|
|
266
|
+
**kwargs:
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
Dictionary containing filename and content
|
|
270
|
+
"""
|
|
271
|
+
pass
|
|
272
|
+
|
|
273
|
+
@abstractmethod
|
|
274
|
+
def list_assets(self, simulation: Simulation, **kwargs) -> List[Asset]:
|
|
275
|
+
"""
|
|
276
|
+
List available assets for a simulation.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
simulation: Simulation of Assets
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
List of filenames
|
|
283
|
+
"""
|
|
284
|
+
pass
|
|
285
|
+
|
|
286
|
+
def create_sim_directory_map(self, simulation_id: str) -> Dict:
|
|
287
|
+
"""
|
|
288
|
+
Build simulation working directory mapping.
|
|
289
|
+
Args:
|
|
290
|
+
simulation_id: simulation id
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
Dict
|
|
294
|
+
"""
|
|
295
|
+
return {}
|
|
296
|
+
|
|
297
|
+
def platform_delete(self, simulation_id: str) -> None:
|
|
298
|
+
"""
|
|
299
|
+
Delete platform simulation.
|
|
300
|
+
Args:
|
|
301
|
+
simulation_id: simulation id
|
|
302
|
+
Returns:
|
|
303
|
+
None
|
|
304
|
+
"""
|
|
305
|
+
pass
|
|
306
|
+
|
|
307
|
+
def platform_cancel(self, simulation_id: str) -> None:
|
|
308
|
+
"""
|
|
309
|
+
Cancel platform simulation.
|
|
310
|
+
Args:
|
|
311
|
+
simulation_id: simulation id
|
|
312
|
+
Returns:
|
|
313
|
+
None
|
|
314
|
+
"""
|
|
315
|
+
pass
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"""
|
|
2
|
+
IPlatformSuiteOperations defines suite item 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 getLogger, DEBUG
|
|
9
|
+
from typing import Type, Any, List, Tuple, Dict, NoReturn, TYPE_CHECKING
|
|
10
|
+
from idmtools.core.enums import EntityStatus, ItemType
|
|
11
|
+
from idmtools.entities.iplatform_ops.utils import batch_create_items
|
|
12
|
+
from idmtools.entities.suite import Suite
|
|
13
|
+
from idmtools.registry.functions import FunctionPluginManager
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING: # pragma: no cover
|
|
16
|
+
from idmtools.entities.iplatform import IPlatform
|
|
17
|
+
|
|
18
|
+
logger = getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass
|
|
22
|
+
class IPlatformSuiteOperations(ABC):
|
|
23
|
+
"""
|
|
24
|
+
IPlatformSuiteOperations defines suite item operations interface.
|
|
25
|
+
"""
|
|
26
|
+
platform: 'IPlatform' # noqa: F821
|
|
27
|
+
platform_type: Type
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def get(self, suite_id: str, **kwargs) -> Any:
|
|
31
|
+
"""
|
|
32
|
+
Returns the platform representation of an Suite.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
suite_id: Item id of Suites
|
|
36
|
+
**kwargs:
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
Platform Representation of an suite
|
|
40
|
+
"""
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def batch_create(self, suites: List[Suite], display_progress: bool = True, **kwargs) -> List[Tuple[Any, str]]:
|
|
44
|
+
"""
|
|
45
|
+
Provides a method to batch create suites.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
display_progress: Display progress bar
|
|
49
|
+
suites: List of suites to create
|
|
50
|
+
**kwargs:
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
List of tuples containing the create object and id of item that was created
|
|
54
|
+
"""
|
|
55
|
+
return batch_create_items(suites, create_func=self.create, display_progress=display_progress,
|
|
56
|
+
progress_description="Creating Suites", unit="suite",
|
|
57
|
+
**kwargs)
|
|
58
|
+
|
|
59
|
+
def pre_create(self, suite: Suite, **kwargs) -> NoReturn:
|
|
60
|
+
"""
|
|
61
|
+
Run the platform/suite post creation events.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
suite: Experiment to run post-creation events
|
|
65
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
NoReturn
|
|
69
|
+
"""
|
|
70
|
+
if logger.isEnabledFor(DEBUG):
|
|
71
|
+
logger.debug("Calling idmtools_platform_pre_create_item")
|
|
72
|
+
FunctionPluginManager.instance().hook.idmtools_platform_pre_create_item(item=suite, kwargs=kwargs)
|
|
73
|
+
if logger.isEnabledFor(DEBUG):
|
|
74
|
+
logger.debug("Calling pre_creation")
|
|
75
|
+
suite.pre_creation(self.platform)
|
|
76
|
+
|
|
77
|
+
def post_create(self, suite: Suite, **kwargs) -> NoReturn:
|
|
78
|
+
"""
|
|
79
|
+
Run the platform/suite post creation events.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
suite: Experiment to run post-creation events
|
|
83
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
NoReturn
|
|
87
|
+
"""
|
|
88
|
+
if logger.isEnabledFor(DEBUG):
|
|
89
|
+
logger.debug("Calling idmtools_platform_post_create_item hooks")
|
|
90
|
+
FunctionPluginManager.instance().hook.idmtools_platform_post_create_item(item=suite, kwargs=kwargs)
|
|
91
|
+
suite.status = EntityStatus.CREATED
|
|
92
|
+
suite.platform = self.platform
|
|
93
|
+
suite.post_creation(self.platform)
|
|
94
|
+
for experiment in suite.experiments:
|
|
95
|
+
experiment.parent_id = suite.id
|
|
96
|
+
|
|
97
|
+
def create(self, suite: Suite, do_pre: bool = True, do_post: bool = True, **kwargs) -> Tuple[Any, str]:
|
|
98
|
+
"""
|
|
99
|
+
Creates an simulation from an IDMTools suite object.
|
|
100
|
+
|
|
101
|
+
Also performs pre-creation and post-creation locally and on platform.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
suite: Suite to create
|
|
105
|
+
do_pre: Perform Pre creation events for item
|
|
106
|
+
do_post: Perform Post creation events for item
|
|
107
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
Created platform item and the id of said item
|
|
111
|
+
"""
|
|
112
|
+
if suite.status == EntityStatus.CREATED:
|
|
113
|
+
return suite._platform_object, suite.uid
|
|
114
|
+
if do_pre:
|
|
115
|
+
self.pre_create(suite, **kwargs)
|
|
116
|
+
if logger.isEnabledFor(DEBUG):
|
|
117
|
+
logger.debug("Finished pre_create")
|
|
118
|
+
if logger.isEnabledFor(DEBUG):
|
|
119
|
+
logger.debug("Calling platform_create")
|
|
120
|
+
ret = self.platform_create(suite, **kwargs)
|
|
121
|
+
if logger.isEnabledFor(DEBUG):
|
|
122
|
+
logger.debug("Finished platform_create")
|
|
123
|
+
if do_post:
|
|
124
|
+
self.post_create(suite, **kwargs)
|
|
125
|
+
if logger.isEnabledFor(DEBUG):
|
|
126
|
+
logger.debug("Finished post_create")
|
|
127
|
+
return ret
|
|
128
|
+
|
|
129
|
+
@abstractmethod
|
|
130
|
+
def platform_create(self, suite: Suite, **kwargs) -> Tuple[Any, str]:
|
|
131
|
+
"""
|
|
132
|
+
Creates an suite from an IDMTools suite object.
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
suite: Suite to create
|
|
136
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
Created platform item and the id of said item
|
|
140
|
+
"""
|
|
141
|
+
pass
|
|
142
|
+
|
|
143
|
+
def pre_run_item(self, suite: Suite, **kwargs):
|
|
144
|
+
"""
|
|
145
|
+
Trigger right before commissioning experiment on platform.
|
|
146
|
+
|
|
147
|
+
This ensures that the item is created. It also ensures that the children(simulations) have also been created.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
suite: Experiment to commission
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
None
|
|
154
|
+
"""
|
|
155
|
+
# ensure the item is created before running
|
|
156
|
+
# TODO what status are valid here? Create only?
|
|
157
|
+
if suite.status is None:
|
|
158
|
+
self.create(suite)
|
|
159
|
+
|
|
160
|
+
exps_to_commission = []
|
|
161
|
+
for exp in suite.experiments:
|
|
162
|
+
if exp.status is None:
|
|
163
|
+
exps_to_commission.append(exp)
|
|
164
|
+
if exps_to_commission:
|
|
165
|
+
if logger.isEnabledFor(DEBUG):
|
|
166
|
+
logger.debug("Calling run_items")
|
|
167
|
+
self.platform.run_items(exps_to_commission, **kwargs)
|
|
168
|
+
if logger.isEnabledFor(DEBUG):
|
|
169
|
+
logger.debug("Finished run_items")
|
|
170
|
+
|
|
171
|
+
def post_run_item(self, suite: Suite, **kwargs):
|
|
172
|
+
"""
|
|
173
|
+
Trigger right after commissioning suite on platform.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
suite: Experiment just commissioned
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
None
|
|
180
|
+
"""
|
|
181
|
+
if logger.isEnabledFor(DEBUG):
|
|
182
|
+
logger.debug("Calling idmtools_platform_post_run hooks")
|
|
183
|
+
FunctionPluginManager.instance().hook.idmtools_platform_post_run(item=suite, kwargs=kwargs)
|
|
184
|
+
suite.status = EntityStatus.RUNNING
|
|
185
|
+
|
|
186
|
+
def run_item(self, suite: Suite, **kwargs):
|
|
187
|
+
"""
|
|
188
|
+
Called during commissioning of an item. This should create the remote resource.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
suite: suite to run
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
None
|
|
195
|
+
"""
|
|
196
|
+
if logger.isEnabledFor(DEBUG):
|
|
197
|
+
logger.debug("Calling pre_run_item")
|
|
198
|
+
self.pre_run_item(suite, **kwargs)
|
|
199
|
+
if logger.isEnabledFor(DEBUG):
|
|
200
|
+
logger.debug("Calling platform_run_item")
|
|
201
|
+
self.platform_run_item(suite, **kwargs)
|
|
202
|
+
if logger.isEnabledFor(DEBUG):
|
|
203
|
+
logger.debug("Calling post_run_item")
|
|
204
|
+
self.post_run_item(suite, **kwargs)
|
|
205
|
+
|
|
206
|
+
def platform_run_item(self, suite: Suite, **kwargs):
|
|
207
|
+
"""
|
|
208
|
+
Called during commissioning of an item. This should perform what is needed to commission job on platform.
|
|
209
|
+
|
|
210
|
+
Args:
|
|
211
|
+
suite:
|
|
212
|
+
|
|
213
|
+
Returns:
|
|
214
|
+
None
|
|
215
|
+
"""
|
|
216
|
+
pass
|
|
217
|
+
|
|
218
|
+
@abstractmethod
|
|
219
|
+
def get_parent(self, suite: Any, **kwargs) -> Any:
|
|
220
|
+
"""
|
|
221
|
+
Returns the parent of item. If the platform doesn't support parents, you should throw a TopLevelItem error.
|
|
222
|
+
|
|
223
|
+
Args:
|
|
224
|
+
suite:
|
|
225
|
+
**kwargs:
|
|
226
|
+
|
|
227
|
+
Returns:
|
|
228
|
+
Parent of suite
|
|
229
|
+
|
|
230
|
+
Raise:
|
|
231
|
+
TopLevelItem
|
|
232
|
+
"""
|
|
233
|
+
pass
|
|
234
|
+
|
|
235
|
+
@abstractmethod
|
|
236
|
+
def get_children(self, suite: Any, **kwargs) -> List[Any]:
|
|
237
|
+
"""
|
|
238
|
+
Returns the children of an suite object.
|
|
239
|
+
|
|
240
|
+
Args:
|
|
241
|
+
suite: Suite object
|
|
242
|
+
**kwargs: Optional arguments mainly for extensibility
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
Children of suite object
|
|
246
|
+
"""
|
|
247
|
+
pass
|
|
248
|
+
|
|
249
|
+
def to_entity(self, suite: Any, **kwargs) -> Suite:
|
|
250
|
+
"""
|
|
251
|
+
Converts the platform representation of suite to idmtools representation.
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
suite:Platform suite object
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
IDMTools suite object
|
|
258
|
+
"""
|
|
259
|
+
return suite
|
|
260
|
+
|
|
261
|
+
@abstractmethod
|
|
262
|
+
def refresh_status(self, experiment: Suite, **kwargs):
|
|
263
|
+
"""
|
|
264
|
+
Refresh status of suite.
|
|
265
|
+
|
|
266
|
+
Args:
|
|
267
|
+
experiment:
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
None
|
|
271
|
+
"""
|
|
272
|
+
pass
|
|
273
|
+
|
|
274
|
+
def get_assets(self, suite: Suite, files: List[str], **kwargs) -> Dict[str, Dict[str, Dict[str, bytearray]]]:
|
|
275
|
+
"""
|
|
276
|
+
Fetch assets for suite.
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
suite: suite to get assets for
|
|
280
|
+
files: Files to load
|
|
281
|
+
**kwargs:
|
|
282
|
+
|
|
283
|
+
Returns:
|
|
284
|
+
Nested dictionaries in the structure
|
|
285
|
+
experiment_id { simulation_id { files = content } } }
|
|
286
|
+
"""
|
|
287
|
+
ret = dict()
|
|
288
|
+
for exp in suite.experiments:
|
|
289
|
+
e = self.platform.get_item(exp.uid, ItemType.EXPERIMENT)
|
|
290
|
+
ret[str(exp.uid)] = self.platform.get_files(e, files, **kwargs)
|
|
291
|
+
return ret
|
|
292
|
+
|
|
293
|
+
def create_sim_directory_map(self, suite_id: str) -> Dict:
|
|
294
|
+
"""
|
|
295
|
+
Build simulation working directory mapping.
|
|
296
|
+
Args:
|
|
297
|
+
suite_id: suite id
|
|
298
|
+
|
|
299
|
+
Returns:
|
|
300
|
+
Dict
|
|
301
|
+
"""
|
|
302
|
+
return {}
|
|
303
|
+
|
|
304
|
+
def platform_delete(self, suite_id: str) -> None:
|
|
305
|
+
"""
|
|
306
|
+
Delete platform suite.
|
|
307
|
+
Args:
|
|
308
|
+
suite_id: suite id
|
|
309
|
+
Returns:
|
|
310
|
+
None
|
|
311
|
+
"""
|
|
312
|
+
pass
|
|
313
|
+
|
|
314
|
+
def platform_cancel(self, suite_id: str) -> None:
|
|
315
|
+
"""
|
|
316
|
+
Cancel platform suite.
|
|
317
|
+
Args:
|
|
318
|
+
suite_id: suite id
|
|
319
|
+
Returns:
|
|
320
|
+
None
|
|
321
|
+
"""
|
|
322
|
+
pass
|