idmtools-test 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.
Files changed (141) hide show
  1. idmtools_test/__init__.py +16 -8
  2. idmtools_test/inputs/__init__.py +0 -0
  3. idmtools_test/inputs/assets/collections/1/a.txt +0 -0
  4. idmtools_test/inputs/assets/collections/1/b.txt +0 -0
  5. idmtools_test/inputs/assets/collections/2/c.txt +0 -0
  6. idmtools_test/inputs/assets/collections/d.txt +0 -0
  7. idmtools_test/inputs/builder/sweeps.csv +6 -0
  8. idmtools_test/inputs/builder/sweeps.yaml +8 -0
  9. idmtools_test/inputs/compsplatform/__init__.py +0 -0
  10. idmtools_test/inputs/compsplatform/failing_model.py +5 -0
  11. idmtools_test/inputs/compsplatform/mixed_model.py +10 -0
  12. idmtools_test/inputs/compsplatform/working_model.py +5 -0
  13. idmtools_test/inputs/configuration/idmtools_test.ini +71 -0
  14. idmtools_test/inputs/custom/Eradication.exe +0 -0
  15. idmtools_test/inputs/custom/Local_Migration.bin +0 -0
  16. idmtools_test/inputs/custom/Local_Migration.bin.json +12 -0
  17. idmtools_test/inputs/custom/Regional_Migration.bin +0 -0
  18. idmtools_test/inputs/custom/Regional_Migration.bin.json +12 -0
  19. idmtools_test/inputs/custom/Zambia_30arcsec_air_temperature_daily.bin +0 -0
  20. idmtools_test/inputs/custom/Zambia_30arcsec_air_temperature_daily.bin.json +26 -0
  21. idmtools_test/inputs/custom/Zambia_30arcsec_rainfall_daily.bin +0 -0
  22. idmtools_test/inputs/custom/Zambia_30arcsec_rainfall_daily.bin.json +26 -0
  23. idmtools_test/inputs/custom/Zambia_30arcsec_relative_humidity_daily.bin +0 -0
  24. idmtools_test/inputs/custom/Zambia_30arcsec_relative_humidity_daily.bin.json +26 -0
  25. idmtools_test/inputs/custom/campaign.json +95384 -0
  26. idmtools_test/inputs/custom/config.json +943 -0
  27. idmtools_test/inputs/custom/custom_reports.json +163 -0
  28. idmtools_test/inputs/custom/demo.json +1258 -0
  29. idmtools_test/inputs/custom/emodules_map.json +9 -0
  30. idmtools_test/inputs/custom/reporter_plugins/libReportMalariaFiltered.dll +0 -0
  31. idmtools_test/inputs/custom/reporter_plugins/libSpatialReportMalariaFiltered.dll +0 -0
  32. idmtools_test/inputs/custom/reporter_plugins/libreporteventcounter.dll +0 -0
  33. idmtools_test/inputs/duplicated_model/exe/Eradication +0 -0
  34. idmtools_test/inputs/duplicated_model/f1 +0 -0
  35. idmtools_test/inputs/emod/Eradication.exe +0 -0
  36. idmtools_test/inputs/emod_files/campaign.json +21 -0
  37. idmtools_test/inputs/emod_files/config.json +125 -0
  38. idmtools_test/inputs/emod_files/demographics.json +81 -0
  39. idmtools_test/inputs/fakemodels/AnotherOne +0 -0
  40. idmtools_test/inputs/fakemodels/Eradication +0 -0
  41. idmtools_test/inputs/fakemodels/Eradication-2.11.custom.exe +0 -0
  42. idmtools_test/inputs/fakemodels/Eradication.exe +0 -0
  43. idmtools_test/inputs/files/campaign.json +21 -0
  44. idmtools_test/inputs/files/config.json +119 -0
  45. idmtools_test/inputs/files/demographics.json +82 -0
  46. idmtools_test/inputs/files/hello.txt +1 -0
  47. idmtools_test/inputs/id_files/slurm.example_python_experiment.id +1 -0
  48. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_air_temperature_daily.bin +0 -0
  49. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_air_temperature_daily.bin.json +26 -0
  50. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_demographics.json +559 -0
  51. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_rainfall_daily.bin +0 -0
  52. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_rainfall_daily.bin.json +26 -0
  53. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_relative_humidity_daily.bin +0 -0
  54. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Brazil_Central_West_Brazil_Central_West_2.5arcmin_relative_humidity_daily.bin.json +26 -0
  55. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Eradication +0 -0
  56. idmtools_test/inputs/malaria_brazil_central_west_spatial/Assets/Eradication.exe +0 -0
  57. idmtools_test/inputs/malaria_brazil_central_west_spatial/campaign.json +4 -0
  58. idmtools_test/inputs/malaria_brazil_central_west_spatial/config.json +667 -0
  59. idmtools_test/inputs/malaria_brazil_central_west_spatial/malaria_brazil_central_west_spatial-ERA5Input_demo.csv +37 -0
  60. idmtools_test/inputs/python/Assets/MyExternalLibrary/__init__.py +0 -0
  61. idmtools_test/inputs/python/Assets/MyExternalLibrary/functions.py +15 -0
  62. idmtools_test/inputs/python/Assets/MyLib/functions.py +2 -0
  63. idmtools_test/inputs/python/Assets/MyLib/temp.py +271 -0
  64. idmtools_test/inputs/python/Assets/__init__.py +0 -0
  65. idmtools_test/inputs/python/__init__.py +0 -0
  66. idmtools_test/inputs/python/folder_dup_file/__init__.py +0 -0
  67. idmtools_test/inputs/python/folder_dup_file/model1.py +19 -0
  68. idmtools_test/inputs/python/hello_world.py +1 -0
  69. idmtools_test/inputs/python/model.py +26 -0
  70. idmtools_test/inputs/python/model1.py +20 -0
  71. idmtools_test/inputs/python/model3.py +21 -0
  72. idmtools_test/inputs/python/newmodel2.py +20 -0
  73. idmtools_test/inputs/python/output_generator/generate.py +39 -0
  74. idmtools_test/inputs/python/realpath_verify.py +6 -0
  75. idmtools_test/inputs/python/ye_seir_model/Assets/MyExternalLibrary/Python36/dtk_generic_intrahost.pyd +0 -0
  76. idmtools_test/inputs/python/ye_seir_model/Assets/MyExternalLibrary/Python36/dtk_nodedemog.pyd +0 -0
  77. idmtools_test/inputs/python/ye_seir_model/Assets/MyExternalLibrary/Python37/dtk_generic_intrahost.pyd +0 -0
  78. idmtools_test/inputs/python/ye_seir_model/Assets/MyExternalLibrary/Python37/dtk_nodedemog.pyd +0 -0
  79. idmtools_test/inputs/python/ye_seir_model/Assets/SEIR_model.py +252 -0
  80. idmtools_test/inputs/python/ye_seir_model/Assets/SEIR_model_slurm.py +242 -0
  81. idmtools_test/inputs/python/ye_seir_model/Assets/config_sim.py +48 -0
  82. idmtools_test/inputs/python/ye_seir_model/Assets/custom_csv_analyzer.py +133 -0
  83. idmtools_test/inputs/python/ye_seir_model/Assets/python.sh +4 -0
  84. idmtools_test/inputs/python/ye_seir_model/Assets/requirements.txt +4 -0
  85. idmtools_test/inputs/python/ye_seir_model/Assets/templates/config.json +68 -0
  86. idmtools_test/inputs/python/ye_seir_model/Assets/templates/demographics_template.json +44 -0
  87. idmtools_test/inputs/python/ye_seir_model/__init__.py +0 -0
  88. idmtools_test/inputs/python_experiments/__init__.py +0 -0
  89. idmtools_test/inputs/python_experiments/model.py +10 -0
  90. idmtools_test/inputs/r/model1.R +1 -0
  91. idmtools_test/inputs/r/ncov_analysis/individual_dynamics_estimates/estimate_incubation_period.R +89 -0
  92. idmtools_test/inputs/regression/107/Assets/__init__.py +0 -0
  93. idmtools_test/inputs/regression/107/Assets/model.py +1 -0
  94. idmtools_test/inputs/regression/107/__init__.py +0 -0
  95. idmtools_test/inputs/regression/125/Assets/__init__.py +0 -0
  96. idmtools_test/inputs/regression/125/Assets/model.py +1 -0
  97. idmtools_test/inputs/regression/125/Assets2/__init__.py +0 -0
  98. idmtools_test/inputs/regression/125/Assets2/dir1/__init__.py +0 -0
  99. idmtools_test/inputs/regression/125/Assets2/dir1/model.py +1 -0
  100. idmtools_test/inputs/regression/125/Assets2/dir2/__init__.py +0 -0
  101. idmtools_test/inputs/regression/125/Assets2/dir2/model.py +1 -0
  102. idmtools_test/inputs/regression/125/__init__.py +0 -0
  103. idmtools_test/inputs/regression/__init__.py +0 -0
  104. idmtools_test/inputs/scheduling/hpc/WorkOrder.json +7 -0
  105. idmtools_test/inputs/scheduling/slurm/WorkOrder.json +11 -0
  106. idmtools_test/inputs/scheduling/slurm/WorkOrder1.json +11 -0
  107. idmtools_test/inputs/scheduling/slurm/WorkOrder2.json +13 -0
  108. idmtools_test/inputs/scheduling/slurm/commandline_model.py +22 -0
  109. idmtools_test/inputs/serialization/Eradication.exe +0 -0
  110. idmtools_test/inputs/serialization/single_node_demographics.json +82 -0
  111. idmtools_test/inputs/singularity/alpine_simple/Singularity.def +28 -0
  112. idmtools_test/inputs/singularity/alpine_simple/run_model.py +41 -0
  113. idmtools_test/inputs/singularity/alpine_template/Singularity.jinja +22 -0
  114. idmtools_test/test_precreate_hooks.py +25 -0
  115. idmtools_test/utils/__init__.py +0 -0
  116. idmtools_test/utils/cli.py +41 -0
  117. idmtools_test/utils/common_experiments.py +79 -0
  118. idmtools_test/utils/comps.py +152 -0
  119. idmtools_test/utils/decorators.py +208 -0
  120. idmtools_test/utils/execute_operations/__init__.py +0 -0
  121. idmtools_test/utils/execute_operations/experiment_operations.py +237 -0
  122. idmtools_test/utils/execute_operations/simulate_operations.py +368 -0
  123. idmtools_test/utils/itest_with_persistence.py +25 -0
  124. idmtools_test/utils/operations/__init__.py +0 -0
  125. idmtools_test/utils/operations/experiment_operations.py +64 -0
  126. idmtools_test/utils/operations/simulation_operations.py +114 -0
  127. idmtools_test/utils/shared_functions.py +25 -0
  128. idmtools_test/utils/test_asset.py +89 -0
  129. idmtools_test/utils/test_asset_collection.py +223 -0
  130. idmtools_test/utils/test_execute_platform.py +137 -0
  131. idmtools_test/utils/test_platform.py +94 -0
  132. idmtools_test/utils/test_task.py +69 -0
  133. idmtools_test/utils/utils.py +146 -0
  134. idmtools_test-0.0.2.dist-info/METADATA +48 -0
  135. idmtools_test-0.0.2.dist-info/RECORD +139 -0
  136. idmtools_test-0.0.2.dist-info/entry_points.txt +9 -0
  137. idmtools_test-0.0.2.dist-info/licenses/LICENSE.TXT +3 -0
  138. idmtools_test-0.0.0.dev0.dist-info/METADATA +0 -41
  139. idmtools_test-0.0.0.dev0.dist-info/RECORD +0 -5
  140. {idmtools_test-0.0.0.dev0.dist-info → idmtools_test-0.0.2.dist-info}/WHEEL +0 -0
  141. {idmtools_test-0.0.0.dev0.dist-info → idmtools_test-0.0.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,15 @@
1
+ import numpy as np
2
+
3
+
4
+ def add(x, y):
5
+ """
6
+ Add x to y
7
+
8
+ Args:
9
+ x: x to add
10
+ y: y to add
11
+
12
+ Returns:
13
+
14
+ """
15
+ return np.add(x, y)
@@ -0,0 +1,2 @@
1
+ def add(a: int, b: int):
2
+ return a + b
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env python
2
+ # flake8: noqa W291,E701
3
+ #
4
+ # Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
5
+ # Copyright (c) 2008-2016 California Institute of Technology.
6
+ # Copyright (c) 2016-2018 The Uncertainty Quantification Foundation.
7
+ # License: 3-clause BSD. The full license text is available at:
8
+ # - https://github.com/uqfoundation/dill/blob/master/LICENSE
9
+ """
10
+ Methods for serialized objects (or source code) stored in temporary files
11
+ and file-like objects.
12
+ """
13
+ # XXX: better instead to have functions write to any given file-like object ?
14
+ # XXX: currently, all file-like objects are created by the function...
15
+
16
+ __all__ = ['dump_source', 'dump', 'dumpIO_source', 'dumpIO', \
17
+ 'load_source', 'load', 'loadIO_source', 'loadIO', \
18
+ 'capture']
19
+
20
+ import contextlib
21
+ from ._dill import PY3
22
+
23
+
24
+ @contextlib.contextmanager
25
+ def capture(stream='stdout'):
26
+ """builds a context that temporarily replaces the given stream name
27
+
28
+ >>> with capture('stdout') as out:
29
+ ... print "foo!"
30
+ ...
31
+ >>> print out.getvalue()
32
+ foo!
33
+
34
+ """
35
+ import sys
36
+ if PY3:
37
+ from io import StringIO
38
+ else:
39
+ from StringIO import StringIO
40
+ orig = getattr(sys, stream)
41
+ setattr(sys, stream, StringIO())
42
+ try:
43
+ yield getattr(sys, stream)
44
+ finally:
45
+ setattr(sys, stream, orig)
46
+
47
+
48
+ def b(x): # deal with b'foo' versus 'foo'
49
+ import codecs
50
+ return codecs.latin_1_encode(x)[0]
51
+
52
+
53
+ def load_source(file, **kwds):
54
+ """load an object that was stored with dill.temp.dump_source
55
+
56
+ file: filehandle
57
+ alias: string name of stored object
58
+ mode: mode to open the file, one of: {'r', 'rb'}
59
+
60
+ >>> f = lambda x: x**2
61
+ >>> pyfile = dill.temp.dump_source(f, alias='_f')
62
+ >>> _f = dill.temp.load_source(pyfile)
63
+ >>> _f(4)
64
+ 16
65
+ """
66
+ alias = kwds.pop('alias', None)
67
+ mode = kwds.pop('mode', 'r')
68
+ fname = getattr(file, 'name', file) # fname=file.name or fname=file (if str)
69
+ source = open(fname, mode=mode, **kwds).read()
70
+ if not alias:
71
+ tag = source.strip().splitlines()[-1].split()
72
+ if tag[0] != '#NAME:':
73
+ stub = source.splitlines()[0]
74
+ raise IOError("unknown name for code: %s" % stub)
75
+ alias = tag[-1]
76
+ local = {}
77
+ exec(source, local)
78
+ _ = eval("%s" % alias, local)
79
+ return _
80
+
81
+
82
+ def dump_source(object, **kwds):
83
+ """write object source to a NamedTemporaryFile (instead of dill.dump)
84
+ Loads with "import" or "dill.temp.load_source". Returns the filehandle.
85
+
86
+ >>> f = lambda x: x**2
87
+ >>> pyfile = dill.temp.dump_source(f, alias='_f')
88
+ >>> _f = dill.temp.load_source(pyfile)
89
+ >>> _f(4)
90
+ 16
91
+
92
+ >>> f = lambda x: x**2
93
+ >>> pyfile = dill.temp.dump_source(f, dir='.')
94
+ >>> modulename = os.path.basename(pyfile.name).split('.py')[0]
95
+ >>> exec('from %s import f as _f' % modulename)
96
+ >>> _f(4)
97
+ 16
98
+
99
+ Optional kwds:
100
+ If 'alias' is specified, the object will be renamed to the given string.
101
+
102
+ If 'prefix' is specified, the file name will begin with that prefix,
103
+ otherwise a default prefix is used.
104
+
105
+ If 'dir' is specified, the file will be created in that directory,
106
+ otherwise a default directory is used.
107
+
108
+ If 'text' is specified and true, the file is opened in text
109
+ mode. Else (the default) the file is opened in binary mode. On
110
+ some operating systems, this makes no difference.
111
+
112
+ NOTE: Keep the return value for as long as you want your file to exist !
113
+ """ # XXX: write a "load_source"?
114
+ from .source import importable, getname
115
+ import tempfile
116
+ kwds.pop('suffix', '') # this is *always* '.py'
117
+ alias = kwds.pop('alias', '') # XXX: include an alias so a name is known
118
+ name = str(alias) or getname(object)
119
+ name = "\n#NAME: %s\n" % name
120
+ # XXX: assumes kwds['dir'] is writable and on $PYTHONPATH
121
+ file = tempfile.NamedTemporaryFile(suffix='.py', **kwds)
122
+ file.write(b(''.join([importable(object, alias=alias), name])))
123
+ file.flush()
124
+ return file
125
+
126
+
127
+ def load(file, **kwds):
128
+ """load an object that was stored with dill.temp.dump
129
+
130
+ file: filehandle
131
+ mode: mode to open the file, one of: {'r', 'rb'}
132
+
133
+ >>> dumpfile = dill.temp.dump([1, 2, 3, 4, 5])
134
+ >>> dill.temp.load(dumpfile)
135
+ [1, 2, 3, 4, 5]
136
+ """
137
+ import dill as pickle
138
+ mode = kwds.pop('mode', 'rb')
139
+ name = getattr(file, 'name', file) # name=file.name or name=file (if str)
140
+ return pickle.load(open(name, mode=mode, **kwds))
141
+
142
+
143
+ def dump(object, **kwds):
144
+ """dill.dump of object to a NamedTemporaryFile.
145
+ Loads with "dill.temp.load". Returns the filehandle.
146
+
147
+ >>> dumpfile = dill.temp.dump([1, 2, 3, 4, 5])
148
+ >>> dill.temp.load(dumpfile)
149
+ [1, 2, 3, 4, 5]
150
+
151
+ Optional kwds:
152
+ If 'suffix' is specified, the file name will end with that suffix,
153
+ otherwise there will be no suffix.
154
+
155
+ If 'prefix' is specified, the file name will begin with that prefix,
156
+ otherwise a default prefix is used.
157
+
158
+ If 'dir' is specified, the file will be created in that directory,
159
+ otherwise a default directory is used.
160
+
161
+ If 'text' is specified and true, the file is opened in text
162
+ mode. Else (the default) the file is opened in binary mode. On
163
+ some operating systems, this makes no difference.
164
+
165
+ NOTE: Keep the return value for as long as you want your file to exist !
166
+ """
167
+ import dill as pickle
168
+ import tempfile
169
+ file = tempfile.NamedTemporaryFile(**kwds)
170
+ pickle.dump(object, file)
171
+ file.flush()
172
+ return file
173
+
174
+
175
+ def loadIO(buffer, **kwds):
176
+ """load an object that was stored with dill.temp.dumpIO
177
+
178
+ buffer: buffer object
179
+
180
+ >>> dumpfile = dill.temp.dumpIO([1, 2, 3, 4, 5])
181
+ >>> dill.temp.loadIO(dumpfile)
182
+ [1, 2, 3, 4, 5]
183
+ """
184
+ import dill as pickle
185
+ if PY3:
186
+ from io import BytesIO as StringIO
187
+ else:
188
+ from StringIO import StringIO
189
+ value = getattr(buffer, 'getvalue', buffer) # value or buffer.getvalue
190
+ if value != buffer: value = value() # buffer.getvalue()
191
+ return pickle.load(StringIO(value))
192
+
193
+
194
+ def dumpIO(object, **kwds):
195
+ """dill.dump of object to a buffer.
196
+ Loads with "dill.temp.loadIO". Returns the buffer object.
197
+
198
+ >>> dumpfile = dill.temp.dumpIO([1, 2, 3, 4, 5])
199
+ >>> dill.temp.loadIO(dumpfile)
200
+ [1, 2, 3, 4, 5]
201
+ """
202
+ import dill as pickle
203
+ if PY3:
204
+ from io import BytesIO as StringIO
205
+ else:
206
+ from StringIO import StringIO
207
+ file = StringIO()
208
+ pickle.dump(object, file)
209
+ file.flush()
210
+ return file
211
+
212
+
213
+ def loadIO_source(buffer, **kwds):
214
+ """load an object that was stored with dill.temp.dumpIO_source
215
+
216
+ buffer: buffer object
217
+ alias: string name of stored object
218
+
219
+ >>> f = lambda x:x**2
220
+ >>> pyfile = dill.temp.dumpIO_source(f, alias='_f')
221
+ >>> _f = dill.temp.loadIO_source(pyfile)
222
+ >>> _f(4)
223
+ 16
224
+ """
225
+ alias = kwds.pop('alias', None)
226
+ source = getattr(buffer, 'getvalue', buffer) # source or buffer.getvalue
227
+ if source != buffer: source = source() # buffer.getvalue()
228
+ if PY3: source = source.decode() # buffer to string
229
+ if not alias:
230
+ tag = source.strip().splitlines()[-1].split()
231
+ if tag[0] != '#NAME:':
232
+ stub = source.splitlines()[0]
233
+ raise IOError("unknown name for code: %s" % stub)
234
+ alias = tag[-1]
235
+ local = {}
236
+ exec(source, local)
237
+ _ = eval("%s" % alias, local)
238
+ return _
239
+
240
+
241
+ def dumpIO_source(object, **kwds):
242
+ """write object source to a buffer (instead of dill.dump)
243
+ Loads by with dill.temp.loadIO_source. Returns the buffer object.
244
+
245
+ >>> f = lambda x:x**2
246
+ >>> pyfile = dill.temp.dumpIO_source(f, alias='_f')
247
+ >>> _f = dill.temp.loadIO_source(pyfile)
248
+ >>> _f(4)
249
+ 16
250
+
251
+ Optional kwds:
252
+ If 'alias' is specified, the object will be renamed to the given string.
253
+ """
254
+ from .source import importable, getname
255
+ if PY3:
256
+ from io import BytesIO as StringIO
257
+ else:
258
+ from StringIO import StringIO
259
+ alias = kwds.pop('alias', '') # XXX: include an alias so a name is known
260
+ name = str(alias) or getname(object)
261
+ name = "\n#NAME: %s\n" % name
262
+ # XXX: assumes kwds['dir'] is writable and on $PYTHONPATH
263
+ file = StringIO()
264
+ file.write(b(''.join([importable(object, alias=alias), name])))
265
+ file.flush()
266
+ return file
267
+
268
+
269
+ del contextlib
270
+
271
+ # EOF
File without changes
File without changes
@@ -0,0 +1,19 @@
1
+ import json
2
+ import os
3
+ import sys
4
+
5
+ # dir_path is current file dir which is under "Assets" dir in COMPS
6
+ dir_path = os.path.dirname(os.path.realpath(__file__))
7
+ sys.path.append(os.path.join(dir_path, "MyExternalLibrary"))
8
+
9
+ # create 'output' dir in COMPS under current working dir which is one dir above "Assets" dir
10
+ output_dir = os.path.join(dir_path, "..", "output")
11
+ if not os.path.exists(output_dir):
12
+ os.mkdir(output_dir)
13
+
14
+ config = json.load(open(os.path.join(dir_path, "..", "config.json"), "r"))
15
+ print(config)
16
+
17
+ # write each configs to result.json in comps's simulation output
18
+ with open(os.path.join(output_dir, "result.json"), "w") as fp:
19
+ json.dump(config, fp)
@@ -0,0 +1 @@
1
+ print('Hello World!')
@@ -0,0 +1,26 @@
1
+ import os
2
+ import sys
3
+
4
+ CURRENT_DIRECTORY = os.path.dirname(__file__)
5
+ LIBRARY_PATH = os.path.join(CURRENT_DIRECTORY, 'site-packages') # Need to site-packages level!!!
6
+
7
+ """
8
+ sys.path.insert(0, LIBRARY_PATH) will search packages from experiment's 'Assets/site-packages' first,
9
+ then default HPC python site-packages.
10
+ "astor" package does not exist in comps, so we use custom_lib to upload to experiment's Assets/site-packages directory
11
+ Please go to examples/load_lib/example-load-lib.py to see how we upload 'astor' package to comps
12
+ """
13
+ sys.path.insert(0, LIBRARY_PATH)
14
+ sys.path.append(os.path.join(CURRENT_DIRECTORY))
15
+ print(sys.path)
16
+ from MyExternalLibrary.functions import add
17
+
18
+ if __name__ == "__main__":
19
+ import json
20
+
21
+ with open("config.json", 'r') as fp:
22
+ config = json.load(fp)
23
+ parameters = config["parameters"]
24
+
25
+ print(add(parameters["a"], parameters["b"]))
26
+ print(config["parameters"])
@@ -0,0 +1,20 @@
1
+ import json
2
+ import os
3
+ import sys
4
+
5
+ current_dir = os.path.abspath(os.getcwd())
6
+
7
+ # create 'output' dir in COMPS under current working dir which is one dir above "Assets" dir
8
+ output_dir = os.path.join(current_dir, "output")
9
+ config_path = os.path.join(current_dir, "config.json")
10
+ if not os.path.exists(output_dir):
11
+ os.mkdir(output_dir)
12
+
13
+ config = json.load(open(config_path, "r"))
14
+ print(config)
15
+
16
+ # write each configs to result.json in comps's simulation output
17
+ with open(os.path.join(output_dir, "result.json"), "w") as fp:
18
+ json.dump(config, fp)
19
+
20
+ sys.exit(0)
@@ -0,0 +1,21 @@
1
+ import os
2
+
3
+ from MyLib.functions import add
4
+ current_dir = os.path.abspath(os.getcwd())
5
+ if __name__ == "__main__":
6
+ import json
7
+
8
+ with open("config.json", 'r') as fp:
9
+ config = json.load(fp)
10
+ parameters = config["parameters"]
11
+
12
+ result = add(parameters["a"], parameters["b"])
13
+ print(result)
14
+ print(config["parameters"])
15
+
16
+ output_dir = os.path.join(current_dir, "output")
17
+ if not os.path.exists(output_dir):
18
+ os.mkdir(output_dir)
19
+ with open(os.path.join(output_dir, "result.txt"), "w") as fp:
20
+ fp.write("result:")
21
+ fp.write(str(result))
@@ -0,0 +1,20 @@
1
+ import json
2
+ import os
3
+ import sys
4
+
5
+ if __name__ == "__main__":
6
+ current_directory = os.path.abspath(os.getcwd())
7
+ with open("config.json", 'r') as fp:
8
+ config = json.load(fp)
9
+ run_number = config["a"]
10
+
11
+ os.makedirs(os.path.join(current_directory, "output"))
12
+ with open(os.path.join(current_directory, "output", "output.json"), 'w') as fp:
13
+ json.dump({"a": run_number}, fp)
14
+ print("Simulation running with Run_Number = " + str(run_number))
15
+
16
+ # The local platform needs to know the resulting status of a work item. We provide it through a return code
17
+ # print(f"Simulation running with Run_Number = {run_number}")
18
+ # 0 means succeeded. Any other value is an error. It is optional if you want to provide specific return codes
19
+ # for specific errors
20
+ sys.exit(0)
@@ -0,0 +1,39 @@
1
+ import argparse
2
+ import random
3
+ from logging import getLogger, basicConfig
4
+
5
+ CHUNK_GENERATION_SIZE = 1048576 * 4
6
+ basicConfig()
7
+ logger = getLogger()
8
+
9
+
10
+ def generate_chunk(filename: str, total_bytes: int):
11
+ logger.info(f"Writing chunk of {total_bytes} to {filename}")
12
+ with open(filename, 'wb') as out:
13
+ total_written = 0
14
+ while total_written < total_bytes:
15
+ # Write in 1 mb segments
16
+ if total_written + CHUNK_GENERATION_SIZE > total_bytes:
17
+ ws = total_bytes - total_written
18
+ else:
19
+ ws = CHUNK_GENERATION_SIZE
20
+ out.write(bytearray(random.getrandbits(8) for _ in range(ws)))
21
+ total_written += CHUNK_GENERATION_SIZE
22
+
23
+
24
+ def generate_chunks(total_chunks: int, chunk_size: int, chunk_name: str):
25
+ logger.info(f"Writing {total_chunks} chunks")
26
+ for i in range(total_chunks):
27
+ fn = chunk_name.format(idx=i)
28
+ generate_chunk(fn, chunk_size)
29
+
30
+
31
+ if __name__ == "__main__":
32
+ random.seed()
33
+ parser = argparse.ArgumentParser()
34
+ parser.add_argument("--chunk-size", default=1024 * 256, type=int)
35
+ parser.add_argument("--chunks", default=100, type=int)
36
+ parser.add_argument("--chunk-name", default="{idx:05d}.chunk")
37
+
38
+ args = parser.parse_args()
39
+ generate_chunks(args.chunks, args.chunk_size, args.chunk_name)
@@ -0,0 +1,6 @@
1
+ import os
2
+
3
+ # This file is used to verify consistent file paths for realpath across platforms
4
+
5
+ dir_path = os.path.dirname(os.path.realpath(__file__))
6
+ print(dir_path)