Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PathLib paths in targets #410

Open
simondrue opened this issue Jan 23, 2024 · 1 comment
Open

Support PathLib paths in targets #410

simondrue opened this issue Jan 23, 2024 · 1 comment

Comments

@simondrue
Copy link

When I try to use a Path from pathlib for inputs/outputs in a target I get the following error message:

File "/home/simond/miniconda3/lib/python3.9/site-packages/gwf/workflow.py", line 257, in target_from_template
    new_target = Target(
  File "<attrs generated init gwf.core.Target>", line 17, in __init__
  File "/home/simond/miniconda3/lib/python3.9/site-packages/gwf/core.py", line 197, in _validate_path
    _check_path(path)
  File "/home/simond/miniconda3/lib/python3.9/site-packages/gwf/core.py", line 58, in _check_path
    result = _has_nonprintable_char(path)
  File "/home/simond/miniconda3/lib/python3.9/site-packages/gwf/core.py", line 39, in _has_nonprintable_char
    chars = enumerate((unicodedata.category(char) == "Cc", char) for char in s)
TypeError: 'PosixPath' object is not iterable

The problem is that Path from pathlib do not support iteration as shown here:

>>> from pathlib import Path
>>> a = Path("/foo/bar")
>>> [c for c in a]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'PosixPath' object is not iterable

It would be really nice if GWF was to support pathlib

Thanks for a great tool 😃

@dansondergaard
Copy link
Collaborator

I'll take a look at this for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants