mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 17:45:08 +08:00
[RLlib] Support windows drives other than C drive for the offline json API (#9909)
This commit is contained in:
@@ -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 "
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user