Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions doc/progress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Changelog
0.11.0
~~~~~~

* FIX #873: Fixes an issue which resulted in incorrect URLs when printing OpenML objects after
switching the server

0.10.2
~~~~~~
* ADD #857: Adds task type ID to list_runs
Expand Down
2 changes: 1 addition & 1 deletion openml/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def openml_url(self) -> Optional[str]:
def url_for_id(cls, id_: int) -> str:
""" Return the OpenML URL for the object of the class entity with the given id. """
# Sample url for a flow: openml.org/f/123
return "{}/{}/{}".format(openml.config.server_base_url, cls._entity_letter(), id_)
return "{}/{}/{}".format(openml.config.get_server_base_url(), cls._entity_letter(), id_)

@classmethod
def _entity_letter(cls) -> str:
Expand Down
15 changes: 14 additions & 1 deletion openml/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ def configure_logging(console_output_level: int, file_output_level: int):
# Default values are actually added here in the _setup() function which is
# called at the end of this module
server = str(_defaults['server']) # so mypy knows it is a string
server_base_url = server[:-len('/api/v1/xml')]


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/"``

Returns
=======
str
"""
return server[:-len('/api/v1/xml')]


apikey = _defaults['apikey']
# The current cache directory (without the server name)
cache_directory = str(_defaults['cachedir']) # so mypy knows it is a string
Expand Down
2 changes: 1 addition & 1 deletion openml/runs/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _get_repr_body_fields(self) -> List[Tuple[str, Union[str, int, List[str]]]]:
"Dataset ID": self.dataset_id,
"Dataset URL": openml.datasets.OpenMLDataset.url_for_id(self.dataset_id)}
if self.uploader is not None:
fields["Uploader Profile"] = "{}/u/{}".format(openml.config.server_base_url,
fields["Uploader Profile"] = "{}/u/{}".format(openml.config.get_server_base_url(),
self.uploader)
if self.run_id is not None:
fields["Run URL"] = self.openml_url
Expand Down
2 changes: 1 addition & 1 deletion openml/study/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _get_repr_body_fields(self) -> List[Tuple[str, Union[str, int, List[str]]]]:
fields["ID"] = self.study_id
fields["Study URL"] = self.openml_url
if self.creator is not None:
fields["Creator"] = "{}/u/{}".format(openml.config.server_base_url, self.creator)
fields["Creator"] = "{}/u/{}".format(openml.config.get_server_base_url(), self.creator)
if self.creation_date is not None:
fields["Upload Time"] = self.creation_date.replace('T', ' ')
if self.data is not None:
Expand Down
2 changes: 1 addition & 1 deletion openml/tasks/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def id(self) -> Optional[int]:
def _get_repr_body_fields(self) -> List[Tuple[str, Union[str, int, List[str]]]]:
""" Collect all information to display in the __repr__ body. """
fields = {"Task Type Description": '{}/tt/{}'.format(
openml.config.server_base_url, self.task_type_id)} # type: Dict[str, Any]
openml.config.get_server_base_url(), self.task_type_id)} # type: Dict[str, Any]
if self.task_id is not None:
fields["Task ID"] = self.task_id
fields["Task URL"] = self.openml_url
Expand Down