experimaestro 1.5.14__py3-none-any.whl → 1.6.1__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 (32) hide show
  1. experimaestro/core/objects.py +8 -2
  2. experimaestro/experiments/cli.py +71 -35
  3. experimaestro/experiments/configuration.py +7 -1
  4. {experimaestro-1.5.14.dist-info → experimaestro-1.6.1.dist-info}/METADATA +2 -3
  5. {experimaestro-1.5.14.dist-info → experimaestro-1.6.1.dist-info}/RECORD +8 -32
  6. {experimaestro-1.5.14.dist-info → experimaestro-1.6.1.dist-info}/WHEEL +1 -1
  7. experimaestro/server/data/016b4a6cdced82ab3aa1.ttf +0 -0
  8. experimaestro/server/data/0c35d18bf06992036b69.woff2 +0 -0
  9. experimaestro/server/data/219aa9140e099e6c72ed.woff2 +0 -0
  10. experimaestro/server/data/3a4004a46a653d4b2166.woff +0 -0
  11. experimaestro/server/data/3baa5b8f3469222b822d.woff +0 -0
  12. experimaestro/server/data/4d73cb90e394b34b7670.woff +0 -0
  13. experimaestro/server/data/4ef4218c522f1eb6b5b1.woff2 +0 -0
  14. experimaestro/server/data/50701fbb8177c2dde530.ttf +0 -0
  15. experimaestro/server/data/5d681e2edae8c60630db.woff +0 -0
  16. experimaestro/server/data/6f420cf17cc0d7676fad.woff2 +0 -0
  17. experimaestro/server/data/878f31251d960bd6266f.woff2 +0 -0
  18. experimaestro/server/data/b041b1fa4fe241b23445.woff2 +0 -0
  19. experimaestro/server/data/b6879d41b0852f01ed5b.woff2 +0 -0
  20. experimaestro/server/data/c380809fd3677d7d6903.woff2 +0 -0
  21. experimaestro/server/data/d75e3fd1eb12e9bd6655.ttf +0 -0
  22. experimaestro/server/data/f882956fd323fd322f31.woff +0 -0
  23. experimaestro/server/data/favicon.ico +0 -0
  24. experimaestro/server/data/index.css +0 -22844
  25. experimaestro/server/data/index.css.map +0 -1
  26. experimaestro/server/data/index.html +0 -27
  27. experimaestro/server/data/index.js +0 -100947
  28. experimaestro/server/data/index.js.map +0 -1
  29. experimaestro/server/data/login.html +0 -22
  30. experimaestro/server/data/manifest.json +0 -15
  31. {experimaestro-1.5.14.dist-info → experimaestro-1.6.1.dist-info}/LICENSE +0 -0
  32. {experimaestro-1.5.14.dist-info → experimaestro-1.6.1.dist-info}/entry_points.txt +0 -0
@@ -1340,8 +1340,14 @@ class ConfigInformation:
1340
1340
  sys.modules[module_name] = mod
1341
1341
  spec.loader.exec_module(mod)
1342
1342
  else:
1343
- logger.debug("Importing module %s", definition["module"])
1344
- mod = importlib.import_module(module_name)
1343
+ try:
1344
+ logger.debug("Importing module %s", definition["module"])
1345
+ mod = importlib.import_module(module_name)
1346
+ except ModuleNotFoundError:
1347
+ # More hints on the nature of the error
1348
+ logging.warning("(1) Either the python path is wrong – %s", ":".join(sys.path))
1349
+ logging.warning("(2) There is not __init__.py in your module")
1350
+ raise
1345
1351
 
1346
1352
  cls = getqualattr(mod, definition["type"])
1347
1353
 
@@ -1,4 +1,5 @@
1
1
  import imp
2
+ import importlib
2
3
  import inspect
3
4
  import json
4
5
  import logging
@@ -55,18 +56,29 @@ class ExperimentCallable(Protocol):
55
56
  ...
56
57
 
57
58
 
58
- def load(yaml_file: Path):
59
- """Loads a YAML file, and parents one if they exist"""
60
- if not yaml_file.exists() and yaml_file.suffix != ".yaml":
61
- yaml_file = yaml_file.with_suffix(".yaml")
59
+ class ConfigurationLoader:
60
+ def __init__(self):
61
+ self.yamls = []
62
+ self.pythonpath = set()
62
63
 
63
- with yaml_file.open("rt") as fp:
64
- _data = yaml.full_load(fp)
65
- data = [_data]
66
- if parent := _data.get("parent", None):
67
- data.extend(load(yaml_file.parent / parent))
64
+ def load(self, yaml_file: Path):
65
+ """Loads a YAML file, and parents one if they exist"""
66
+ if not yaml_file.exists() and yaml_file.suffix != ".yaml":
67
+ yaml_file = yaml_file.with_suffix(".yaml")
68
68
 
69
- return data[::-1]
69
+ with yaml_file.open("rt") as fp:
70
+ _data = yaml.full_load(fp)
71
+ if parent := _data.get("parent", None):
72
+ self.load(yaml_file.parent / parent)
73
+
74
+ self.yamls.append(_data)
75
+
76
+ for path in _data.get("pythonpath", []):
77
+ path = Path(path)
78
+ if path.is_absolute():
79
+ self.pythonpath.add(path.resolve())
80
+ else:
81
+ self.pythonpath.add((yaml_file.parent / path).resolve())
70
82
 
71
83
 
72
84
  @click.option("--debug", is_flag=True, help="Print debug information")
@@ -106,6 +118,9 @@ def load(yaml_file: Path):
106
118
  @click.option(
107
119
  "--file", "xp_file", help="The file containing the main experimental code"
108
120
  )
121
+ @click.option(
122
+ "--module-name", "module_name", help="Module containing the experimental code"
123
+ )
109
124
  @click.option(
110
125
  "--workspace",
111
126
  type=str,
@@ -141,31 +156,49 @@ def experiments_cli( # noqa: C901
141
156
  extra_conf: List[str],
142
157
  pre_yaml: List[str],
143
158
  post_yaml: List[str],
159
+ module_name: Optional[str],
144
160
  args: List[str],
145
161
  show: bool,
146
162
  debug: bool,
147
163
  ):
148
164
  """Run an experiment"""
165
+
149
166
  # --- Set the logger
150
167
  logging.getLogger().setLevel(logging.DEBUG if debug else logging.INFO)
151
168
  logging.getLogger("xpm.hash").setLevel(logging.INFO)
152
169
 
153
170
  # --- Loads the YAML
154
- yamls = []
171
+ conf_loader = ConfigurationLoader()
155
172
  for y in pre_yaml:
156
- yamls.extend(load(Path(y)))
157
- yamls.extend(load(Path(yaml_file)))
173
+ conf_loader.load(Path(y))
174
+ conf_loader.load(Path(yaml_file))
158
175
  for y in post_yaml:
159
- yamls.extend(load(Path(y)))
176
+ conf_loader.load(Path(y))
177
+
178
+ # --- Merge the YAMLs
179
+ configuration = OmegaConf.merge(*conf_loader.yamls)
180
+ if extra_conf:
181
+ configuration.merge_with(OmegaConf.from_dotlist(extra_conf))
160
182
 
161
183
  # --- Get the XP file
162
- if xp_file is None:
163
- for data in yamls[::-1]:
164
- if xp_file := data.get("file", None):
165
- break
184
+ pythonpath = list(conf_loader.pythonpath)
185
+ if module_name is None:
186
+ module_name = configuration.get("module", None)
166
187
 
167
- if xp_file is None:
168
- raise ValueError("No experiment file given")
188
+ if xp_file is None:
189
+ xp_file = configuration.get("file", None)
190
+ if xp_file:
191
+ assert (
192
+ not module_name
193
+ ), "Module name and experiment file are mutually exclusive options"
194
+ xp_file = Path(xp_file)
195
+ if not pythonpath:
196
+ pythonpath.append(xp_file.parent)
197
+ logging.info("Using python path: %s", ", ".join(str(s) for s in pythonpath))
198
+
199
+ assert (
200
+ module_name or xp_file
201
+ ), "Either the module name or experiment file should be given"
169
202
 
170
203
  # --- Set some options
171
204
 
@@ -173,23 +206,29 @@ def experiments_cli( # noqa: C901
173
206
  assert xpm_config_dir.is_dir()
174
207
  LauncherRegistry.set_config_dir(xpm_config_dir)
175
208
 
176
- # --- Loads the XP file
177
- xp_file = Path(xp_file)
178
- if not xp_file.exists() and xp_file.suffix != ".py":
179
- xp_file = xp_file.with_suffix(".py")
180
- xp_file: Path = Path(yaml_file).parent / xp_file
181
-
182
209
  # --- Finds the "run" function
183
- try:
184
- sys.path.append(str(xp_file.parent.absolute()))
210
+
211
+ # Modifies the Python path
212
+ for path in pythonpath:
213
+ sys.path.append(str(path))
214
+
215
+ if xp_file:
216
+ if not xp_file.exists() and xp_file.suffix != ".py":
217
+ xp_file = xp_file.with_suffix(".py")
218
+ xp_file: Path = Path(yaml_file).parent / xp_file
185
219
  with open(xp_file) as src:
186
220
  module_name = xp_file.with_suffix("").name
187
221
  mod = imp.load_module(
188
- module_name, src, str(xp_file.absolute()), (".py", "r", imp.PY_SOURCE)
222
+ module_name,
223
+ src,
224
+ str(xp_file.absolute()),
225
+ (".py", "r", imp.PY_SOURCE),
189
226
  )
190
- helper = getattr(mod, "run", None)
191
- finally:
192
- sys.path.pop()
227
+ else:
228
+ # Module
229
+ mod = importlib.import_module(module_name)
230
+
231
+ helper = getattr(mod, "run", None)
193
232
 
194
233
  # --- ... and runs it
195
234
  if helper is None:
@@ -208,9 +247,6 @@ def experiments_cli( # noqa: C901
208
247
  schema = list_parameters[1].annotation
209
248
  omegaconf_schema = OmegaConf.structured(schema())
210
249
 
211
- configuration = OmegaConf.merge(*yamls)
212
- if extra_conf:
213
- configuration.merge_with(OmegaConf.from_dotlist(extra_conf))
214
250
  if omegaconf_schema is not None:
215
251
  try:
216
252
  configuration = OmegaConf.merge(omegaconf_schema, configuration)
@@ -1,5 +1,5 @@
1
1
  from omegaconf import MISSING
2
- from typing import Optional
2
+ from typing import Optional, List
3
3
  import attr
4
4
 
5
5
  try:
@@ -31,6 +31,12 @@ class ConfigurationBase:
31
31
  file: str = "experiment"
32
32
  """Relative path of the file containing a run function"""
33
33
 
34
+ module: Optional[str] = None
35
+ """Relative path of the file containing a run function"""
36
+
37
+ pythonpath: Optional[List[str]] = None
38
+ """Python path relative to the parent directory of the YAML file"""
39
+
34
40
  parent: Optional[str] = None
35
41
  """Relative path of a YAML file that should be merged"""
36
42
 
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: experimaestro
3
- Version: 1.5.14
3
+ Version: 1.6.1
4
4
  Summary: "Experimaestro is a computer science experiment manager"
5
- Home-page: https://github.com/experimaestro/experimaestro-python
6
5
  License: GPL-3
7
6
  Keywords: experiment manager
8
7
  Author: Benjamin Piwowarski
@@ -14,7 +14,7 @@ experimaestro/connectors/ssh.py,sha256=P6XfCdC4mQTsFzgI-dEdx6AdVhwd0T6VrQpPmNpmi
14
14
  experimaestro/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  experimaestro/core/arguments.py,sha256=dW32opqNEsULYr6nR7Zk8PqHsSCbLPclfXofw27GTpI,5620
16
16
  experimaestro/core/context.py,sha256=Q8_ngiHRBZ0laavXRJNiDvdCprrnROVTWaHfrwMdlG4,2638
17
- experimaestro/core/objects.py,sha256=M6g2f3klT0Z913yniwKBakChUKGnb2dOoW3hJHZi7do,64305
17
+ experimaestro/core/objects.py,sha256=Oh9S85enB_cuQhFxZqwNoJMcrbuPoESdTdEDcO4tAqM,64649
18
18
  experimaestro/core/objects.pyi,sha256=Adi2OKCW0-B9GROlEUgxxBDK6SHUqccTBHTofRRJE9M,7131
19
19
  experimaestro/core/serialization.py,sha256=9tg5ebLF3YeZ_zG9DiTHPLthppvo7io710ohD_dcLTo,3836
20
20
  experimaestro/core/serializers.py,sha256=R_CAMyjjfU1oi-eHU6VlEUixJpFayGqEPaYu7VsD9xA,1197
@@ -22,8 +22,8 @@ experimaestro/core/types.py,sha256=8alVqTA7aeIZ3FAaDux8IwoRPDbwVxzONVqnAL1A6QI,2
22
22
  experimaestro/core/utils.py,sha256=JfC3qGUS9b6FUHc2VxIYUI9ysNpXSQ1LjOBkjfZ8n7o,495
23
23
  experimaestro/exceptions.py,sha256=cUy83WHM3GeynxmMk6QRr5xsnpqUAdAoc-m3KQVrE2o,44
24
24
  experimaestro/experiments/__init__.py,sha256=GcpDUIbCvhnv6rxFdAp4wTffCVNTv-InY6fbQAlTy-o,159
25
- experimaestro/experiments/cli.py,sha256=tMMtfAkewj8jAPseXD1RBePBt10XWRItQ9TkKhV18yY,7228
26
- experimaestro/experiments/configuration.py,sha256=8GRqyLG1leF_NbvbFzqpm0yM24O0WjSNmQzvnuLnxxw,1150
25
+ experimaestro/experiments/cli.py,sha256=AS6LcbY3O8tkQ8X-ushZcRVdLt1WbykwGP8CZ2BfgMw,8371
26
+ experimaestro/experiments/configuration.py,sha256=cFDiUHnUGblJsctAUxAqx0jlM7_Ja_527lzk-4G-44k,1368
27
27
  experimaestro/generators.py,sha256=9NQ_TfDfASkArLnO4PF7s5Yoo9KWjlna2DCPzk5gJOI,1230
28
28
  experimaestro/huggingface.py,sha256=gnVlr6SZnbutYz4PLH0Q77n1TRF-uk-dR-3UFzFqAY0,2956
29
29
  experimaestro/ipc.py,sha256=ltYqybPm_XfcQC3yiskMfhfI_1dREs-XRu0F83YsNws,1490
@@ -55,30 +55,6 @@ experimaestro/scheduler/services.py,sha256=aCKkNZMULlceabqf-kOs_-C7KPINnjU3Q-I00
55
55
  experimaestro/scheduler/workspace.py,sha256=vyVbYZML28zvmgxfWc2PsKKHGlrAejY43UYlttbm9AU,2280
56
56
  experimaestro/scriptbuilder.py,sha256=WokCsXjmsVsx9mD6-sJdsBI6lD6xNMXUz1YvAnb7e10,4533
57
57
  experimaestro/server/__init__.py,sha256=F2bzLf2q29Haj2OIbPA26r5WVbaipBNylIozg-As758,10854
58
- experimaestro/server/data/016b4a6cdced82ab3aa1.ttf,sha256=AD8RVBhWpkmmyCNcYmbIk2IkxdYJ5RRC2iTcVVbRT78,189684
59
- experimaestro/server/data/0c35d18bf06992036b69.woff2,sha256=gmX2R4Y5fWuDLRygqv3xSa2E5ydZ__qfcnLpGg-wFdE,128352
60
- experimaestro/server/data/219aa9140e099e6c72ed.woff2,sha256=0xv7gdVueQ4Nni-gC4Pfj3FZ-QYxFM3AFIWbHUg5Vsg,135984
61
- experimaestro/server/data/3a4004a46a653d4b2166.woff,sha256=-jiI7_pbxjPGuygaSdiSf-eqACEsn8D3M4yBnsXMFu4,156236
62
- experimaestro/server/data/3baa5b8f3469222b822d.woff,sha256=PTTzCsa7Ivpb9Y0-Uue7bezZnFcdanfV36e-eL7PK1A,339600
63
- experimaestro/server/data/4d73cb90e394b34b7670.woff,sha256=_YT4i0lwQNT31ejJ-GNa740-cGwPpS4rb6zxTu6H5SI,164912
64
- experimaestro/server/data/4ef4218c522f1eb6b5b1.woff2,sha256=Hmc7qFiWVHlNKtN1woc_GHCkV48rPoR9zEB63QO1esI,215704
65
- experimaestro/server/data/50701fbb8177c2dde530.ttf,sha256=fYGhp8wH4asZbkBJbT9DWel1n3nY7Ig6Rmde5pkSlQs,63348
66
- experimaestro/server/data/5d681e2edae8c60630db.woff,sha256=HBNbFRpB4jE4sy0wZePw6rIwpnrv6SXplwnL4QK9YEw,206260
67
- experimaestro/server/data/6f420cf17cc0d7676fad.woff2,sha256=NdyopxRaF8jRMG8lo8oJFXjhU5bwsi1h645zJirHVXc,155276
68
- experimaestro/server/data/878f31251d960bd6266f.woff2,sha256=-q5vwKqUzFveUHZkfIF6IyBglqHL7aENHG89idYWPtE,109808
69
- experimaestro/server/data/b041b1fa4fe241b23445.woff2,sha256=kWnYvnqBd-WpKk0Ett5_ZQS5OFc79NpYiYccTzdtOEk,24488
70
- experimaestro/server/data/b6879d41b0852f01ed5b.woff2,sha256=iGyGESqATvHd0csgavTIxA40tzwmZSyiMUBKo1prMNk,150020
71
- experimaestro/server/data/c380809fd3677d7d6903.woff2,sha256=yUjxJjNBaZs8HpxV2NDz5EZmnQ8rnVVJTGFpIiwCQ6Y,173620
72
- experimaestro/server/data/d75e3fd1eb12e9bd6655.ttf,sha256=zqebNFyvSdYiMJi4orBNcCc-jXxrnj0Dz396JneT6ao,394668
73
- experimaestro/server/data/f882956fd323fd322f31.woff,sha256=jpR1jFTCboWqzy09yhrXqtpZBKRgI4-uSEPrxEvELtw,182028
74
- experimaestro/server/data/favicon.ico,sha256=PRD32mxgMXg0AIFmjErFs66XQ8qaJiqw_NMS-7n0i90,3870
75
- experimaestro/server/data/index.css,sha256=JTjLM7vCHt6ShbNYXZ27MJsYcX_KNuVVwg05OcTfqmU,418843
76
- experimaestro/server/data/index.css.map,sha256=ieCWV1uODCJdH3Lgoekp2WGaphqZird27UsGqFlzEI0,576970
77
- experimaestro/server/data/index.html,sha256=LcXSo2QU5jcmqgmFhVWWOG_CfGyrqdm3H8jwkdRgdGU,706
78
- experimaestro/server/data/index.js,sha256=f0GvRsfsQ4ayP4en7Q-raZ6buwRXLCswCbzVaxQEDWY,3734128
79
- experimaestro/server/data/index.js.map,sha256=za3MUIjzyyGRI6F5KuBFMTgrFU55xgt0LBrw-4YPHag,3904832
80
- experimaestro/server/data/login.html,sha256=4dvhSOn6DHp_tbmzqIKrqq2uAo0sAUbgLVD0lTnPp4s,511
81
- experimaestro/server/data/manifest.json,sha256=EpzHQZzrGh9c1Kf63nrqvI33H1cm0nLYfdh5lDm8ijI,318
82
58
  experimaestro/settings.py,sha256=UsfKIA4Jx-32hm3xGjBs_b9uvw8M7sOYtzFyUsYSJ8s,3145
83
59
  experimaestro/sphinx/__init__.py,sha256=heovvtwbYToZM-b6HNi4pJdBoo_97usdEawhMGSK3bk,9560
84
60
  experimaestro/sphinx/static/experimaestro.css,sha256=0rEgt1LoDdD-a_R5rVfWZ19zD1gR-1L7q3f4UibIB58,294
@@ -139,8 +115,8 @@ experimaestro/utils/jupyter.py,sha256=JcEo2yQK7x3Cr1tNl5FqGMZOICxCv9DwMvL5xsWdQP
139
115
  experimaestro/utils/resources.py,sha256=MaCQL9dLfze3lwyuBVeWF7Ki5fFSE1F0BGWrfaaHi1I,1135
140
116
  experimaestro/utils/settings.py,sha256=jpFMqF0DLL4_P1xGal0zVR5cOrdD8O0Y2IOYvnRgN3k,793
141
117
  experimaestro/xpmutils.py,sha256=S21eMbDYsHfvmZ1HmKpq5Pz5O-1HnCLYxKbyTBbASyQ,638
142
- experimaestro-1.5.14.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
143
- experimaestro-1.5.14.dist-info/METADATA,sha256=jEbKxGTumDrr8CB6aAz50WUx7yel7Kvp3xQiSBX14aw,6286
144
- experimaestro-1.5.14.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
145
- experimaestro-1.5.14.dist-info/entry_points.txt,sha256=TppTNiz5qm5xm1fhAcdLKdCLMrlL-eQggtCrCI00D9c,446
146
- experimaestro-1.5.14.dist-info/RECORD,,
118
+ experimaestro-1.6.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
119
+ experimaestro-1.6.1.dist-info/METADATA,sha256=23LdSFk3UzGvwsUqh3GLk_g-VTqZ_qvJa6SAYHXDGiI,6220
120
+ experimaestro-1.6.1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
121
+ experimaestro-1.6.1.dist-info/entry_points.txt,sha256=TppTNiz5qm5xm1fhAcdLKdCLMrlL-eQggtCrCI00D9c,446
122
+ experimaestro-1.6.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
Binary file