experimaestro 1.3.5__py3-none-any.whl → 1.3.6__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.

@@ -36,13 +36,18 @@ class SerializedPath:
36
36
 
37
37
 
38
38
  class SerializationContext:
39
+ """Context when serializing experimaestro configurations"""
40
+
39
41
  save_directory: Optional[Path]
40
42
  var_path: List[str]
41
43
  serialized: Set[int]
42
44
 
43
- """Context when serializing experimaestro configurations"""
44
-
45
45
  def __init__(self, *, save_directory: Optional[Path] = None):
46
+ """Creates a new serialization context
47
+
48
+ :param save_directory: Defines the directory where `SerializedPath` are
49
+ stored
50
+ """
46
51
  self.save_directory = save_directory
47
52
  self.var_path = []
48
53
  self.serialized = set()
@@ -5,7 +5,7 @@ from pathlib import Path
5
5
  from shutil import rmtree
6
6
  import threading
7
7
  import time
8
- from typing import List, Optional, Set, TypeVar, Union, TYPE_CHECKING
8
+ from typing import Any, List, Optional, Set, TypeVar, Union, TYPE_CHECKING
9
9
  import enum
10
10
  import signal
11
11
  import asyncio
@@ -482,7 +482,7 @@ class Scheduler:
482
482
 
483
483
  return None
484
484
 
485
- async def aio_submit(self, job: Job) -> JobState:
485
+ async def aio_submit(self, job: Job) -> JobState: # noqa: C901
486
486
  """Main scheduler function: submit a job, run it (if needed), and returns
487
487
  the status code
488
488
  """
@@ -693,14 +693,25 @@ ServiceClass = TypeVar("ServiceClass", bound=Service)
693
693
 
694
694
 
695
695
  class experiment:
696
- """Experiment context"""
696
+ """Main experiment object
697
+
698
+ It is a context object, i.e. experiments is run with
699
+
700
+ ```py
701
+ with experiment(...) as xp:
702
+ ...
703
+ ```
704
+ """
697
705
 
698
706
  # Current experiment
699
707
  CURRENT: Optional["experiment"] = None
700
708
 
701
709
  @staticmethod
702
710
  def current() -> "experiment":
703
- """Returns the current experiment, but checking first if set"""
711
+ """Returns the current experiment, but checking first if set
712
+
713
+ If there is no current experiment, raises an AssertError
714
+ """
704
715
  assert experiment.CURRENT is not None, "No current experiment defined"
705
716
  return experiment.CURRENT
706
717
 
@@ -718,9 +729,18 @@ class experiment:
718
729
  """
719
730
  :param env: an environment -- or a working directory for a local
720
731
  environment
721
- :param port: the port for the web server (overrides environment port if
722
- any). Use None to avoid running a web server (default when dry run).
732
+
733
+ :param name: the identifier of the experiment
734
+
723
735
  :param launcher: The launcher (if not provided, inferred from path)
736
+
737
+ :param host: The host for the web server (overrides the environment if
738
+ set)
739
+ :param port: the port for the web server (overrides the environment if
740
+ set). Use negative number to avoid running a web server (default when dry run).
741
+
742
+ :param run_mode: The run mode for the experiment (normal, generate run
743
+ files, dry run)
724
744
  """
725
745
 
726
746
  from experimaestro.server import Server
@@ -759,7 +779,7 @@ class experiment:
759
779
  self.scheduler = Scheduler(self, name)
760
780
  self.server = (
761
781
  Server(self.scheduler, settings.server)
762
- if settings.server.port is not None
782
+ if (settings.server.port is not None and settings.server.port >= 0)
763
783
  and self.workspace.run_mode == RunMode.NORMAL
764
784
  else None
765
785
  )
@@ -842,7 +862,9 @@ class experiment:
842
862
  self.environment.setenv(name, value)
843
863
 
844
864
  def token(self, name: str, count: int):
845
- """Returns a token for this experiment depending on the host"""
865
+ """Returns a token for this experiment
866
+
867
+ The token is the default token of the workspace connector"""
846
868
  return self.workspace.connector.createtoken(name, count)
847
869
 
848
870
  def __enter__(self):
@@ -928,8 +950,43 @@ class experiment:
928
950
  self.server.stop()
929
951
 
930
952
  def add_service(self, service: ServiceClass) -> ServiceClass:
931
- """Adds a service (e.g. tensorboard viewer) to the experiment"""
953
+ """Adds a service (e.g. tensorboard viewer) to the experiment
954
+
955
+ :param service: A service instance
956
+ :type service: Service
957
+ :return: The same service instance
958
+ """
932
959
  self.services[service.id] = service
933
960
  for listener in self.scheduler.listeners:
934
961
  listener.service_add(service)
935
962
  return service
963
+
964
+ def save(self, obj: Any, name: str = "default"):
965
+ """Serializes configurations.
966
+
967
+ Saves configuration objects within the experimental directory
968
+
969
+ :param obj: The object to save
970
+ :param name: The name of the saving directory (default to `default`)
971
+ """
972
+
973
+ if self.workspace.run_mode == RunMode.NORMAL:
974
+ from experimaestro import save
975
+
976
+ save_dir = self.workdir / "data" / name
977
+ save_dir.mkdir(exist_ok=True, parents=True)
978
+
979
+ save(obj, save_dir)
980
+
981
+ def load(self, reference: str, name: str = "default"):
982
+ """Serializes configurations.
983
+
984
+ Loads configuration objects from an experimental directory
985
+
986
+ :param reference: The name of the experiment
987
+ :param name: The name of the saving directory (default to `default`)
988
+ """
989
+ from experimaestro import load
990
+
991
+ path = self.workspace.experimentspath / reference / "data" / name
992
+ return load(path)
@@ -6,6 +6,8 @@ from typing import Set
6
6
 
7
7
 
8
8
  class ServiceListener:
9
+ """A service listener"""
10
+
9
11
  def service_state_changed(service):
10
12
  pass
11
13
 
@@ -18,6 +20,12 @@ class ServiceState(Enum):
18
20
 
19
21
 
20
22
  class Service:
23
+ """An experiment service
24
+
25
+ Services can be associated with an experiment. They send
26
+ notifications to service listeners.
27
+ """
28
+
21
29
  id: str
22
30
  _state: ServiceState = ServiceState.STOPPED
23
31
 
@@ -25,9 +33,17 @@ class Service:
25
33
  self.listeners: Set[ServiceListener] = set()
26
34
 
27
35
  def add_listener(self, listener: ServiceListener):
36
+ """Adds a listener
37
+
38
+ :param listener: The listener to add
39
+ """
28
40
  self.listeners.add(listener)
29
41
 
30
42
  def remove_listener(self, listener: ServiceListener):
43
+ """Removes a listener
44
+
45
+ :param listener: The listener to remove
46
+ """
31
47
  self.listeners.remove(listener)
32
48
 
33
49
  def description(self):
@@ -47,6 +63,8 @@ class Service:
47
63
 
48
64
 
49
65
  class WebService(Service):
66
+ """Web service"""
67
+
50
68
  def __init__(self):
51
69
  super().__init__()
52
70
  self.url = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: experimaestro
3
- Version: 1.3.5
3
+ Version: 1.3.6
4
4
  Summary: "Experimaestro is a computer science experiment manager"
5
5
  Home-page: https://github.com/experimaestro/experimaestro-python
6
6
  License: GPL-3
@@ -10,7 +10,7 @@ experimaestro/connectors/local.py,sha256=6tlaZb0tvNS2mjsapiVbfY7kIfLICJad137VXBM
10
10
  experimaestro/connectors/ssh.py,sha256=A6qObY_phynZVQFdAsyymP9c0fiUHwn04nShROzMrec,7896
11
11
  experimaestro/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  experimaestro/core/arguments.py,sha256=dW32opqNEsULYr6nR7Zk8PqHsSCbLPclfXofw27GTpI,5620
13
- experimaestro/core/context.py,sha256=70ZhDBobGDl0wEyvZyqyrnWagLs7EiRf0cBSXp1N3Lc,2479
13
+ experimaestro/core/context.py,sha256=Q8_ngiHRBZ0laavXRJNiDvdCprrnROVTWaHfrwMdlG4,2638
14
14
  experimaestro/core/objects.py,sha256=AuviYnITYuoKkj2MR6ovyU7cMl8BgJfXp5yAKaunlJo,62571
15
15
  experimaestro/core/objects.pyi,sha256=D8-kd-NU-pRl9-_ktXUne_k1YH6TG3VGqRaKV8mrZwk,7003
16
16
  experimaestro/core/serialization.py,sha256=nLlSSqerH9lqiWvqkCxz0YRRW8M1y56ainZ9_GVgTMk,3432
@@ -45,10 +45,10 @@ experimaestro/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
45
  experimaestro/rpyc.py,sha256=ZRKol-3tVoeoUITLNFenLF4dhWBLW_FvSV_GvsypmeI,3605
46
46
  experimaestro/run.py,sha256=tH9oG7o8_c7cp0cyBLIzWN7CVYjtz72SChz2X-FjYhs,4455
47
47
  experimaestro/scheduler/__init__.py,sha256=ERmmOxz_9mUkIuccNbzUa5Y6gVLLVDdyc4cCxbCCUbY,20
48
- experimaestro/scheduler/base.py,sha256=StJMB-9aPv5r91Zfo8ZNVButPowVhWjtqi3esf5Husk,29257
48
+ experimaestro/scheduler/base.py,sha256=B4L3E-TnNjt0kutaEVrnA3-rTpoCfuXZO9rzH28phNI,30945
49
49
  experimaestro/scheduler/dependencies.py,sha256=n9XegwrmjayOIxt3xhuTEBVEBGSq4oeVdzz-FviDGXo,1994
50
50
  experimaestro/scheduler/environment.py,sha256=ZaSHSgAcZBmIj7b_eS1OvNQOuVLFvuw-qvqtYrc3Vms,2393
51
- experimaestro/scheduler/services.py,sha256=lrxhM4feQuGjtBVHJbEdmzI9x-bPBa5rXVcaDjjiSqU,1820
51
+ experimaestro/scheduler/services.py,sha256=aCKkNZMULlceabqf-kOs_-C7KPINnjU3Q-I00o5x6iY,2189
52
52
  experimaestro/scheduler/workspace.py,sha256=xATJi6-GJcpdwB4alliJnmAuvwt-URUiUKUfq5scUac,1731
53
53
  experimaestro/scriptbuilder.py,sha256=-wq4jgH8eKpjKWyU_7SxU7MNJLfPqZ0VdERv6rrkJ88,4235
54
54
  experimaestro/server/__init__.py,sha256=F2bzLf2q29Haj2OIbPA26r5WVbaipBNylIozg-As758,10854
@@ -137,8 +137,8 @@ experimaestro/utils/resources.py,sha256=gDjkrRjo7GULWyXmNXm_u1uqzEIAoAvJydICk56n
137
137
  experimaestro/utils/settings.py,sha256=jpFMqF0DLL4_P1xGal0zVR5cOrdD8O0Y2IOYvnRgN3k,793
138
138
  experimaestro/utils/yaml.py,sha256=jEjqXqUtJ333wNUdIc0o3LGvdsTQ9AKW9a9CCd-bmGU,6766
139
139
  experimaestro/xpmutils.py,sha256=S21eMbDYsHfvmZ1HmKpq5Pz5O-1HnCLYxKbyTBbASyQ,638
140
- experimaestro-1.3.5.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
141
- experimaestro-1.3.5.dist-info/METADATA,sha256=dk-rmZJ-s5UfCM1f3rL4mFU4j4Zm3AaZX65LFxWJR5U,5336
142
- experimaestro-1.3.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
143
- experimaestro-1.3.5.dist-info/entry_points.txt,sha256=PhaEili_fDgn5q7rBJGip_uhGkRBq5l3Yuhg91zkcbk,574
144
- experimaestro-1.3.5.dist-info/RECORD,,
140
+ experimaestro-1.3.6.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
141
+ experimaestro-1.3.6.dist-info/METADATA,sha256=oIMCcjrUWC-mHhVFI2K2aj5d-cw3JXLMqlmID1LD4Bo,5336
142
+ experimaestro-1.3.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
143
+ experimaestro-1.3.6.dist-info/entry_points.txt,sha256=PhaEili_fDgn5q7rBJGip_uhGkRBq5l3Yuhg91zkcbk,574
144
+ experimaestro-1.3.6.dist-info/RECORD,,