Skip to content

Monkey-patch os.path to support gs:// URIs#273

Open
janEbert wants to merge 1 commit intogoogle:mainfrom
janEbert:mp-os-path
Open

Monkey-patch os.path to support gs:// URIs#273
janEbert wants to merge 1 commit intogoogle:mainfrom
janEbert:mp-os-path

Conversation

@janEbert
Copy link

This monkey-patches the private os.path._get_sep function used by os.path.join to handle paths that start with "gs://". If a path starts with "gs://", we ignore the OS separator and return "/" as the separator to use.

Background info

For example in the pretrained_optimizers.py file, os.path.join is used to concat strings for the gs:// URIs (one example).
This will cause issues on Windows machines because there, URIs are concatenated with "".

Since I understand monkey-patching is always quite fickle, I can also replace all os.path.join usages with a new method that uses '/'.join(paths) for "gs://" paths instead.

This monkey-patches the private `os.path._get_sep` function used by
`os.path.join` to handle paths that start with "gs://". If a path starts
with "gs://", we ignore the OS separator and return "/" as the separator
to use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant