lightray 0.2.1__tar.gz → 0.2.3__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.
- {lightray-0.2.1 → lightray-0.2.3}/PKG-INFO +10 -7
- {lightray-0.2.1 → lightray-0.2.3}/README.md +8 -6
- {lightray-0.2.1 → lightray-0.2.3}/lightray/cli.py +22 -15
- {lightray-0.2.1 → lightray-0.2.3}/pyproject.toml +2 -1
- {lightray-0.2.1 → lightray-0.2.3}/lightray/__init__.py +0 -0
- {lightray-0.2.1 → lightray-0.2.3}/lightray/callbacks.py +0 -0
- {lightray-0.2.1 → lightray-0.2.3}/lightray/fs.py +0 -0
- {lightray-0.2.1 → lightray-0.2.3}/lightray/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lightray
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Distribute a LightningCLI hyperparameter search with Ray Tune
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Ethan Jacob Marx
|
|
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
16
16
|
Requires-Dist: jsonargparse[signatures] (>=4.33.2,<5.0.0)
|
|
17
17
|
Requires-Dist: lightning (<=2.4.0)
|
|
18
|
+
Requires-Dist: omegaconf (>=2.3.0,<3.0.0)
|
|
18
19
|
Requires-Dist: pyarrow (>=17.0.0,<18.0.0)
|
|
19
20
|
Requires-Dist: ray[default,tune] (>=2.8.0,<3.0.0)
|
|
20
21
|
Requires-Dist: s3fs (>=2024.9.0,<2025.0.0)
|
|
@@ -114,17 +115,19 @@ tune_callback:
|
|
|
114
115
|
cpus_per_trial: 2
|
|
115
116
|
gpus_per_trial: 1
|
|
116
117
|
|
|
117
|
-
# lightning cli
|
|
118
|
+
# lightning cli class to tune
|
|
118
119
|
lightning_cli_cls: example.lightning.Cli
|
|
119
|
-
lightning_config: /home/ethan.marx/projects/lightray/example/cli.yaml
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
Then, launch the tuning job
|
|
122
|
+
Then, launch the tuning job.
|
|
123
123
|
|
|
124
124
|
```console
|
|
125
|
-
lightray --config tune.yaml
|
|
125
|
+
lightray --config tune.yaml -- --config cli.yaml
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
+
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`.
|
|
129
|
+
|
|
130
|
+
|
|
128
131
|
## S3 Support
|
|
129
132
|
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
133
|
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 +141,9 @@ This is provided at `lightray.callbacks.LightRayReportCheckpointCallback`
|
|
|
138
141
|
|
|
139
142
|
|
|
140
143
|
## Remote cluster
|
|
141
|
-
To connect to a remote ray cluster, pass the ip address
|
|
144
|
+
To connect to a remote ray cluster, pass the ip address (using port `10001`) to `ray_init.address`:
|
|
142
145
|
|
|
143
146
|
```console
|
|
144
|
-
lightray --config tune.yaml --ray_init.address ray://{ip}:10001
|
|
147
|
+
lightray --config tune.yaml --ray_init.address ray://{ip}:10001 -- --config cli.yaml
|
|
145
148
|
```
|
|
146
149
|
|
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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
|
|
@@ -19,7 +23,7 @@ from lightray import fs, utils
|
|
|
19
23
|
|
|
20
24
|
|
|
21
25
|
def cli(args=None):
|
|
22
|
-
parser = ArgumentParser()
|
|
26
|
+
parser = ArgumentParser(parser_mode="omegaconf")
|
|
23
27
|
parser.add_argument("--config", action=ActionConfigFile)
|
|
24
28
|
parser.add_subclass_arguments(TuneCallback, "tune_callback")
|
|
25
29
|
parser.add_class_arguments(tune.TuneConfig, "tune_config")
|
|
@@ -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
|
|
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
|
-
|
|
81
|
-
|
|
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 []
|
|
@@ -136,7 +144,6 @@ def cli(args=None):
|
|
|
136
144
|
run_config=cfg_init.run_config,
|
|
137
145
|
)
|
|
138
146
|
|
|
139
|
-
# othereise, instantiate a new tuner from config
|
|
140
147
|
results = tuner.fit()
|
|
141
148
|
|
|
142
149
|
ray.shutdown()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "lightray"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.3"
|
|
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"
|
|
@@ -14,6 +14,7 @@ s3fs = {version = "^2024.9.0"}
|
|
|
14
14
|
pyarrow = {version = "^17.0.0"}
|
|
15
15
|
jsonargparse = {version = "^4.33.2", extras = ["signatures"]}
|
|
16
16
|
wandb = "^0.18.5"
|
|
17
|
+
omegaconf = "^2.3.0"
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
[tool.poetry.scripts]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|