[rllib] Fix to allow input strings that are not file paths (#16830)

This commit is contained in:
Julius Frost 2021-07-03 04:12:47 -04:00 committed by GitHub
parent 4bb3883a73
commit 7842bda50a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,10 +182,15 @@ def run(args, parser):
inputs = force_list(input_)
# This script runs in the ray/rllib dir.
rllib_dir = Path(__file__).parent
abs_inputs = [
str(rllib_dir.absolute().joinpath(i))
if not os.path.exists(i) else i for i in inputs
]
def patch_path(path):
if os.path.exists(path):
return path
else:
abs_path = str(rllib_dir.absolute().joinpath(path))
return abs_path if os.path.exists(abs_path) else path
abs_inputs = list(map(patch_path, inputs))
if not isinstance(input_, list):
abs_inputs = abs_inputs[0]