Skip to content

Commit bbca4b9

Browse files
authored
refactor: rename read_config() to read() (#856)
1 parent 154e8be commit bbca4b9

6 files changed

Lines changed: 12 additions & 38 deletions

File tree

diracx-cli/src/diracx/cli/internal/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_repo_path(config_repo_str: str) -> Path:
3535

3636

3737
def get_config_from_repo_path(repo_path: Path) -> Config:
38-
return ConfigSource.create_from_url(backend_url=repo_path).read_config()
38+
return ConfigSource.create_from_url(backend_url=repo_path).read()
3939

4040

4141
@app.command()

diracx-cli/tests/test_internal.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_generate_cs(tmp_path, protocol):
7272

7373

7474
def test_add_vo(cs_repo):
75-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
75+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
7676

7777
assert TEST_VO in config.Registry
7878
assert config.Registry[TEST_VO].DefaultGroup == "user"
@@ -95,7 +95,7 @@ def test_add_vo(cs_repo):
9595
],
9696
)
9797

98-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
98+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
9999
assert result.exit_code == 0, result.output
100100

101101
assert vo2 in config.Registry
@@ -121,7 +121,7 @@ def test_add_vo(cs_repo):
121121
def test_add_group(cs_repo):
122122
new_group = "testgroup2"
123123

124-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
124+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
125125

126126
assert TEST_USER_GROUP in config.Registry[TEST_VO].Groups
127127
assert config.Registry[TEST_VO].Groups[TEST_USER_GROUP].JobShare == 1000
@@ -143,7 +143,7 @@ def test_add_group(cs_repo):
143143
"AdminUser",
144144
],
145145
)
146-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
146+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
147147
assert result.exit_code == 0, result.output
148148

149149
assert new_group in config.Registry[TEST_VO].Groups
@@ -190,7 +190,7 @@ def test_add_user(cs_repo, vo, user_group):
190190
sub = "lhcb:chaen"
191191
preferred_username = "dontCallMeShirley"
192192

193-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
193+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
194194

195195
# Check the user isn't in it
196196
if vo in config.Registry:
@@ -216,7 +216,7 @@ def test_add_user(cs_repo, vo, user_group):
216216

217217
assert result.exit_code == 0, result.output
218218

219-
config = ConfigSource.create_from_url(backend_url=cs_repo).read_config()
219+
config = ConfigSource.create_from_url(backend_url=cs_repo).read()
220220
# check the user is defined
221221
assert vo in config.Registry
222222
assert sub in config.Registry[vo].Users

diracx-core/src/diracx/core/config/sources.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -171,30 +171,6 @@ def create_from_url(
171171
url = TypeAdapter(ConfigSourceUrl).validate_python(str(backend_url))
172172
return cls.__registry[url.scheme](backend_url=url)
173173

174-
@abstractmethod
175-
def read_raw(self, hexsha: str, modified: datetime) -> Config:
176-
"""Abstract method.
177-
178-
Return the Config object that corresponds to the specific hash
179-
The `modified` parameter is just added as a attribute to the config.
180-
"""
181-
182-
def read_config(self) -> Config:
183-
"""Load the configuration from the backend with appropriate caching.
184-
185-
:raises: diracx.core.exceptions.NotReadyError if the config is being loaded still
186-
:raises: git.exc.BadName if version does not exist
187-
"""
188-
return super().read()
189-
190-
async def read_config_non_blocking(self) -> Config:
191-
"""Load the configuration from the backend with appropriate caching.
192-
193-
:raises: diracx.core.exceptions.NotReadyError if the config is being loaded still
194-
:raises: git.exc.BadName if version does not exist
195-
"""
196-
return await super().read_non_blocking()
197-
198174

199175
class BaseGitConfigSource(ConfigSource):
200176
"""Base class for the git based config source."""

diracx-routers/src/diracx/routers/factory.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ def create_app_inner(
152152

153153
# Override the ConfigSource.create by the actual reading of the config
154154
# Mark it as non-blocking so we can serve 503 errors while waiting for the config
155-
app.dependency_overrides[ConfigSource.create] = (
156-
config_source.read_config_non_blocking
157-
)
155+
app.dependency_overrides[ConfigSource.create] = config_source.read_non_blocking
158156

159157
all_access_policies_used = {}
160158

diracx-routers/tests/health/test_probes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ async def test_live(client_factory):
2121
r = await _test_after_clear(config_source, probe_fcn)
2222
assert r.json() == {"status": "live"}
2323

24-
old_config = await config_source.read_config_non_blocking()
24+
old_config = await config_source.read_non_blocking()
2525
repo = Repo(config_source.repo_location)
2626
commit = repo.index.commit("Test commit")
2727
assert commit.hexsha not in old_config._hexsha
2828

2929
# This will trigger a config update but still return the old config
3030
config_source._revision_cache.soft_cache.clear()
31-
new_config = await config_source.read_config_non_blocking()
31+
new_config = await config_source.read_non_blocking()
3232
assert commit.hexsha not in old_config._hexsha
3333

3434
# If we wait long enough, the new config should be returned
@@ -37,7 +37,7 @@ async def test_live(client_factory):
3737

3838
r = probe_fcn()
3939
assert r.status_code == 200, r.text
40-
new_config = await config_source.read_config_non_blocking()
40+
new_config = await config_source.read_non_blocking()
4141
if commit.hexsha in new_config._hexsha:
4242
break
4343
else:

diracx-testing/src/diracx/testing/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def enrich_tokens(
206206
backend_url=f"git+file://{with_config_repo}"
207207
)
208208
# Warm the cache to avoid 503 errors
209-
config_source.read_config()
209+
config_source.read()
210210

211211
self.app = create_app_inner(
212212
enabled_systems=enabled_systems,

0 commit comments

Comments
 (0)