Skip to content

fix: Add support for pathlib in notebook field#3811

Merged
johanneskoester merged 3 commits intosnakemake:mainfrom
mschilli87:pull-3636
Nov 27, 2025
Merged

fix: Add support for pathlib in notebook field#3811
johanneskoester merged 3 commits intosnakemake:mainfrom
mschilli87:pull-3636

Conversation

@mschilli87
Copy link
Copy Markdown
Contributor

@mschilli87 mschilli87 commented Oct 27, 2025

PR #3636 added support for Pathlike notebook specifications but @staadecker (the original author of that PR) did not provide a matching test.

This PR superseeds @staadecker's original PR #3636 by merging in current main and adding a commit that adds such a test based on @staadecker's example.

I have verified that this test


closes #3636

Summary by CodeRabbit

  • Bug Fixes

    • Ensure pathlike notebook resources are converted to strings before processing to avoid inconsistent handling.
  • Tests

    • Added test coverage verifying Jupyter notebook pathlike object support with Conda deployment.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 27, 2025

📝 Walkthrough

Walkthrough

Convert Path-like notebook inputs to str inside notebook() before formatting/processing; add a new test verifying Jupyter notebook pathlike handling with CONDA deployment.

Changes

Cohort / File(s) Summary
Path object handling in notebook processing
src/snakemake/notebook.py
Added a guard that converts pathlib.Path (path-like) notebook inputs to str prior to formatting and subsequent processing.
Pathlike notebook support tests
tests/test_jupyter_notebook_pathlike.py
New test module adding fixtures and test_jupyter_notebook_pathlike to exercise a Jupyter notebook specified as a Path-like object with DeploymentMethod.CONDA.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as Rule evaluation
    participant NotebookFn as notebook()
    participant Processor as Formatting/Processing

    Caller->>NotebookFn: pass notebook path (str or Path)
    alt notebook is Path-like
        Note right of NotebookFn: convert Path -> str
        NotebookFn-->>NotebookFn: path = str(path)
    end
    NotebookFn->>Processor: format/process notebook path (now str)
    Processor-->>Caller: continue normal flow
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Areas to inspect:
    • src/snakemake/notebook.py — confirm conversion only applies to path-like inputs and preserves existing error handling and formatting behavior.
    • tests/test_jupyter_notebook_pathlike.py — verify cross-platform path handling and fixture cleanup.

Suggested reviewers

  • johanneskoester
  • cmeesters

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description provides substantive information about the changes, background context, and verification across multiple commits. However, it does not include the required QC checklist section specified in the template, which requires checkboxes confirming the presence of test cases and documentation updates. While the description is detailed and explains the changes thoroughly, it fails to follow the specified template structure that includes the formal QC section with ticked boxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "fix: Add support for pathlib in notebook field" accurately and clearly describes the main change. The modifications to src/snakemake/notebook.py add support for pathlib.Path objects in the notebook field, and the new test file verifies this functionality. The title is concise, specific, and directly related to the primary changeset without vague language or excessive detail.
Linked Issues Check ✅ Passed The PR successfully addresses all requirements from issue #3636: the code change in notebook.py adds a guard to convert Path objects to strings before processing, preventing the TypeError when pathlib.Path objects are used in the notebook field; the new test file test_jupyter_notebook_pathlike.py provides the missing test case that verifies the feature works correctly; and the PR description includes verification that the test fails on the original version and passes after the fix is applied. All coding-related requirements from the linked issue are met.
Out of Scope Changes Check ✅ Passed All changes in this PR are directly aligned with issue #3636. The modification to notebook.py implements the core fix for handling pathlib.Path objects, and the new test file test_jupyter_notebook_pathlike.py specifically addresses the testing gap mentioned in the PR description where the original PR #3636 lacked a test case. Both the code change and the test addition are necessary and in-scope for the stated objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31e8d30 and 8f36457.

⛔ Files ignored due to path filters (1)
  • pyproject.toml is excluded by !pyproject.toml
📒 Files selected for processing (2)
  • src/snakemake/notebook.py (1 hunks)
  • tests/test_jupyter_notebook_pathlike.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/snakemake/notebook.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • tests/test_jupyter_notebook_pathlike.py
🧠 Learnings (7)
📓 Common learnings
Learnt from: zmbc
PR: snakemake/snakemake#2857
File: snakemake/notebook.py:84-90
Timestamp: 2024-10-29T17:14:13.585Z
Learning: In `snakemake/notebook.py`, when suggesting enhancements to the `execute_script` method in the `JupyterNotebook` class, ensure that changes align with both papermill and nbconvert use cases.
📚 Learning: 2024-10-06T14:09:54.370Z
Learnt from: johanneskoester
PR: snakemake/snakemake#3117
File: tests/test_wrapper/Snakefile:11-11
Timestamp: 2024-10-06T14:09:54.370Z
Learning: Changes made within test cases, such as in `tests/test_wrapper/Snakefile`, are for testing purposes and do not require updates to the project documentation.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
📚 Learning: 2024-10-29T17:14:13.585Z
Learnt from: zmbc
PR: snakemake/snakemake#2857
File: snakemake/notebook.py:84-90
Timestamp: 2024-10-29T17:14:13.585Z
Learning: In `snakemake/notebook.py`, when suggesting enhancements to the `execute_script` method in the `JupyterNotebook` class, ensure that changes align with both papermill and nbconvert use cases.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
📚 Learning: 2025-01-17T12:00:09.368Z
Learnt from: leoschwarz
PR: snakemake/snakemake#3176
File: tests/test_output_index.py:99-157
Timestamp: 2025-01-17T12:00:09.368Z
Learning: New test dependencies for Snakemake should be introduced in separate PRs rather than being added as part of feature or refactoring PRs.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
📚 Learning: 2025-01-13T18:50:40.791Z
Learnt from: cademirch
PR: snakemake/snakemake#3107
File: snakemake/logging.py:20-20
Timestamp: 2025-01-13T18:50:40.791Z
Learning: Dependencies for Snakemake are managed through test-environment.yml file, which includes snakemake-interface-logger-plugins (>= 0.1.0) and other required packages.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
📚 Learning: 2024-12-21T15:10:31.992Z
Learnt from: johanneskoester
PR: snakemake/snakemake#2925
File: tests/test_nonstr_params/Snakefile:14-15
Timestamp: 2024-12-21T15:10:31.992Z
Learning: The file "test.jsonl" in tests/test_nonstr_params is automatically created by Snakemake, rather than manually generated in the Snakefile.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
📚 Learning: 2024-10-11T13:12:35.827Z
Learnt from: johanneskoester
PR: snakemake/snakemake#3132
File: snakemake/deployment/conda.py:85-88
Timestamp: 2024-10-11T13:12:35.827Z
Learning: In the `snakemake/deployment/conda.py` file, within the `Env` class, validation of `env_dir` occurs later in the code, so it's unnecessary to validate `env_dir` in the `__init__` method.

Applied to files:

  • tests/test_jupyter_notebook_pathlike.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (45)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (8, macos-latest, py313)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
🔇 Additional comments (7)
tests/test_jupyter_notebook_pathlike.py (7)

1-6: LGTM!

The imports are appropriate and necessary for testing pathlib.Path support in notebook specifications with CONDA deployment.


8-17: Excellent test case for pathlib support.

The Snakefile effectively tests the PR's objective by using DIR / "process_data.ipynb" where DIR is a pathlib.Path object. This would previously raise a TypeError ("expected str, got PosixPath") but should now work correctly after the fix in src/snakemake/notebook.py.


19-27: LGTM!

The conda environment correctly specifies jupyter and papermill, which are required for Snakemake notebook execution.


29-37: LGTM!

The minimal notebook structure is sufficient for testing pathlib support. The empty cells array keeps the test focused on path handling rather than notebook execution details.


40-44: LGTM!

The explicit testdir subdirectory improves test clarity, as you explained in the PR discussion. The structure is straightforward and appropriate.


47-55: LGTM!

The fixture correctly sets up all required files in the expected locations. The notebook path (scripts/process_data.ipynb) matches the pathlib expression used in the SNAKEFILE.


58-63: LGTM!

The test correctly verifies pathlib support in the notebook field:

  • The Path() conversion properly handles the tmpdir fixture as discussed in previous reviews.
  • Using check_results=False is appropriate since the minimal notebook produces no outputs to verify.
  • The test serves its purpose as a regression test—if the pathlib support works correctly, run() completes without raising a TypeError.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8b8620 and 6b6f9b8.

📒 Files selected for processing (2)
  • src/snakemake/notebook.py (1 hunks)
  • tests/test_jupyter_notebook_pathlike.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • src/snakemake/notebook.py
  • tests/test_jupyter_notebook_pathlike.py
🧠 Learnings (1)
📚 Learning: 2024-10-29T17:14:13.585Z
Learnt from: zmbc
PR: snakemake/snakemake#2857
File: snakemake/notebook.py:84-90
Timestamp: 2024-10-29T17:14:13.585Z
Learning: In `snakemake/notebook.py`, when suggesting enhancements to the `execute_script` method in the `JupyterNotebook` class, ensure that changes align with both papermill and nbconvert use cases.

Applied to files:

  • src/snakemake/notebook.py
🧬 Code graph analysis (1)
tests/test_jupyter_notebook_pathlike.py (1)
tests/common.py (1)
  • dpath (33-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (45)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (10, macos-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (3, macos-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (1, ubuntu-latest, py312)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (2, macos-latest, py313)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
🔇 Additional comments (2)
src/snakemake/notebook.py (1)

283-284: LGTM! Clean fix for pathlib support.

The guard correctly converts Path instances to strings before the format() call, enabling pathlib.Path objects in the notebook field without breaking existing string-based paths. The implementation handles all Path subclasses (PosixPath, WindowsPath, etc.).

tests/test_jupyter_notebook_pathlike.py (1)

7-41: Well-structured test fixtures and data.

The test correctly validates pathlike notebook specifications using notebook: DIR / "process_data.ipynb" in the Snakefile. The fixture data (SNAKEFILE, ENV_YAML, NOTEBOOK) and setup are appropriate for this regression test.

Comment thread tests/test_jupyter_notebook_pathlike.py Outdated
@mschilli87
Copy link
Copy Markdown
Contributor Author

Now all tests should pass. I consider this ready to merge. Let me know if anything else is needed from my end.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/test_jupyter_notebook_pathlike.py (2)

40-44: Consider simplifying the directory structure.

The fixture creates a nested "testdir" subdirectory within tmpdir, which appears unnecessary. You could simplify by using tmpdir directly:

 @pytest.fixture
 def testdir(tmpdir):
-    p = tmpdir.mkdir("testdir")
-    p.mkdir("scripts")
-    return p
+    tmpdir.mkdir("scripts")
+    return tmpdir

This reduces nesting while maintaining the same functionality.


58-63: Consider adding a docstring.

While the test is clear, a docstring would help document its purpose:

def test_jupyter_notebook_pathlike(testdir_notebook_pathlike):
    """Verify that pathlib.Path objects can be used in the notebook field.
    
    Regression test for issue #3636.
    """
    run(
        Path(testdir_notebook_pathlike),
        check_results=False,
        deployment_method={DeploymentMethod.CONDA},
    )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b6f9b8 and 31e8d30.

📒 Files selected for processing (1)
  • tests/test_jupyter_notebook_pathlike.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • tests/test_jupyter_notebook_pathlike.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (45)
  • GitHub Check: tests (9, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py311)
  • GitHub Check: tests (10, macos-latest, py313)
  • GitHub Check: tests (10, ubuntu-latest, py312)
  • GitHub Check: tests (9, ubuntu-latest, py313)
  • GitHub Check: tests (10, windows-2022, py313)
  • GitHub Check: tests (10, ubuntu-latest, py313)
  • GitHub Check: tests (9, ubuntu-latest, py311)
  • GitHub Check: tests (9, ubuntu-latest, py312)
  • GitHub Check: tests (8, ubuntu-latest, py312)
  • GitHub Check: tests (7, windows-2022, py313)
  • GitHub Check: tests (8, windows-2022, py313)
  • GitHub Check: tests (8, ubuntu-latest, py313)
  • GitHub Check: tests (8, ubuntu-latest, py311)
  • GitHub Check: tests (7, ubuntu-latest, py311)
  • GitHub Check: tests (7, macos-latest, py313)
  • GitHub Check: tests (6, macos-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py313)
  • GitHub Check: tests (4, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py313)
  • GitHub Check: tests (6, ubuntu-latest, py312)
  • GitHub Check: tests (7, ubuntu-latest, py312)
  • GitHub Check: tests (6, windows-2022, py313)
  • GitHub Check: tests (6, ubuntu-latest, py313)
  • GitHub Check: tests (5, ubuntu-latest, py312)
  • GitHub Check: tests (6, ubuntu-latest, py311)
  • GitHub Check: tests (4, macos-latest, py313)
  • GitHub Check: tests (5, windows-2022, py313)
  • GitHub Check: tests (5, ubuntu-latest, py311)
  • GitHub Check: tests (4, windows-2022, py313)
  • GitHub Check: tests (4, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py312)
  • GitHub Check: tests (4, ubuntu-latest, py311)
  • GitHub Check: tests (3, windows-2022, py313)
  • GitHub Check: tests (3, ubuntu-latest, py313)
  • GitHub Check: tests (3, ubuntu-latest, py311)
  • GitHub Check: tests (2, ubuntu-latest, py312)
  • GitHub Check: tests (2, windows-2022, py313)
  • GitHub Check: tests (1, macos-latest, py313)
  • GitHub Check: tests (2, ubuntu-latest, py311)
  • GitHub Check: tests (1, windows-2022, py313)
  • GitHub Check: tests (2, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py313)
  • GitHub Check: tests (1, ubuntu-latest, py311)
  • GitHub Check: tests (1, ubuntu-latest, py312)
🔇 Additional comments (4)
tests/test_jupyter_notebook_pathlike.py (4)

1-6: LGTM: Imports are correct and necessary.

All imports are used appropriately in the test.


8-17: LGTM: Test case correctly exercises Path object in notebook field.

The Snakefile uses Path("scripts") / "process_data.ipynb" which creates a pathlib.Path object, directly testing the fix for issue #3636.


19-37: LGTM: Test fixtures are minimal and appropriate.

The conda environment and empty notebook structure are sufficient for testing pathlib support without unnecessary complexity.


47-55: LGTM: Fixture correctly sets up the test environment.

The fixture creates all necessary files (notebook, conda env, Snakefile) in the correct locations to match the workflow's expectations.

@mschilli87
Copy link
Copy Markdown
Contributor Author

Regarding the nitpicks of your bot: I added the testdir on purpose because I found it more clear to make it explicit this is the directory the test will be in. Mostly because @staadecker said they weren't familiar with pytest so I wanted the test case to be easy to grasp.
Regarding the docstring, I really don't think it is nessecary here and I saw many other tests without them.
That being said, I am fine with addressing both of these issues if a human reviewers requests it.

Copy link
Copy Markdown
Contributor

@johanneskoester johanneskoester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would also have to add the new test file to the test-all command in the pyproject.toml

@johanneskoester
Copy link
Copy Markdown
Contributor

Regarding the nitpicks of your bot: I added the testdir on purpose because I found it more clear to make it explicit this is the directory the test will be in. Mostly because @staadecker said they weren't familiar with pytest so I wanted the test case to be easy to grasp. Regarding the docstring, I really don't think it is nessecary here and I saw many other tests without them. That being said, I am fine with addressing both of these issues if a human reviewers requests it.

This is totally fine. The AI is often stupid, but sometimes it catches important stuff and it helps to sort out the most severe issues before a human has a look at things.

PR snakemake#3636 added support for Pathlike `notebook` specifications but
@staadecker (the original author of that PR) did not provide a matching
test.

This commit add such a test based on @staadecker's example.

I have verified that this test

* fails (with the expected `TypeError`:

  ```
  TypeError in file "</path/to/testdir>/Snakefile", line 7:
  expected str, got PosixPath
  ```

  ) at commit 8bd1df9 (v9.6.0; parent
  of @staadecker's original PR snakemake#3636),
* passes after applying the changes of commit
  4445bb8 (@staadecker's original PR
  snakemake#3636),
* still fails (with the same expected `TypeError`, see above) at commit
  395a5e6 (current `main`), and
* still passes at commit 756656d (after
  merging the current `main` (see above) on top of @staadecker's
  original PR snakemake#3636).
@mschilli87
Copy link
Copy Markdown
Contributor Author

@johanneskoester: Good catch. Thank you and sorry for not noticing this myself. I force-pushed the requested change along an updated merge of the latest changes in main without touching @staadecker's original commit.

@mschilli87
Copy link
Copy Markdown
Contributor Author

@johanneskoester: Anything missing from my end? Do you want me to merge in current main again?

@johanneskoester
Copy link
Copy Markdown
Contributor

All fine, I am just slow these days! Always feel free to ping me via discord.

@johanneskoester johanneskoester merged commit 7b2180a into snakemake:main Nov 27, 2025
61 checks passed
johanneskoester pushed a commit that referenced this pull request Nov 27, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.14.0](v9.13.7...v9.14.0)
(2025-11-27)


### Features

* Support Hy in script directive
([#3824](#3824))
([2329c9e](2329c9e))


### Bug Fixes

* Add support for pathlib in `notebook` field
([#3811](#3811))
([7b2180a](7b2180a))
* Addressed race condition in workdir_handler.py
([#3844](#3844))
([8dbfcfb](8dbfcfb))
* cleanup update-marked output files of failed jobs if there was no
backup to restore them
([#3843](#3843))
([41f1ce8](41f1ce8))
* correct Windows callable path handling
([#3832](#3832))
([5caad70](5caad70))
* expand env vars on resources
([#3823](#3823))
([fcfa1bc](fcfa1bc))
* fix backup for output marked by `update`
([#3839](#3839))
([09c64b7](09c64b7))
* Minor fixes/additions to logging module.
([#3802](#3802))
([3b3986d](3b3986d))
* mount local storage prefix into containers
([#3840](#3840))
([f1e8b62](f1e8b62))
* properly format input/output files in case of missing rule to produce
them ([#3849](#3849))
([69d5d24](69d5d24))
* Unpack AnnotatedString in _apply_wildcards
([#3798](#3798))
([7886508](7886508))


### Performance Improvements

* retrieve storage inputs immediately before scheduling jobs instead of
before running the entire workflow
([#3850](#3850))
([4ac6cda](4ac6cda))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
PR snakemake#3636 added support for Pathlike `notebook` specifications but
@staadecker (the original author of that PR) did not provide a matching
test.
    
This PR superseeds @staadecker's original PR snakemake#3636 by merging in current
`main` and adding a commit that adds such a test based on @staadecker's
example.
    
I have verified that this test
    
* fails (with the expected `TypeError`:
  
  ```
  TypeError in file "</path/to/testdir>/Snakefile", line 7:
  expected str, got PosixPath
  ```
  
) at commit 8bd1df9 (v9.6.0; parent of
@staadecker's original PR snakemake#3636),
* passes after applying the changes of commit
4445bb8 (@staadecker's original PR
snakemake#3636),
* still fails (with the same expected `TypeError`, see above) at commit
395a5e6 (current `main`), and
* still passes at commit 756656d
merging the current `main` (see above) on top of @staadecker's original
PR snakemake#3636).

---
closes snakemake#3636

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Ensure pathlike notebook resources are converted to strings before
processing to avoid inconsistent handling.

* **Tests**
* Added test coverage verifying Jupyter notebook pathlike object support
with Conda deployment.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Martin <[email protected]>
kjohnsen pushed a commit to kjohnsen/snakemake that referenced this pull request Dec 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.14.0](snakemake/snakemake@v9.13.7...v9.14.0)
(2025-11-27)


### Features

* Support Hy in script directive
([snakemake#3824](snakemake#3824))
([2329c9e](snakemake@2329c9e))


### Bug Fixes

* Add support for pathlib in `notebook` field
([snakemake#3811](snakemake#3811))
([7b2180a](snakemake@7b2180a))
* Addressed race condition in workdir_handler.py
([snakemake#3844](snakemake#3844))
([8dbfcfb](snakemake@8dbfcfb))
* cleanup update-marked output files of failed jobs if there was no
backup to restore them
([snakemake#3843](snakemake#3843))
([41f1ce8](snakemake@41f1ce8))
* correct Windows callable path handling
([snakemake#3832](snakemake#3832))
([5caad70](snakemake@5caad70))
* expand env vars on resources
([snakemake#3823](snakemake#3823))
([fcfa1bc](snakemake@fcfa1bc))
* fix backup for output marked by `update`
([snakemake#3839](snakemake#3839))
([09c64b7](snakemake@09c64b7))
* Minor fixes/additions to logging module.
([snakemake#3802](snakemake#3802))
([3b3986d](snakemake@3b3986d))
* mount local storage prefix into containers
([snakemake#3840](snakemake#3840))
([f1e8b62](snakemake@f1e8b62))
* properly format input/output files in case of missing rule to produce
them ([snakemake#3849](snakemake#3849))
([69d5d24](snakemake@69d5d24))
* Unpack AnnotatedString in _apply_wildcards
([snakemake#3798](snakemake#3798))
([7886508](snakemake@7886508))


### Performance Improvements

* retrieve storage inputs immediately before scheduling jobs instead of
before running the entire workflow
([snakemake#3850](snakemake#3850))
([4ac6cda](snakemake@4ac6cda))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants