Skip to content

Commit

Permalink
plex_init handles kwarg relative filepaths (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
acashmoney committed Aug 4, 2023
1 parent b3ff299 commit 254da28
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/src/plex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def plex_init(tool_path: str, scattering_method=ScatteringMethod.DOT_PRODUCT.val
cwd = os.getcwd()
plex_work_dir = os.environ.get("PLEX_WORK_DIR", os.path.dirname(os.path.dirname(cwd)))

# Convert all relative file paths in kwargs to absolute paths
for key, value in kwargs.items():
if isinstance(value, list):
for i in range(len(value)):
# If the value is a string and represents a file path
if isinstance(value[i], str) and os.path.isfile(value[i]):
# Convert the relative path to an absolute path
value[i] = os.path.abspath(value[i])
# If the value is a string and represents a file path
elif isinstance(value, str) and os.path.isfile(value):
kwargs[key] = os.path.abspath(value)

# Convert kwargs dictionary to a JSON string
inputs = json.dumps(kwargs)

Expand Down

0 comments on commit 254da28

Please sign in to comment.