[RLlib] Support windows drives other than C drive for the offline json API (#9909)

This commit is contained in:
Julius Frost
2020-08-13 05:57:54 -04:00
committed by GitHub
parent 7a56c3b71a
commit 6d9d2b320a
2 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -21,6 +21,8 @@ from typing import List
logger = logging.getLogger(__name__)
WINDOWS_DRIVES = [chr(i) for i in range(ord("c"), ord("z") + 1)]
@PublicAPI
class JsonReader(InputReader):
@@ -47,7 +49,7 @@ class JsonReader(InputReader):
logger.warning(
"Treating input directory as glob pattern: {}".format(
inputs))
if urlparse(inputs).scheme not in ["", "c"]:
if urlparse(inputs).scheme not in [""] + WINDOWS_DRIVES:
raise ValueError(
"Don't know how to glob over `{}`, ".format(inputs) +
"please specify a list of files to read instead.")
@@ -126,7 +128,7 @@ class JsonReader(InputReader):
def _next_file(self) -> FileType:
path = random.choice(self.files)
if urlparse(path).scheme not in ["", "c"]:
if urlparse(path).scheme not in [""] + WINDOWS_DRIVES:
if smart_open is None:
raise ValueError(
"You must install the `smart_open` module to read "
+3 -1
View File
@@ -21,6 +21,8 @@ from typing import Any, List
logger = logging.getLogger(__name__)
WINDOWS_DRIVES = [chr(i) for i in range(ord("c"), ord("z") + 1)]
@PublicAPI
class JsonWriter(OutputWriter):
@@ -44,7 +46,7 @@ class JsonWriter(OutputWriter):
self.ioctx = ioctx or IOContext()
self.max_file_size = max_file_size
self.compress_columns = compress_columns
if urlparse(path).scheme not in ["", "c"]:
if urlparse(path).scheme not in [""] + WINDOWS_DRIVES:
self.path_is_uri = True
else:
path = os.path.abspath(os.path.expanduser(path))