experimaestro 1.6.0__py3-none-any.whl → 1.6.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.

Potentially problematic release.


This version of experimaestro might be problematic. Click here for more details.

@@ -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
 
@@ -59,7 +59,7 @@ class ExperimentCallable(Protocol):
59
59
  class ConfigurationLoader:
60
60
  def __init__(self):
61
61
  self.yamls = []
62
- self.pythonpath = set()
62
+ self.python_path = set()
63
63
 
64
64
  def load(self, yaml_file: Path):
65
65
  """Loads a YAML file, and parents one if they exist"""
@@ -76,9 +76,9 @@ class ConfigurationLoader:
76
76
  for path in _data.get("pythonpath", []):
77
77
  path = Path(path)
78
78
  if path.is_absolute():
79
- self.pythonpath.add(path.resolve())
79
+ self.python_path.add(path.resolve())
80
80
  else:
81
- self.pythonpath.add((yaml_file.parent / path).resolve())
81
+ self.python_path.add((yaml_file.parent / path).resolve())
82
82
 
83
83
 
84
84
  @click.option("--debug", is_flag=True, help="Print debug information")
@@ -181,7 +181,7 @@ def experiments_cli( # noqa: C901
181
181
  configuration.merge_with(OmegaConf.from_dotlist(extra_conf))
182
182
 
183
183
  # --- Get the XP file
184
- pythonpath = list(conf_loader.pythonpath)
184
+ python_path = list(conf_loader.python_path)
185
185
  if module_name is None:
186
186
  module_name = configuration.get("module", None)
187
187
 
@@ -192,9 +192,9 @@ def experiments_cli( # noqa: C901
192
192
  not module_name
193
193
  ), "Module name and experiment file are mutually exclusive options"
194
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))
195
+ if not python_path:
196
+ python_path.append(xp_file.parent)
197
+ logging.info("Using python path: %s", ", ".join(str(s) for s in python_path))
198
198
 
199
199
  assert (
200
200
  module_name or xp_file
@@ -208,29 +208,31 @@ def experiments_cli( # noqa: C901
208
208
 
209
209
  # --- Finds the "run" function
210
210
 
211
- try:
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
219
- with open(xp_file) as src:
220
- module_name = xp_file.with_suffix("").name
221
- mod = imp.load_module(
222
- module_name,
223
- src,
224
- str(xp_file.absolute()),
225
- (".py", "r", imp.PY_SOURCE),
226
- )
227
- else:
228
- # Module
211
+ # Modifies the Python path
212
+ for path in python_path:
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
219
+ with open(xp_file) as src:
220
+ module_name = xp_file.with_suffix("").name
221
+ mod = imp.load_module(
222
+ module_name,
223
+ src,
224
+ str(xp_file.absolute()),
225
+ (".py", "r", imp.PY_SOURCE),
226
+ )
227
+ else:
228
+ # Module
229
+ try:
229
230
  mod = importlib.import_module(module_name)
231
+ except ModuleNotFoundError as e:
232
+ logging.error("Module not found: %s with python path %s", e, sys.path)
233
+ raise
230
234
 
231
- helper = getattr(mod, "run", None)
232
- finally:
233
- pass
235
+ helper = getattr(mod, "run", None)
234
236
 
235
237
  # --- ... and runs it
236
238
  if helper is None:
@@ -267,10 +269,11 @@ def experiments_cli( # noqa: C901
267
269
 
268
270
  # Define the workspace
269
271
  ws_env = find_workspace(workdir=workdir, workspace=workspace)
272
+
270
273
  workdir = ws_env.path
271
274
 
272
275
  logging.info("Using working directory %s", str(workdir.resolve()))
273
-
276
+
274
277
  # --- Runs the experiment
275
278
  with experiment(
276
279
  ws_env, configuration.id, host=host, port=port, run_mode=run_mode
@@ -280,6 +283,9 @@ def experiments_cli( # noqa: C901
280
283
  for key, value in env:
281
284
  xp.setenv(key, value)
282
285
 
286
+ # Sets the python path
287
+ xp.workspace.python_path.extend(python_path)
288
+
283
289
  try:
284
290
  # Run the experiment
285
291
  helper.xp = xp
@@ -1,12 +1,13 @@
1
1
  from collections import ChainMap
2
2
  from functools import cached_property
3
+ import itertools
3
4
  import logging
4
5
  import os
5
6
  from pathlib import Path
6
7
  from shutil import rmtree
7
8
  import threading
8
9
  import time
9
- from typing import Any, List, Optional, Set, TypeVar, Union, TYPE_CHECKING
10
+ from typing import Any, Iterator, List, Optional, Set, TypeVar, Union, TYPE_CHECKING
10
11
  import enum
11
12
  import signal
12
13
  import asyncio
@@ -166,6 +167,13 @@ class Job(Resource):
166
167
  assert self._future, "Cannot wait a not submitted job"
167
168
  return self._future.result()
168
169
 
170
+ @cached_property
171
+ def python_path(self) -> Iterator[str]:
172
+ """Returns an iterator over python path"""
173
+ return itertools.chain(
174
+ self.workspace.python_path
175
+ )
176
+
169
177
  @cached_property
170
178
  def environ(self):
171
179
  """Returns the job environment
@@ -2,7 +2,7 @@ from collections import ChainMap
2
2
  from enum import Enum
3
3
  from functools import cached_property
4
4
  from pathlib import Path
5
- from typing import Optional
5
+ from typing import Iterator, Optional
6
6
  from experimaestro.settings import WorkspaceSettings, Settings
7
7
 
8
8
 
@@ -46,6 +46,7 @@ class Workspace:
46
46
  path = path.absolute()
47
47
  self.path = path
48
48
  self.run_mode = run_mode
49
+ self.python_path = []
49
50
  from ..launchers import Launcher
50
51
 
51
52
  self.launcher = launcher or Launcher.get(path)
@@ -94,6 +94,7 @@ class PythonScriptBuilder:
94
94
  out.write("# Experimaestro generated task\n\n")
95
95
  out.write(
96
96
  """import logging\n"""
97
+ """import sys\n"""
97
98
  """logging.basicConfig(level=logging.INFO, """
98
99
  """format='%(levelname)s:%(process)d:%(asctime)s [%(name)s] %(message)s', datefmt='%y-%m-%d %H:%M:%S')\n\n"""
99
100
  )
@@ -112,9 +113,17 @@ class PythonScriptBuilder:
112
113
  out.write(" ]\n")
113
114
 
114
115
  for name, value in job.environ.items():
115
- out.write(f""" os.environ["{name}"] = "{shquote(value)}"\n""")
116
+ if name == "PYTHONPATH":
117
+ # Handles properly python path
118
+ for path in value.split(":"):
119
+ out.write(f""" sys.path.insert(0, "{shquote(path)}")\n""")
120
+ else:
121
+ out.write(f""" os.environ["{name}"] = "{shquote(value)}"\n""")
116
122
  out.write("\n")
117
123
 
124
+ for path in job.python_path:
125
+ out.write(f""" sys.path.insert(0, "{shquote(str(path))}")\n""")
126
+
118
127
  out.write(
119
128
  f""" TaskRunner("{shquote(connector.resolve(scriptpath))}","""
120
129
  """ lockfiles).run()\n"""
experimaestro/settings.py CHANGED
@@ -37,7 +37,7 @@ class WorkspaceSettings:
37
37
 
38
38
  alt_workspaces: List[str] = field(default_factory=list)
39
39
  """Alternative workspaces to find jobs or experiments"""
40
-
40
+
41
41
  def __post_init__(self):
42
42
  self.path = self.path.expanduser().resolve()
43
43
 
@@ -83,7 +83,7 @@ def get_workspace(id: Optional[str] = None) -> Optional[WorkspaceSettings]:
83
83
  return None
84
84
 
85
85
 
86
- def find_workspace(*, workspace: Optional[str] = None, workdir: Optional[Path] = None):
86
+ def find_workspace(*, workspace: Optional[str] = None, workdir: Optional[Path] = None) -> WorkspaceSettings:
87
87
  """Find workspace"""
88
88
  workdir = Path(workdir) if workdir else None
89
89
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: experimaestro
3
- Version: 1.6.0
3
+ Version: 1.6.2
4
4
  Summary: "Experimaestro is a computer science experiment manager"
5
5
  License: GPL-3
6
6
  Keywords: experiment manager
@@ -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,7 +22,7 @@ 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=Uu9GlCrwBvyp_sxmO4VLLcSwVVquKfdlYrxCXhlN7Kc,8447
25
+ experimaestro/experiments/cli.py,sha256=IyoYL2tBR33tI2bxLD0Z5fwXlyTQH626eFE8NAws-VE,8633
26
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
@@ -49,13 +49,13 @@ experimaestro/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
49
  experimaestro/rpyc.py,sha256=ZRKol-3tVoeoUITLNFenLF4dhWBLW_FvSV_GvsypmeI,3605
50
50
  experimaestro/run.py,sha256=NTFORDb_RlEK6tWKa7K-_2_bGCdHzzjBJVH5C1ReYtw,5222
51
51
  experimaestro/scheduler/__init__.py,sha256=ERmmOxz_9mUkIuccNbzUa5Y6gVLLVDdyc4cCxbCCUbY,20
52
- experimaestro/scheduler/base.py,sha256=XGq8kokNycba5D-KYKrNZ3WcXWKDUxusTkgR-X9S0E0,31941
52
+ experimaestro/scheduler/base.py,sha256=z2npreB_MiE-mjZgxLSYFSMh8Ugns_AlyaNPY-BRw8U,32174
53
53
  experimaestro/scheduler/dependencies.py,sha256=n9XegwrmjayOIxt3xhuTEBVEBGSq4oeVdzz-FviDGXo,1994
54
54
  experimaestro/scheduler/services.py,sha256=aCKkNZMULlceabqf-kOs_-C7KPINnjU3Q-I00o5x6iY,2189
55
- experimaestro/scheduler/workspace.py,sha256=vyVbYZML28zvmgxfWc2PsKKHGlrAejY43UYlttbm9AU,2280
56
- experimaestro/scriptbuilder.py,sha256=WokCsXjmsVsx9mD6-sJdsBI6lD6xNMXUz1YvAnb7e10,4533
55
+ experimaestro/scheduler/workspace.py,sha256=KNdxPBwUk7gO8h2utMCrlIVKB-f2Ylqg_IxLc4okp_8,2320
56
+ experimaestro/scriptbuilder.py,sha256=nLtwZG136mcji3UhbUDNw4Wj8nbHcj1XysZ2f0_A8eQ,4947
57
57
  experimaestro/server/__init__.py,sha256=F2bzLf2q29Haj2OIbPA26r5WVbaipBNylIozg-As758,10854
58
- experimaestro/settings.py,sha256=UsfKIA4Jx-32hm3xGjBs_b9uvw8M7sOYtzFyUsYSJ8s,3145
58
+ experimaestro/settings.py,sha256=U6gTVBL5Z4Rk0_7BAVoavVJKN2sQNRpspE-601Elfys,3170
59
59
  experimaestro/sphinx/__init__.py,sha256=heovvtwbYToZM-b6HNi4pJdBoo_97usdEawhMGSK3bk,9560
60
60
  experimaestro/sphinx/static/experimaestro.css,sha256=0rEgt1LoDdD-a_R5rVfWZ19zD1gR-1L7q3f4UibIB58,294
61
61
  experimaestro/taskglobals.py,sha256=aBjPpo4HQp6E6M3GQ8L6PR4rK2Lu0kD5dS1WjnaGgDc,499
@@ -115,8 +115,8 @@ experimaestro/utils/jupyter.py,sha256=JcEo2yQK7x3Cr1tNl5FqGMZOICxCv9DwMvL5xsWdQP
115
115
  experimaestro/utils/resources.py,sha256=MaCQL9dLfze3lwyuBVeWF7Ki5fFSE1F0BGWrfaaHi1I,1135
116
116
  experimaestro/utils/settings.py,sha256=jpFMqF0DLL4_P1xGal0zVR5cOrdD8O0Y2IOYvnRgN3k,793
117
117
  experimaestro/xpmutils.py,sha256=S21eMbDYsHfvmZ1HmKpq5Pz5O-1HnCLYxKbyTBbASyQ,638
118
- experimaestro-1.6.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
119
- experimaestro-1.6.0.dist-info/METADATA,sha256=ls8yp4BJZ_021MzRsuWAmIWLbKWz8apcxCwzKT8H7pM,6220
120
- experimaestro-1.6.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
121
- experimaestro-1.6.0.dist-info/entry_points.txt,sha256=TppTNiz5qm5xm1fhAcdLKdCLMrlL-eQggtCrCI00D9c,446
122
- experimaestro-1.6.0.dist-info/RECORD,,
118
+ experimaestro-1.6.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
119
+ experimaestro-1.6.2.dist-info/METADATA,sha256=3UbntC-D10JVbARfMQQKenXFCYeSZn6lkM9zkIbz_pY,6220
120
+ experimaestro-1.6.2.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
121
+ experimaestro-1.6.2.dist-info/entry_points.txt,sha256=TppTNiz5qm5xm1fhAcdLKdCLMrlL-eQggtCrCI00D9c,446
122
+ experimaestro-1.6.2.dist-info/RECORD,,