|
8 | 8 |
|
9 | 9 | import lightning.pytorch as pl |
10 | 10 | import yaml |
11 | | -import requests |
12 | 11 | from lightning_fabric.utilities import cloud_io |
13 | 12 | from loguru import logger as cli_logger |
14 | 13 | from omegaconf import OmegaConf |
15 | 14 | from typing_extensions import TypeGuard, override |
16 | | -from requests import RequestException |
17 | | -from urllib.parse import urlparse |
18 | 15 |
|
19 | 16 | from eva.core import loggers |
20 | 17 |
|
@@ -112,26 +109,12 @@ def _load_yaml_files(paths: List[str]) -> Dict[str, Any]: |
112 | 109 | """ |
113 | 110 | merged_config = {} |
114 | 111 | for config_path in paths: |
115 | | - parsed_url = urlparse(config_path) |
116 | | - is_remote = parsed_url.scheme in ("http", "https") |
117 | | - |
118 | | - if is_remote: |
119 | | - try: |
120 | | - response = requests.get(config_path) |
121 | | - response.raise_for_status() |
122 | | - except RequestException as e: |
123 | | - raise RuntimeError(f"Failed to download remote config: {config_path}\n{str(e)}") |
124 | | - |
125 | | - omegaconf_file = OmegaConf.create(response.text) |
126 | | - else: |
127 | | - fs = cloud_io.get_filesystem(config_path) |
128 | | - with fs.open(config_path, "r") as file: |
129 | | - omegaconf_file = OmegaConf.load(file) # type: ignore |
130 | | - |
131 | | - config_dict = OmegaConf.to_object(omegaconf_file) # type: ignore |
132 | | - parsed_config = _type_resolver(config_dict) # type: ignore |
133 | | - merged_config.update(parsed_config) |
134 | | - |
| 112 | + fs = cloud_io.get_filesystem(config_path) |
| 113 | + with fs.open(config_path, "r") as file: |
| 114 | + omegaconf_file = OmegaConf.load(file) # type: ignore |
| 115 | + config_dict = OmegaConf.to_object(omegaconf_file) # type: ignore |
| 116 | + parsed_config = _type_resolver(config_dict) # type: ignore |
| 117 | + merged_config.update(parsed_config) |
135 | 118 | return merged_config |
136 | 119 |
|
137 | 120 |
|
|
0 commit comments