Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ def _resolve_default_cache_dir() -> Path:
def get_server_base_url() -> str:
"""Return the base URL of the currently configured server.

Turns ``"https://www.openml.org/api/v1/xml"`` in ``"https://www.openml.org/"``
Turns ``"https://api.openml.org/api/v1/xml"`` in ``"https://www.openml.org/"``
and ``"https://test.openml.org/api/v1/xml"`` in ``"https://test.openml.org/"``

Returns
-------
str
"""
return server.split("/api")[0]
domain, path = server.split("/api", maxsplit=1)
return domain.replace("api", "www")


apikey: str = _defaults["apikey"]
Expand Down Expand Up @@ -400,10 +402,9 @@ def set_field_in_config_file(field: str, value: Any) -> None:
# There doesn't seem to be a way to avoid writing defaults to file with configparser,
# because it is impossible to distinguish from an explicitly set value that matches
# the default value, to one that was set to its default because it was omitted.
value = config.get("FAKE_SECTION", f) # type: ignore
if f == field:
value = globals()[f]
fh.write(f"{f} = {value}\n")
value = globals()[f] if f == field else config.get(f) # type: ignore
if value is not None:
fh.write(f"{f} = {value}\n")
Comment on lines +405 to +407
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for not being clear about the CLI fix. That's this bit of code.. it's used only by the CLI (I think). I understand that's not particularly clear since the other edit is in the cli.py file which you might reasonably expect to also have the fix that was mentioned.

Basically, if f!=field then it would write the name of the variable to itself (e.g., apikey = apikey), instead of fetching the corresponding value from the configuration and re-writing that.



def _parse_config(config_file: str | Path) -> _Config:
Expand Down
Loading