Skip to content

Commit 37d4950

Browse files
JklubienskiJklubienski
authored andcommitted
Change _save_config function to use fspec
1 parent 400dff8 commit 37d4950

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

src/eva/core/callbacks/config.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
import lightning.pytorch as pl
1010
import yaml
11-
import requests
1211
from lightning_fabric.utilities import cloud_io
1312
from loguru import logger as cli_logger
1413
from omegaconf import OmegaConf
1514
from typing_extensions import TypeGuard, override
16-
from requests import RequestException
17-
from urllib.parse import urlparse
1815

1916
from eva.core import loggers
2017

@@ -112,26 +109,12 @@ def _load_yaml_files(paths: List[str]) -> Dict[str, Any]:
112109
"""
113110
merged_config = {}
114111
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)
135118
return merged_config
136119

137120

src/eva/core/trainers/_recorder.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
import statistics
77
import sys
8-
import requests
98
from typing import Dict, List, Mapping, TypedDict
109

1110
from lightning.pytorch.utilities.types import _EVALUATE_OUTPUT
@@ -15,8 +14,6 @@
1514
from rich import console as rich_console
1615
from rich import table as rich_table
1716
from toolz import dicttoolz
18-
from urllib.parse import urlparse
19-
from requests.exceptions import RequestException
2017

2118
SESSION_METRICS = Mapping[str, List[float]]
2219
"""Session metrics type-hint."""

0 commit comments

Comments
 (0)