Fix URL for uploaded files with '%' in their name to allow proper unquote during HTTP serving

This commit is contained in:
allegroai 2020-02-10 10:28:23 +02:00
parent c6849985ea
commit 3ee70beea2
2 changed files with 17 additions and 2 deletions

View File

@ -319,6 +319,16 @@ class ImageEvent(UploadEvent):
def get_api_event(self):
return events.MetricsImageEvent(
url=self._url,
# Hack: replace single '%' with quoted value '%25',
# allowing the link to be properly unquoted during http serving
url=self._url
if (
not self._url
or self._url.startswith("file://")
or self._url.startswith("/")
or self._url.startswith("\\")
)
else self._url.replace("%", "%25"),
key=self._key,
**self._get_base_dict())
**self._get_base_dict()
)

View File

@ -533,6 +533,11 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
return self.report_image_and_upload(title=title, series=series, iter=iter, path=path, image=matrix,
upload_uri=upload_uri, max_image_history=max_image_history)
# Hack: replace single '%' with quoted value '%25',
# allowing the link to be properly unquoted during http serving
if url:
url = url.replace('%', '%25')
self._report(ev)
plotly_dict = create_image_plot(
image_src=url,