Skip to content

Commit

Permalink
Update auroris/utils.py
Browse files Browse the repository at this point in the history
Co-authored-by: Cas Wognum <caswognum@outlook.com>
  • Loading branch information
zhu0619 and cwognum committed May 22, 2024
1 parent e0699c5 commit b417935
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions auroris/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ def bytes2img(image_bytes: ByteString):
return image


def path2url(path: str, destination: str):
def _img_to_html_src(self, path: str):
"""
Convert path to an local or remote url for html report.
Currently, only GCP is supported.
Convert a path to a corresponding `src` attribute for an `<img />` tag.
Currently only supports GCP and local paths.
"""
if not os.path.isfile(path):
if path.startswith("gs://"):
return path.replace("gs://", "https://storage.googleapis.com/")
else:
raise ValueError("Only GCP path is supported.")
else:
return os.path.relpath(path, destination)
protocol = dm.utils.fs.get_protocol(path)
if protocol == "gs":
return path.replace("gs://", "https://storage.googleapis.com/")
elif protocol == "file":
return os.path.relpath(path, self._destination)
else:
raise ValueError("We only support images hosted in GCP or locally")


def save_image(image: ImageType, path: str, destination: str):
Expand Down

0 comments on commit b417935

Please sign in to comment.