Skip to content

Commit

Permalink
fix: allow script directive to take pathlib Path (#1869)
Browse files Browse the repository at this point in the history
### Description

This PR allows the `script` directive to accept a `pathlib.Path` object.

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [ ] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).
  • Loading branch information
mbhall88 committed Sep 21, 2022
1 parent 2dc2e6a commit 12cdc96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions snakemake/script.py
Expand Up @@ -1498,6 +1498,8 @@ def script(
"""
Load a script from the given basedir + path and execute it.
"""
if isinstance(path, Path):
path = str(path)

path, source, language, is_local = get_source(
path, SourceCache(runtime_sourcecache_path), basedir, wildcards, params
Expand Down
4 changes: 3 additions & 1 deletion tests/test_script/Snakefile
@@ -1,3 +1,5 @@
from pathlib import Path


configfile: "config.yaml"

Expand Down Expand Up @@ -28,7 +30,7 @@ rule:
output:
"test.in"
script:
"scripts/test.py"
Path("scripts/test.py")

rule:
output:
Expand Down

0 comments on commit 12cdc96

Please sign in to comment.