lightray 0.2.1__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lightray
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Distribute a LightningCLI hyperparameter search with Ray Tune
5
5
  License: MIT
6
6
  Author: Ethan Jacob Marx
@@ -114,17 +114,19 @@ tune_callback:
114
114
  cpus_per_trial: 2
115
115
  gpus_per_trial: 1
116
116
 
117
- # lightning cli
117
+ # lightning cli class to tune
118
118
  lightning_cli_cls: example.lightning.Cli
119
- lightning_config: /home/ethan.marx/projects/lightray/example/cli.yaml
120
119
  ```
121
120
 
122
- Then, launch the tuning job
121
+ Then, launch the tuning job.
123
122
 
124
123
  ```console
125
- lightray --config tune.yaml
124
+ lightray --config tune.yaml -- --config cli.yaml
126
125
  ```
127
126
 
127
+ Any arguments passed after "--" will automatically be forwarded to the specified `LightningCLI` class as if it were being run from the command line. This way, tuning configuration and training configuration can be kept separate. Also, you can easily utilize existing configuration files compatible with your `LightningCLI`.
128
+
129
+
128
130
  ## S3 Support
129
131
  In addition, there is automatic support for `s3` storage. Make sure you have set the `AWS_ENDPOINT_URL`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` environment variables.
130
132
  Then, simply pass the path to your bucket with the `s3` prefix (e.g. `s3://{bucket}/{folder}`) to the `run_config.storage_path` argument.
@@ -138,9 +140,9 @@ This is provided at `lightray.callbacks.LightRayReportCheckpointCallback`
138
140
 
139
141
 
140
142
  ## Remote cluster
141
- To connect to a remote ray cluster, pass the ip address and (using port `10001`) to `ray_init.address`:
143
+ To connect to a remote ray cluster, pass the ip address (using port `10001`) to `ray_init.address`:
142
144
 
143
145
  ```console
144
- lightray --config tune.yaml --ray_init.address ray://{ip}:10001
146
+ lightray --config tune.yaml --ray_init.address ray://{ip}:10001 -- --config cli.yaml
145
147
  ```
146
148
 
@@ -91,17 +91,19 @@ tune_callback:
91
91
  cpus_per_trial: 2
92
92
  gpus_per_trial: 1
93
93
 
94
- # lightning cli
94
+ # lightning cli class to tune
95
95
  lightning_cli_cls: example.lightning.Cli
96
- lightning_config: /home/ethan.marx/projects/lightray/example/cli.yaml
97
96
  ```
98
97
 
99
- Then, launch the tuning job
98
+ Then, launch the tuning job.
100
99
 
101
100
  ```console
102
- lightray --config tune.yaml
101
+ lightray --config tune.yaml -- --config cli.yaml
103
102
  ```
104
103
 
104
+ Any arguments passed after "--" will automatically be forwarded to the specified `LightningCLI` class as if it were being run from the command line. This way, tuning configuration and training configuration can be kept separate. Also, you can easily utilize existing configuration files compatible with your `LightningCLI`.
105
+
106
+
105
107
  ## S3 Support
106
108
  In addition, there is automatic support for `s3` storage. Make sure you have set the `AWS_ENDPOINT_URL`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY` environment variables.
107
109
  Then, simply pass the path to your bucket with the `s3` prefix (e.g. `s3://{bucket}/{folder}`) to the `run_config.storage_path` argument.
@@ -115,8 +117,8 @@ This is provided at `lightray.callbacks.LightRayReportCheckpointCallback`
115
117
 
116
118
 
117
119
  ## Remote cluster
118
- To connect to a remote ray cluster, pass the ip address and (using port `10001`) to `ray_init.address`:
120
+ To connect to a remote ray cluster, pass the ip address (using port `10001`) to `ray_init.address`:
119
121
 
120
122
  ```console
121
- lightray --config tune.yaml --ray_init.address ray://{ip}:10001
123
+ lightray --config tune.yaml --ray_init.address ray://{ip}:10001 -- --config cli.yaml
122
124
  ```
@@ -1,6 +1,5 @@
1
1
  """
2
- A large portion of this was inspired by
3
- https://github.com/mauvilsa/ray-tune-cli/
2
+ Heavily inspired by https://github.com/mauvilsa/ray-tune-cli/
4
3
  """
5
4
 
6
5
  import logging
@@ -10,7 +9,12 @@ from typing import Optional, Type
10
9
 
11
10
  import pyarrow
12
11
  import ray
13
- from jsonargparse import ActionConfigFile, ArgumentParser, capture_parser
12
+ from jsonargparse import (
13
+ REMAINDER,
14
+ ActionConfigFile,
15
+ ArgumentParser,
16
+ capture_parser,
17
+ )
14
18
  from lightning.pytorch.cli import LightningCLI
15
19
  from ray import train, tune
16
20
  from ray.tune.integration.pytorch_lightning import TuneCallback
@@ -31,7 +35,7 @@ def cli(args=None):
31
35
  parser.add_class_arguments(train.SyncConfig, "sync_config")
32
36
  parser.add_function_arguments(ray.init, "ray_init")
33
37
  parser.add_argument(
34
- "lightning_cli_cls",
38
+ "--lightning_cli_cls",
35
39
  type=Type[LightningCLI],
36
40
  help="Lightning CLI class",
37
41
  )
@@ -43,11 +47,6 @@ def cli(args=None):
43
47
  )
44
48
  parser.add_argument("--gpus_per_trial", type=int, default=0)
45
49
  parser.add_argument("--cpus_per_trial", type=int, default=1)
46
- parser.add_argument(
47
- "lightning_config",
48
- type=str,
49
- help="Path to the lightning config file",
50
- )
51
50
 
52
51
  parser.link_arguments(
53
52
  "run_config.checkpoint_config.checkpoint_score_attribute",
@@ -60,6 +59,13 @@ def cli(args=None):
60
59
  apply_on="parse",
61
60
  )
62
61
 
62
+ parser.add_argument(
63
+ "lightning_args",
64
+ nargs=REMAINDER,
65
+ help='All arguments after the double dash "--"'
66
+ "are forwarded to the LightningCLI-based function",
67
+ )
68
+
63
69
  cfg = parser.parse_args(args)
64
70
 
65
71
  log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
@@ -69,7 +75,8 @@ def cli(args=None):
69
75
  stream=sys.stdout,
70
76
  )
71
77
 
72
- # get lightning cli parser and parse passed config
78
+ # get lightning cli parser and parse any arguments
79
+ # passed after "--" at the command line
73
80
  lightning_cli_cls = cfg.lightning_cli_cls
74
81
  lightning_parser = capture_parser(lightning_cli_cls)
75
82
  if lightning_parser._subcommands_action:
@@ -77,9 +84,10 @@ def cli(args=None):
77
84
  lightning_parser._subcommands_action._name_parser_map["fit"]
78
85
  )
79
86
 
80
- lightning_cfg = lightning_parser.parse_args(
81
- ["--config", cfg.lightning_config]
82
- )
87
+ if len(cfg.lightning_args) > 1:
88
+ lightning_cfg = lightning_parser.parse_args(cfg.lightning_args[1:])
89
+ else:
90
+ lightning_cfg = lightning_parser.get_defaults()
83
91
 
84
92
  callbacks = [cfg.tune_callback]
85
93
  callbacks += lightning_cfg.get("trainer.callbacks") or []
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "lightray"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Distribute a LightningCLI hyperparameter search with Ray Tune"
5
5
  authors = ["Ethan Jacob Marx <ethan.marx@ligo.org>"]
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes